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 feedback_loop_color; 52 bool feedback_loop_ds; 53 54 /* True if we must invalidate UCHE thanks to a feedback loop. */ 55 bool feedback_invalidate; 56 57 /* In other words - framebuffer fetch support */ 58 bool raster_order_attachment_access; 59 60 struct tu_subpass_attachment *input_attachments; 61 struct tu_subpass_attachment *color_attachments; 62 struct tu_subpass_attachment *resolve_attachments; 63 struct tu_subpass_attachment depth_stencil_attachment; 64 65 VkSampleCountFlagBits samples; 66 67 uint32_t srgb_cntl; 68 uint32_t multiview_mask; 69 70 struct tu_subpass_barrier start_barrier; 71 }; 72 73 struct tu_render_pass_attachment 74 { 75 VkFormat format; 76 uint32_t samples; 77 uint32_t cpp; 78 VkImageAspectFlags clear_mask; 79 uint32_t clear_views; 80 bool load; 81 bool store; 82 bool gmem; 83 int32_t gmem_offset[TU_GMEM_LAYOUT_COUNT]; 84 bool will_be_resolved; 85 /* for D32S8 separate stencil: */ 86 bool load_stencil; 87 bool store_stencil; 88 89 bool cond_load_allowed; 90 bool cond_store_allowed; 91 92 int32_t gmem_offset_stencil[TU_GMEM_LAYOUT_COUNT]; 93 }; 94 95 struct tu_render_pass 96 { 97 struct vk_object_base base; 98 99 uint32_t attachment_count; 100 uint32_t subpass_count; 101 uint32_t gmem_pixels[TU_GMEM_LAYOUT_COUNT]; 102 uint32_t tile_align_w; 103 104 /* memory bandwidth costs (in bytes) for gmem / sysmem rendering */ 105 uint32_t gmem_bandwidth_per_pixel; 106 uint32_t sysmem_bandwidth_per_pixel; 107 108 struct tu_subpass_attachment *subpass_attachments; 109 struct tu_render_pass_attachment *attachments; 110 struct tu_subpass_barrier end_barrier; 111 struct tu_subpass subpasses[0]; 112 }; 113 114 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_render_pass, base, VkRenderPass, 115 VK_OBJECT_TYPE_RENDER_PASS) 116 117 void tu_setup_dynamic_render_pass(struct tu_cmd_buffer *cmd_buffer, 118 const VkRenderingInfo *pRenderingInfo); 119 120 void tu_setup_dynamic_inheritance(struct tu_cmd_buffer *cmd_buffer, 121 const VkCommandBufferInheritanceRenderingInfo *info); 122 123 uint32_t 124 tu_subpass_get_attachment_to_resolve(const struct tu_subpass *subpass, uint32_t index); 125 126 #endif /* TU_PASS_H */ 127