• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2021 Raspberry Pi Ltd
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is 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
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 /* This file generates the per-v3d-version function prototypes.  It must only
25  * be included from v3dv_private.h.
26  */
27 
28 #ifndef V3DV_PRIVATE_H
29 #error This file is included by means other than v3dv_private.h
30 #endif
31 
32 /* Used at v3dv_cmd_buffer */
33 void
34 v3dX(job_emit_binning_flush)(struct v3dv_job *job);
35 
36 void
37 v3dX(cmd_buffer_emit_color_write_mask)(struct v3dv_cmd_buffer *cmd_buffer);
38 
39 void
40 v3dX(cmd_buffer_end_render_pass_secondary)(struct v3dv_cmd_buffer *cmd_buffer);
41 
42 void
43 v3dX(job_emit_clip_window)(struct v3dv_job *job, const VkRect2D *rect);
44 
45 void
46 v3dX(cmd_buffer_emit_render_pass_rcl)(struct v3dv_cmd_buffer *cmd_buffer);
47 
48 void
49 v3dX(cmd_buffer_emit_viewport)(struct v3dv_cmd_buffer *cmd_buffer);
50 
51 void
52 v3dX(cmd_buffer_emit_stencil)(struct v3dv_cmd_buffer *cmd_buffer);
53 
54 void
55 v3dX(cmd_buffer_emit_depth_bias)(struct v3dv_cmd_buffer *cmd_buffer);
56 
57 void
58 v3dX(cmd_buffer_emit_depth_bounds)(struct v3dv_cmd_buffer *cmd_buffer);
59 
60 void
61 v3dX(cmd_buffer_emit_line_width)(struct v3dv_cmd_buffer *cmd_buffer);
62 
63 void
64 v3dX(cmd_buffer_emit_sample_state)(struct v3dv_cmd_buffer *cmd_buffer);
65 
66 void
67 v3dX(cmd_buffer_emit_blend)(struct v3dv_cmd_buffer *cmd_buffer);
68 
69 void
70 v3dX(cmd_buffer_emit_varyings_state)(struct v3dv_cmd_buffer *cmd_buffer);
71 
72 void
73 v3dX(cmd_buffer_emit_configuration_bits)(struct v3dv_cmd_buffer *cmd_buffer);
74 
75 void
76 v3dX(job_emit_binning_prolog)(struct v3dv_job *job,
77                               const struct v3dv_frame_tiling *tiling,
78                               uint32_t layers);
79 
80 void
81 v3dX(job_emit_enable_double_buffer)(struct v3dv_job *job);
82 
83 void
84 v3dX(cmd_buffer_execute_inside_pass)(struct v3dv_cmd_buffer *primary,
85                                      uint32_t cmd_buffer_count,
86                                      const VkCommandBuffer *cmd_buffers);
87 
88 void
89 v3dX(cmd_buffer_emit_occlusion_query)(struct v3dv_cmd_buffer *cmd_buffer);
90 
91 void
92 v3dX(cmd_buffer_emit_gl_shader_state)(struct v3dv_cmd_buffer *cmd_buffer);
93 
94 
95 void
96 v3dX(cmd_buffer_emit_draw)(struct v3dv_cmd_buffer *cmd_buffer,
97                            struct v3dv_draw_info *info);
98 
99 
100 void
101 v3dX(cmd_buffer_emit_index_buffer)(struct v3dv_cmd_buffer *cmd_buffer);
102 
103 void
104 v3dX(cmd_buffer_emit_draw_indexed)(struct v3dv_cmd_buffer *cmd_buffer,
105                                    uint32_t indexCount,
106                                    uint32_t instanceCount,
107                                    uint32_t firstIndex,
108                                    int32_t vertexOffset,
109                                    uint32_t firstInstance);
110 
111 void
112 v3dX(cmd_buffer_emit_draw_indirect)(struct v3dv_cmd_buffer *cmd_buffer,
113                                     struct v3dv_buffer *buffer,
114                                     VkDeviceSize offset,
115                                     uint32_t drawCount,
116                                     uint32_t stride);
117 
118 void
119 v3dX(cmd_buffer_emit_indexed_indirect)(struct v3dv_cmd_buffer *cmd_buffer,
120                                        struct v3dv_buffer *buffer,
121                                        VkDeviceSize offset,
122                                        uint32_t drawCount,
123                                        uint32_t stride);
124 
125 void
126 v3dX(get_hw_clear_color)(const VkClearColorValue *color,
127                          uint32_t internal_type,
128                          uint32_t internal_size,
129                          uint32_t *hw_color);
130 
131 /* Used at v3dv_device */
132 
133 void
134 v3dX(pack_sampler_state)(const struct v3dv_device *device,
135                          struct v3dv_sampler *sampler,
136                          const VkSamplerCreateInfo *pCreateInfo,
137                          const VkSamplerCustomBorderColorCreateInfoEXT *bc_info);
138 
139 void
140 v3dX(framebuffer_compute_internal_bpp_msaa)(const struct v3dv_framebuffer *framebuffer,
141                                             const struct v3dv_cmd_buffer_attachment_state *attachments,
142                                             const struct v3dv_subpass *subpass,
143                                             uint8_t *max_internal_bpp,
144                                             uint8_t *total_color_bpp,
145                                             bool *msaa);
146 
147 #ifdef DEBUG
148 void
149 v3dX(device_check_prepacked_sizes)(void);
150 #endif
151 
152 /* Used at v3dv_format */
153 const struct v3dv_format *
154 v3dX(get_format)(VkFormat);
155 
156 void
157 v3dX(get_internal_type_bpp_for_output_format)(uint32_t format,
158                                               uint32_t *type,
159                                               uint32_t *bpp);
160 
161 bool
162 v3dX(format_supports_tlb_resolve)(const struct v3dv_format *format);
163 
164 bool
165 v3dX(format_supports_blending)(const struct v3dv_format *format);
166 
167 /* FIXME: tex_format should be `enum V3DX(Texture_Data_Formats)`, but using
168  * that enum type in the header requires including v3dx_pack.h, which triggers
169  * circular include dependencies issues, so we're using a `uint32_t` for now.
170  */
171 bool
172 v3dX(tfu_supports_tex_format)(uint32_t tex_format);
173 
174 /* Used at v3dv_image */
175 
176 void
177 v3dX(pack_texture_shader_state)(struct v3dv_device *device,
178                                 struct v3dv_image_view *iview);
179 
180 void
181 v3dX(pack_texture_shader_state_from_buffer_view)(struct v3dv_device *device,
182                                                  struct v3dv_buffer_view *buffer_view);
183 
184 /* Used at v3dv_meta_* */
185 
186 uint32_t
187 v3dX(zs_buffer_from_aspect_bits)(VkImageAspectFlags aspects);
188 
189 uint8_t
190 v3dX(get_internal_depth_type)(VkFormat format);
191 
192 struct v3dv_meta_framebuffer;
193 
194 void
195 v3dX(meta_emit_copy_image_to_buffer_rcl)(struct v3dv_job *job,
196                                          struct v3dv_buffer *buffer,
197                                          struct v3dv_image *image,
198                                          struct v3dv_meta_framebuffer *framebuffer,
199                                          const VkBufferImageCopy2 *region);
200 
201 void
202 v3dX(meta_emit_resolve_image_rcl)(struct v3dv_job *job,
203                                   struct v3dv_image *dst,
204                                   struct v3dv_image *src,
205                                   struct v3dv_meta_framebuffer *framebuffer,
206                                   const VkImageResolve2 *region);
207 
208 void
209 v3dX(meta_emit_copy_buffer)(struct v3dv_job *job,
210                             struct v3dv_bo *dst,
211                             struct v3dv_bo *src,
212                             uint32_t dst_offset,
213                             uint32_t src_offset,
214                             struct v3dv_meta_framebuffer *framebuffer,
215                             uint32_t format,
216                             uint32_t item_size);
217 
218 void
219 v3dX(meta_emit_copy_buffer_rcl)(struct v3dv_job *job,
220                                 struct v3dv_bo *dst,
221                                 struct v3dv_bo *src,
222                                 uint32_t dst_offset,
223                                 uint32_t src_offset,
224                                 struct v3dv_meta_framebuffer *framebuffer,
225                                 uint32_t format,
226                                 uint32_t item_size);
227 
228 void
229 v3dX(meta_emit_copy_image_rcl)(struct v3dv_job *job,
230                                struct v3dv_image *dst,
231                                struct v3dv_image *src,
232                                struct v3dv_meta_framebuffer *framebuffer,
233                                const VkImageCopy2 *region);
234 
235 void
236 v3dX(meta_emit_tfu_job)(struct v3dv_cmd_buffer *cmd_buffer,
237                         uint32_t dst_bo_handle,
238                         uint32_t dst_offset,
239                         enum v3d_tiling_mode dst_tiling,
240                         uint32_t dst_padded_height_or_stride,
241                         uint32_t dst_cpp,
242                         uint32_t src_bo_handle,
243                         uint32_t src_offset,
244                         enum v3d_tiling_mode src_tiling,
245                         uint32_t src_padded_height_or_stride,
246                         uint32_t src_cpp,
247                         uint32_t width,
248                         uint32_t height,
249                         const struct v3dv_format_plane *format_plane);
250 
251 void
252 v3dX(meta_emit_clear_image_rcl)(struct v3dv_job *job,
253                                 struct v3dv_image *image,
254                                 struct v3dv_meta_framebuffer *framebuffer,
255                                 const union v3dv_clear_value *clear_value,
256                                 VkImageAspectFlags aspects,
257                                 uint32_t min_layer,
258                                 uint32_t max_layer,
259                                 uint32_t level);
260 
261 void
262 v3dX(meta_emit_fill_buffer_rcl)(struct v3dv_job *job,
263                                 struct v3dv_bo *bo,
264                                 uint32_t offset,
265                                 struct v3dv_meta_framebuffer *framebuffer,
266                                 uint32_t data);
267 
268 void
269 v3dX(meta_emit_copy_buffer_to_image_rcl)(struct v3dv_job *job,
270                                          struct v3dv_image *image,
271                                          struct v3dv_buffer *buffer,
272                                          struct v3dv_meta_framebuffer *framebuffer,
273                                          const VkBufferImageCopy2 *region);
274 
275 void
276 v3dX(get_internal_type_bpp_for_image_aspects)(VkFormat vk_format,
277                                               VkImageAspectFlags aspect_mask,
278                                               uint32_t *internal_type,
279                                               uint32_t *internal_bpp);
280 
281 struct v3dv_job *
282 v3dX(meta_copy_buffer)(struct v3dv_cmd_buffer *cmd_buffer,
283                        struct v3dv_bo *dst,
284                        uint32_t dst_offset,
285                        struct v3dv_bo *src,
286                        uint32_t src_offset,
287                        const VkBufferCopy2 *region);
288 
289 void
290 v3dX(meta_fill_buffer)(struct v3dv_cmd_buffer *cmd_buffer,
291                        struct v3dv_bo *bo,
292                        uint32_t offset,
293                        uint32_t size,
294                        uint32_t data);
295 
296 void
297 v3dX(meta_framebuffer_init)(struct v3dv_meta_framebuffer *fb,
298                             VkFormat vk_format,
299                             uint32_t internal_type,
300                             const struct v3dv_frame_tiling *tiling);
301 
302 /* Used at v3dv_pipeline */
303 void
304 v3dX(pipeline_pack_state)(struct v3dv_pipeline *pipeline,
305                           const VkPipelineColorBlendStateCreateInfo *cb_info,
306                           const VkPipelineDepthStencilStateCreateInfo *ds_info,
307                           const VkPipelineRasterizationStateCreateInfo *rs_info,
308                           const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT *pv_info,
309                           const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info,
310                           const VkPipelineMultisampleStateCreateInfo *ms_info);
311 void
312 v3dX(pipeline_pack_compile_state)(struct v3dv_pipeline *pipeline,
313                                   const VkPipelineVertexInputStateCreateInfo *vi_info,
314                                   const VkPipelineVertexInputDivisorStateCreateInfoEXT *vd_info);
315 
316 bool
317 v3dX(pipeline_needs_default_attribute_values)(struct v3dv_pipeline *pipeline);
318 
319 struct v3dv_bo *
320 v3dX(create_default_attribute_values)(struct v3dv_device *device,
321                                       struct v3dv_pipeline *pipeline);
322 
323 /* Used at v3dv_queue */
324 void
325 v3dX(job_emit_noop)(struct v3dv_job *job);
326 
327 /* Used at v3dv_query */
328 VkResult
329 v3dX(enumerate_performance_query_counters)(uint32_t *pCounterCount,
330                                            VkPerformanceCounterKHR *pCounters,
331                                            VkPerformanceCounterDescriptionKHR *pCounterDescriptions);
332 
333 /* Used at v3dv_descriptor_set, and other descriptor set utils */
334 uint32_t v3dX(descriptor_bo_size)(VkDescriptorType type);
335 
336 uint32_t v3dX(max_descriptor_bo_size)(void);
337 
338 uint32_t v3dX(combined_image_sampler_texture_state_offset)(uint8_t plane);
339 
340 uint32_t v3dX(combined_image_sampler_sampler_state_offset)(uint8_t plane);
341 
342 /* General utils */
343 
344 uint32_t
345 v3dX(clamp_for_format_and_type)(uint32_t rt_type,
346                                 VkFormat vk_format);
347 
348 #define V3D42_CLIPPER_XY_GRANULARITY 256.0f
349 #define V3D71_CLIPPER_XY_GRANULARITY 64.0f
350 
351 uint32_t
352 v3dX(clamp_for_format_and_type)(uint32_t rt_type,
353                                 VkFormat vk_format);
354 
355 void
356 v3dX(viewport_compute_xform)(const VkViewport *viewport,
357                              float scale[3],
358                              float translate[3]);
359