1 /* 2 * Copyright © 2016 Red Hat. 3 * Copyright © 2016 Bas Nieuwenhuizen 4 * SPDX-License-Identifier: MIT 5 * 6 * based in part on anv driver which is: 7 * Copyright © 2015 Intel Corporation 8 */ 9 10 #ifndef TU_PASS_H 11 #define TU_PASS_H 12 13 #include "tu_common.h" 14 15 enum tu_gmem_layout 16 { 17 /* Use all of GMEM for attachments */ 18 TU_GMEM_LAYOUT_FULL, 19 /* Avoid using the region of GMEM that the CCU needs */ 20 TU_GMEM_LAYOUT_AVOID_CCU, 21 /* Number of layouts we have, also the value set when we don't know the layout in a secondary. */ 22 TU_GMEM_LAYOUT_COUNT, 23 }; 24 25 struct tu_subpass_barrier { 26 VkPipelineStageFlags2 src_stage_mask; 27 VkPipelineStageFlags2 dst_stage_mask; 28 VkAccessFlags2 src_access_mask; 29 VkAccessFlags2 dst_access_mask; 30 bool incoherent_ccu_color, incoherent_ccu_depth; 31 }; 32 33 struct tu_subpass_attachment 34 { 35 uint32_t attachment; 36 37 /* For input attachments, true if it needs to be patched to refer to GMEM 38 * in GMEM mode. This is false if it hasn't already been written as an 39 * attachment. 40 */ 41 bool patch_input_gmem; 42 }; 43 44 struct tu_subpass 45 { 46 uint32_t input_count; 47 uint32_t color_count; 48 uint32_t resolve_count; 49 bool resolve_depth_stencil; 50 51 bool legacy_dithering_enabled; 52 53 bool feedback_loop_color; 54 bool feedback_loop_ds; 55 56 /* True if we must invalidate UCHE thanks to a feedback loop. */ 57 bool feedback_invalidate; 58 59 /* In other words - framebuffer fetch support */ 60 bool raster_order_attachment_access; 61 62 struct tu_subpass_attachment *input_attachments; 63 struct tu_subpass_attachment *color_attachments; 64 struct tu_subpass_attachment *resolve_attachments; 65 struct tu_subpass_attachment depth_stencil_attachment; 66 67 uint32_t fsr_attachment; 68 VkExtent2D fsr_attachment_texel_size; 69 70 /* When using dynamic rendering depth and stencil attachments may be 71 * set to unused independently, so we need to track this bit of 72 * information separately for each of them. 73 * 74 * Due to VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08916 and 75 * VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08917 we can set 76 * these values at cmdBeginRendering() time. 77 */ 78 bool depth_used; 79 bool stencil_used; 80 81 VkSampleCountFlagBits samples; 82 83 uint32_t srgb_cntl; 84 uint32_t multiview_mask; 85 86 struct tu_subpass_barrier start_barrier; 87 }; 88 89 struct tu_render_pass_attachment 90 { 91 VkFormat format; 92 VkSampleCountFlagBits samples; 93 uint32_t cpp; 94 VkImageAspectFlags clear_mask; 95 uint32_t clear_views; 96 bool load; 97 bool store; 98 bool gmem; 99 int32_t gmem_offset[TU_GMEM_LAYOUT_COUNT]; 100 bool will_be_resolved; 101 /* for D32S8 separate stencil: */ 102 bool load_stencil; 103 bool store_stencil; 104 105 bool cond_load_allowed; 106 bool cond_store_allowed; 107 108 int32_t gmem_offset_stencil[TU_GMEM_LAYOUT_COUNT]; 109 110 /* The subpass id in which the attachment will be used first/last. */ 111 uint32_t first_subpass_idx; 112 uint32_t last_subpass_idx; 113 }; 114 115 struct tu_render_pass 116 { 117 struct vk_object_base base; 118 119 uint32_t attachment_count; 120 uint32_t subpass_count; 121 uint32_t gmem_pixels[TU_GMEM_LAYOUT_COUNT]; 122 uint32_t tile_align_w; 123 uint32_t min_cpp; 124 uint64_t autotune_hash; 125 126 /* memory bandwidth costs (in bytes) for gmem / sysmem rendering */ 127 uint32_t gmem_bandwidth_per_pixel; 128 uint32_t sysmem_bandwidth_per_pixel; 129 130 unsigned num_views; 131 132 struct tu_subpass_attachment fragment_density_map; 133 134 struct tu_subpass_attachment *subpass_attachments; 135 136 struct tu_render_pass_attachment *attachments; 137 bool has_cond_load_store; 138 bool has_fdm; 139 140 struct tu_subpass_barrier end_barrier; 141 struct tu_subpass subpasses[0]; 142 }; 143 144 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_render_pass, base, VkRenderPass, 145 VK_OBJECT_TYPE_RENDER_PASS) 146 147 void tu_setup_dynamic_render_pass(struct tu_cmd_buffer *cmd_buffer, 148 const VkRenderingInfo *pRenderingInfo); 149 150 void tu_setup_dynamic_inheritance(struct tu_cmd_buffer *cmd_buffer, 151 const VkCommandBufferInheritanceRenderingInfo *info); 152 153 uint32_t 154 tu_subpass_get_attachment_to_resolve(const struct tu_subpass *subpass, uint32_t index); 155 156 #endif /* TU_PASS_H */ 157