Debian Codegraph @

src/imagination/vulkan/pvr_job_render.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_JOB_RENDER_H
25 #define PVR_JOB_RENDER_H
26
27 #include <stdbool.h>
28 #include <stdint.h>
29 #include <vulkan/vulkan.h>
30
31 #include "hwdef/rogue_hw_defs.h"
32 #include "pvr_common.h"
33 #include "pvr_csb.h"
34 #include "pvr_limits.h"
35 #include "pvr_types.h"
36
37 struct pvr_device;
38 struct pvr_device_info;
39 struct pvr_render_ctx;
40 struct pvr_rt_dataset;
41 struct vk_sync;
42
43 /* Macrotile information. */
44 struct pvr_rt_mtile_info {
45 uint32_t tile_size_x;
46 uint32_t tile_size_y;
47
48 uint32_t num_tiles_x;
49 uint32_t num_tiles_y;
50
51 uint32_t tiles_per_mtile_x;
52 uint32_t tiles_per_mtile_y;
53
54 uint32_t x_tile_max;
55 uint32_t y_tile_max;
56
57 uint32_t mtiles_x;
58 uint32_t mtiles_y;
59
60 uint32_t mtile_x1;
61 uint32_t mtile_y1;
62 uint32_t mtile_x2;
63 uint32_t mtile_y2;
64 uint32_t mtile_x3;
65 uint32_t mtile_y3;
66 };
67
68 /* FIXME: Turn 'struct pvr_sub_cmd' into 'struct pvr_job' and change 'struct
69 * pvr_render_job' to subclass it? This is approximately what v3dv does
70 * (although it doesn't subclass).
71 */
72 struct pvr_render_job {
73 struct {
74 bool run_frag : 1;
75 bool geometry_terminate : 1;
76 bool frag_uses_atomic_ops : 1;
77 bool disable_compute_overlap : 1;
78 bool enable_bg_tag : 1;
79 bool process_empty_tiles : 1;
80 bool get_vis_results : 1;
81 bool has_depth_attachment : 1;
82 bool has_stencil_attachment : 1;
83 bool requires_spm_scratch_buffer : 1;
84 bool disable_pixel_merging : 1;
85 bool z_only_render : 1;
86 };
87
88 /* PDS pixel event for partial renders do not depend on the view index. */
89 uint32_t pr_pds_pixel_event_data_offset;
90
91 pvr_dev_addr_t ctrl_stream_addr;
92
93 pvr_dev_addr_t depth_bias_table_addr;
94 pvr_dev_addr_t scissor_table_addr;
95
96 /* Unless VK_KHR_dynamic_rendering or core 1.3 is supported, Vulkan does not
97 * allow for separate depth and stencil attachments. We don't bother storing
98 * separate parameters for them here (yet). If both has_depth_attachment and
99 * has_stencil_attachment are false, the contents are undefined.
100 */
101 struct pvr_ds_attachment {
102 struct {
103 bool d : 1;
104 bool s : 1;
105 } load, store;
106
107 pvr_dev_addr_t addr;
108 uint32_t stride;
109 uint32_t height;
110 VkExtent2D physical_extent;
111 uint32_t layer_size;
112 enum ROGUE_CR_ZLS_FORMAT_TYPE zls_format;
113 enum pvr_memlayout memlayout;
114
115 /* TODO: Is this really necessary? Maybe we can extract all useful
116 * information and drop this member. */
117 const struct pvr_image_view *iview;
118
119 bool has_alignment_transfers;
120 } ds;
121
122 VkClearDepthStencilValue ds_clear_value;
123
124 uint32_t samples;
125
126 uint32_t pixel_output_width;
127
128 uint8_t max_shared_registers;
129
130 /* Upper limit for tiles in flight, '0' means use default limit based
131 * on partition store.
132 */
133 uint32_t max_tiles_in_flight;
134
135 uint64_t pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS]
136 [ROGUE_NUM_PBESTATE_REG_WORDS];
137 uint64_t pr_pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS]
138 [ROGUE_NUM_PBESTATE_REG_WORDS];
139
140 struct pvr_view_state {
141 struct {
142 uint32_t pds_pixel_event_data_offset;
143 uint64_t pds_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS];
144 uint64_t pr_pds_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS];
145 } view[PVR_MAX_MULTIVIEW];
146
147 /* True if pds_pixel_event_data_offset should be taken from the first
148 * element of the view array. Otherwise view_index should be used.
149 */
150 bool force_pds_pixel_event_data_offset_zero : 1;
151
152 /* True if a partial render job uses the same EOT program data for a
153 * pixel event as the fragment job and not from the scratch buffer.
154 */
155 bool use_pds_pixel_event_data_offset : 1;
156
157 /* True if first_pds_bgnd_reg_values should be taken from the first
158 * element of the view array. Otherwise view_index should be used.
159 */
160 bool force_pds_bgnd_reg_values_zero : 1;
161
162 struct pvr_rt_dataset **rt_datasets;
163
164 uint32_t view_index;
165 } view_state;
166 };
167
168 #ifdef PVR_PER_ARCH
169
170 void PVR_PER_ARCH(rt_mtile_info_init)(const struct pvr_device_info *dev_info,
171 struct pvr_rt_mtile_info *info,
172 uint32_t width,
173 uint32_t height,
174 uint32_t samples);
175
176 # define pvr_arch_rt_mtile_info_init PVR_PER_ARCH(rt_mtile_info_init)
177
178 VkResult PVR_PER_ARCH(render_target_dataset_create)(
179 struct pvr_device *device,
180 uint32_t width,
181 uint32_t height,
182 uint32_t samples,
183 uint32_t layers,
184 struct pvr_rt_dataset **const rt_dataset_out);
185
186 # define pvr_arch_render_target_dataset_create \
187 PVR_PER_ARCH(render_target_dataset_create)
188
189 VkResult PVR_PER_ARCH(render_job_submit)(struct pvr_render_ctx *ctx,
190 struct pvr_render_job *job,
191 struct vk_sync *wait_geom,
192 struct vk_sync *wait_frag,
193 struct vk_sync *signal_sync_geom,
194 struct vk_sync *signal_sync_frag);
195
196 # define pvr_arch_render_job_submit PVR_PER_ARCH(render_job_submit)
197
198 #endif
199
200 #endif /* PVR_JOB_RENDER_H */