xref: /aosp_15_r20/external/mesa3d/src/freedreno/vulkan/tu_pass.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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    /*  When using dynamic rendering depth and stencil attachments may be
67     *  set to unused independently, so we need to track this bit of
68     *  information separately for each of them.
69     *
70     *  Due to VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08916 and
71     *  VUID-vkCmdDraw-dynamicRenderingUnusedAttachments-08917 we can set
72     *  these values at cmdBeginRendering() time.
73     */
74    bool depth_used;
75    bool stencil_used;
76 
77    VkSampleCountFlagBits samples;
78 
79    uint32_t srgb_cntl;
80    uint32_t multiview_mask;
81 
82    struct tu_subpass_barrier start_barrier;
83 };
84 
85 struct tu_render_pass_attachment
86 {
87    VkFormat format;
88    VkSampleCountFlagBits samples;
89    uint32_t cpp;
90    VkImageAspectFlags clear_mask;
91    uint32_t clear_views;
92    bool load;
93    bool store;
94    bool gmem;
95    int32_t gmem_offset[TU_GMEM_LAYOUT_COUNT];
96    bool will_be_resolved;
97    /* for D32S8 separate stencil: */
98    bool load_stencil;
99    bool store_stencil;
100 
101    bool cond_load_allowed;
102    bool cond_store_allowed;
103 
104    int32_t gmem_offset_stencil[TU_GMEM_LAYOUT_COUNT];
105 
106    /* The subpass id in which the attachment will be used first/last. */
107    uint32_t first_subpass_idx;
108    uint32_t last_subpass_idx;
109 };
110 
111 struct tu_render_pass
112 {
113    struct vk_object_base base;
114 
115    uint32_t attachment_count;
116    uint32_t subpass_count;
117    uint32_t gmem_pixels[TU_GMEM_LAYOUT_COUNT];
118    uint32_t tile_align_w;
119    uint32_t min_cpp;
120    uint64_t autotune_hash;
121 
122    /* memory bandwidth costs (in bytes) for gmem / sysmem rendering */
123    uint32_t gmem_bandwidth_per_pixel;
124    uint32_t sysmem_bandwidth_per_pixel;
125 
126    unsigned num_views;
127 
128    struct tu_subpass_attachment fragment_density_map;
129 
130    struct tu_subpass_attachment *subpass_attachments;
131 
132    struct tu_render_pass_attachment *attachments;
133    bool has_cond_load_store;
134    bool has_fdm;
135 
136    struct tu_subpass_barrier end_barrier;
137    struct tu_subpass subpasses[0];
138 };
139 
140 VK_DEFINE_NONDISP_HANDLE_CASTS(tu_render_pass, base, VkRenderPass,
141                                VK_OBJECT_TYPE_RENDER_PASS)
142 
143 void tu_setup_dynamic_render_pass(struct tu_cmd_buffer *cmd_buffer,
144                                   const VkRenderingInfo *pRenderingInfo);
145 
146 void tu_setup_dynamic_inheritance(struct tu_cmd_buffer *cmd_buffer,
147                                   const VkCommandBufferInheritanceRenderingInfo *info);
148 
149 uint32_t
150 tu_subpass_get_attachment_to_resolve(const struct tu_subpass *subpass, uint32_t index);
151 
152 #endif /* TU_PASS_H */
153