Debian Codegraph @

src/imagination/vulkan/pvr_hw_pass.h

raw
1 /*
2 * Copyright © 2022 Imagination Technologies Ltd.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #ifndef PVR_HW_PASS_H
25 #define PVR_HW_PASS_H
26
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <vulkan/vulkan.h>
30
31 #include "pvr_macros.h"
32
33 struct pvr_device;
34 struct pvr_render_pass;
35
36 #include "pvr_mrt.h"
37
38 enum pvr_resolve_type {
39 PVR_RESOLVE_TYPE_INVALID = 0, /* explicitly treat 0 as invalid. */
40 PVR_RESOLVE_TYPE_PBE,
41 PVR_RESOLVE_TYPE_TRANSFER,
42 };
43
44 enum pvr_renderpass_hwsetup_input_access {
45 /* The attachment must be loaded using a texture sample. */
46 PVR_RENDERPASS_HWSETUP_INPUT_ACCESS_OFFCHIP,
47 /* The attachment can be loaded from an output register or tile buffer. */
48 PVR_RENDERPASS_HWSETUP_INPUT_ACCESS_ONCHIP,
49 /* As _ONCHIP but the attachment is the result of a Z replicate in the same
50 * subpass.
51 */
52 PVR_RENDERPASS_HWSETUP_INPUT_ACCESS_ONCHIP_ZREPLICATE,
53 };
54
55 struct pvr_renderpass_hwsetup_eot_surface {
56 /* MRT index to store from. Also used to index into
57 * usc_mrt_setup::mrt_resources.
58 */
59 uint32_t mrt_idx;
60
61 /* Index of pvr_render_pass_info::attachments to store into. */
62 uint32_t attachment_idx;
63
64 /* True if the surface should be resolved. */
65 bool need_resolve;
66
67 /* How the surface should be resolved at the end of a render. Only valid if
68 * pvr_renderpass_hwsetup_eot_surface::need_resolve is set to true.
69 */
70 enum pvr_resolve_type resolve_type;
71
72 /* Index of pvr_render_pass_info::attachments to resolve from. Only valid if
73 * pvr_renderpass_hwsetup_eot_surface::need_resolve is set to true.
74 */
75 uint32_t src_attachment_idx;
76 };
77
78 struct pvr_renderpass_hwsetup_subpass {
79 /* Mapping from fragment stage pixel outputs to hardware storage for all
80 * fragment programs in the subpass.
81 */
82 struct usc_mrt_setup setup;
83
84 /* If >=0 then copy the depth into this pixel output for all fragment
85 * programs in the subpass.
86 */
87 int32_t z_replicate;
88
89 /* The operation to perform on the depth at the start of the subpass. Loads
90 * are deferred to subpasses when depth has been replicated.
91 */
92 VkAttachmentLoadOp depth_initop;
93
94 /* If true then clear the stencil at the start of the subpass. */
95 bool stencil_clear;
96
97 /* Subpass index from the input pvr_render_subpass structure. */
98 uint32_t index;
99
100 /* For each color attachment to the subpass the operation to perform at
101 * the start of the subpass.
102 */
103 VkAttachmentLoadOp *color_initops;
104
105 struct pvr_load_op *load_op;
106
107 struct {
108 enum pvr_renderpass_hwsetup_input_access type;
109 uint32_t on_chip_rt;
110 } *input_access;
111
112 uint8_t output_register_mask;
113 bool has_stencil_self_dep;
114 };
115
116 struct pvr_renderpass_colorinit {
117 /* Source attachment for the operation. */
118 uint32_t index;
119
120 /* Type of operation either clear or load. */
121 VkAttachmentLoadOp op;
122 };
123
124 struct pvr_renderpass_hwsetup_render {
125 /* Number of pixel output registers to allocate for this render. */
126 uint32_t output_regs_count;
127
128 /* Number of tile buffers to allocate for this render. */
129 uint32_t tile_buffers_count;
130
131 /* Number of subpasses in this render. */
132 uint32_t subpass_count;
133
134 /* Description of each subpass. */
135 struct pvr_renderpass_hwsetup_subpass *subpasses;
136
137 /* The sample count of every color attachment (or depth attachment if
138 * z-only) in this render.
139 */
140 uint32_t sample_count;
141
142 /* Index of the attachment to use for depth/stencil load/store in this
143 * render.
144 */
145 uint32_t ds_attach_idx;
146
147 /* Index of the attachment to use for depth/stencil resolve load/store in
148 * this render.
149 */
150 uint32_t ds_attach_resolve_idx;
151
152 /* Resolve mode to perform for this render originally set for each subpass.
153 */
154 VkResolveModeFlagBits stencil_resolve_mode;
155 VkResolveModeFlagBits depth_resolve_mode;
156
157 /* Operation on the on-chip depth at the start of the render.
158 * Either load from 'ds_attach_idx', clear using 'ds_attach_idx' or leave
159 * uninitialized.
160 */
161 VkAttachmentLoadOp depth_init;
162
163 /* Operation on the on-chip stencil at the start of the render. */
164 VkAttachmentLoadOp stencil_init;
165
166 /* Count of operations on on-chip color storage at the start of the render.
167 */
168 uint32_t color_init_count;
169
170 /* For each operation: the destination in the on-chip color storage. */
171 struct usc_mrt_setup init_setup;
172
173 /* How to initialize render targets at the start of the render. */
174 struct pvr_renderpass_colorinit *color_init;
175
176 /* true to store depth to 'ds_attach_idx' at the end of the render. */
177 bool depth_store;
178 /* true to store stencil to 'ds_attach_idx' at the end of the render. */
179 bool stencil_store;
180
181 /* Describes the location of the source data for each stored surface. */
182 struct usc_mrt_setup eot_setup;
183
184 struct pvr_renderpass_hwsetup_eot_surface *eot_surfaces;
185 uint32_t eot_surface_count;
186
187 uint32_t pbe_emits;
188
189 /* true if this HW render has lasting effects on its attachments. */
190 bool has_side_effects;
191
192 bool requires_frag_pr;
193
194 bool multiview_enabled;
195
196 /* View mask for multiview. */
197 uint32_t view_mask;
198
199 struct pvr_load_op_state *load_op_state;
200 };
201
202 struct pvr_renderpass_hw_map {
203 uint32_t render;
204 uint32_t subpass;
205 };
206
207 struct pvr_renderpass_hwsetup {
208 /* Number of renders. */
209 uint32_t render_count;
210
211 /* Description of each render. */
212 struct pvr_renderpass_hwsetup_render *renders;
213
214 /* Maps indices from pvr_render_pass::subpasses to the
215 * pvr_renderpass_hwsetup_render/pvr_renderpass_hwsetup_subpass relative to
216 * that render where the subpass is scheduled.
217 */
218 struct pvr_renderpass_hw_map *subpass_map;
219
220 bool *surface_allocate;
221 };
222
223 #ifdef PVR_PER_ARCH
224
225 VkResult PVR_PER_ARCH(create_renderpass_hwsetup)(
226 struct pvr_device *device,
227 const VkAllocationCallbacks *alloc,
228 struct pvr_render_pass *pass,
229 bool disable_merge,
230 struct pvr_renderpass_hwsetup **const hw_setup_out);
231
232 # define pvr_arch_create_renderpass_hwsetup \
233 PVR_PER_ARCH(create_renderpass_hwsetup)
234
235 void PVR_PER_ARCH(destroy_renderpass_hwsetup)(
236 const VkAllocationCallbacks *alloc,
237 struct pvr_renderpass_hwsetup *hw_setup);
238
239 # define pvr_arch_destroy_renderpass_hwsetup \
240 PVR_PER_ARCH(destroy_renderpass_hwsetup)
241
242 #endif
243
244 #endif /* PVR_HW_PASS_H */