radv: track memory heaps usage if overallocation is explicitly disallowed
[mesa.git] / src / amd / vulkan / radv_private.h
1 /*
2 * Copyright © 2016 Red Hat.
3 * Copyright © 2016 Bas Nieuwenhuizen
4 *
5 * based in part on anv driver which is:
6 * Copyright © 2015 Intel Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
26 */
27
28 #ifndef RADV_PRIVATE_H
29 #define RADV_PRIVATE_H
30
31 #include <stdlib.h>
32 #include <stdio.h>
33 #include <stdbool.h>
34 #include <pthread.h>
35 #include <assert.h>
36 #include <stdint.h>
37 #include <string.h>
38 #ifdef HAVE_VALGRIND
39 #include <valgrind.h>
40 #include <memcheck.h>
41 #define VG(x) x
42 #else
43 #define VG(x) ((void)0)
44 #endif
45
46 #include "c11/threads.h"
47 #include <amdgpu.h>
48 #include "compiler/shader_enums.h"
49 #include "util/macros.h"
50 #include "util/list.h"
51 #include "util/xmlconfig.h"
52 #include "vk_alloc.h"
53 #include "vk_debug_report.h"
54
55 #include "radv_radeon_winsys.h"
56 #include "ac_binary.h"
57 #include "ac_nir_to_llvm.h"
58 #include "ac_gpu_info.h"
59 #include "ac_surface.h"
60 #include "ac_llvm_build.h"
61 #include "ac_llvm_util.h"
62 #include "radv_constants.h"
63 #include "radv_descriptor_set.h"
64 #include "radv_extensions.h"
65 #include "sid.h"
66
67 /* Pre-declarations needed for WSI entrypoints */
68 struct wl_surface;
69 struct wl_display;
70 typedef struct xcb_connection_t xcb_connection_t;
71 typedef uint32_t xcb_visualid_t;
72 typedef uint32_t xcb_window_t;
73
74 #include <vulkan/vulkan.h>
75 #include <vulkan/vulkan_intel.h>
76 #include <vulkan/vulkan_android.h>
77 #include <vulkan/vk_icd.h>
78 #include <vulkan/vk_android_native_buffer.h>
79
80 #include "radv_entrypoints.h"
81
82 #include "wsi_common.h"
83 #include "wsi_common_display.h"
84
85 /* Helper to determine if we should compile
86 * any of the Android AHB support.
87 *
88 * To actually enable the ext we also need
89 * the necessary kernel support.
90 */
91 #if defined(ANDROID) && ANDROID_API_LEVEL >= 26
92 #define RADV_SUPPORT_ANDROID_HARDWARE_BUFFER 1
93 #else
94 #define RADV_SUPPORT_ANDROID_HARDWARE_BUFFER 0
95 #endif
96
97
98 struct gfx10_format {
99 unsigned img_format:9;
100
101 /* Various formats are only supported with workarounds for vertex fetch,
102 * and some 32_32_32 formats are supported natively, but only for buffers
103 * (possibly with some image support, actually, but no filtering). */
104 bool buffers_only:1;
105 };
106
107 #include "gfx10_format_table.h"
108
109 enum radv_secure_compile_type {
110 RADV_SC_TYPE_INIT_SUCCESS,
111 RADV_SC_TYPE_INIT_FAILURE,
112 RADV_SC_TYPE_COMPILE_PIPELINE,
113 RADV_SC_TYPE_COMPILE_PIPELINE_FINISHED,
114 RADV_SC_TYPE_READ_DISK_CACHE,
115 RADV_SC_TYPE_WRITE_DISK_CACHE,
116 RADV_SC_TYPE_FORK_DEVICE,
117 RADV_SC_TYPE_DESTROY_DEVICE,
118 RADV_SC_TYPE_COUNT
119 };
120
121 #define radv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
122
123 static inline uint32_t
124 align_u32(uint32_t v, uint32_t a)
125 {
126 assert(a != 0 && a == (a & -a));
127 return (v + a - 1) & ~(a - 1);
128 }
129
130 static inline uint32_t
131 align_u32_npot(uint32_t v, uint32_t a)
132 {
133 return (v + a - 1) / a * a;
134 }
135
136 static inline uint64_t
137 align_u64(uint64_t v, uint64_t a)
138 {
139 assert(a != 0 && a == (a & -a));
140 return (v + a - 1) & ~(a - 1);
141 }
142
143 static inline int32_t
144 align_i32(int32_t v, int32_t a)
145 {
146 assert(a != 0 && a == (a & -a));
147 return (v + a - 1) & ~(a - 1);
148 }
149
150 /** Alignment must be a power of 2. */
151 static inline bool
152 radv_is_aligned(uintmax_t n, uintmax_t a)
153 {
154 assert(a == (a & -a));
155 return (n & (a - 1)) == 0;
156 }
157
158 static inline uint32_t
159 round_up_u32(uint32_t v, uint32_t a)
160 {
161 return (v + a - 1) / a;
162 }
163
164 static inline uint64_t
165 round_up_u64(uint64_t v, uint64_t a)
166 {
167 return (v + a - 1) / a;
168 }
169
170 static inline uint32_t
171 radv_minify(uint32_t n, uint32_t levels)
172 {
173 if (unlikely(n == 0))
174 return 0;
175 else
176 return MAX2(n >> levels, 1);
177 }
178 static inline float
179 radv_clamp_f(float f, float min, float max)
180 {
181 assert(min < max);
182
183 if (f > max)
184 return max;
185 else if (f < min)
186 return min;
187 else
188 return f;
189 }
190
191 static inline bool
192 radv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask)
193 {
194 if (*inout_mask & clear_mask) {
195 *inout_mask &= ~clear_mask;
196 return true;
197 } else {
198 return false;
199 }
200 }
201
202 #define for_each_bit(b, dword) \
203 for (uint32_t __dword = (dword); \
204 (b) = __builtin_ffs(__dword) - 1, __dword; \
205 __dword &= ~(1 << (b)))
206
207 #define typed_memcpy(dest, src, count) ({ \
208 STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
209 memcpy((dest), (src), (count) * sizeof(*(src))); \
210 })
211
212 /* Whenever we generate an error, pass it through this function. Useful for
213 * debugging, where we can break on it. Only call at error site, not when
214 * propagating errors. Might be useful to plug in a stack trace here.
215 */
216
217 struct radv_image_view;
218 struct radv_instance;
219
220 VkResult __vk_errorf(struct radv_instance *instance, VkResult error, const char *file, int line, const char *format, ...);
221
222 #define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
223 #define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
224
225 void __radv_finishme(const char *file, int line, const char *format, ...)
226 radv_printflike(3, 4);
227 void radv_loge(const char *format, ...) radv_printflike(1, 2);
228 void radv_loge_v(const char *format, va_list va);
229 void radv_logi(const char *format, ...) radv_printflike(1, 2);
230 void radv_logi_v(const char *format, va_list va);
231
232 /**
233 * Print a FINISHME message, including its source location.
234 */
235 #define radv_finishme(format, ...) \
236 do { \
237 static bool reported = false; \
238 if (!reported) { \
239 __radv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); \
240 reported = true; \
241 } \
242 } while (0)
243
244 /* A non-fatal assert. Useful for debugging. */
245 #ifdef DEBUG
246 #define radv_assert(x) ({ \
247 if (unlikely(!(x))) \
248 fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \
249 })
250 #else
251 #define radv_assert(x) do {} while(0)
252 #endif
253
254 #define stub_return(v) \
255 do { \
256 radv_finishme("stub %s", __func__); \
257 return (v); \
258 } while (0)
259
260 #define stub() \
261 do { \
262 radv_finishme("stub %s", __func__); \
263 return; \
264 } while (0)
265
266 int radv_get_instance_entrypoint_index(const char *name);
267 int radv_get_device_entrypoint_index(const char *name);
268 int radv_get_physical_device_entrypoint_index(const char *name);
269
270 const char *radv_get_instance_entry_name(int index);
271 const char *radv_get_physical_device_entry_name(int index);
272 const char *radv_get_device_entry_name(int index);
273
274 bool radv_instance_entrypoint_is_enabled(int index, uint32_t core_version,
275 const struct radv_instance_extension_table *instance);
276 bool radv_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
277 const struct radv_instance_extension_table *instance);
278 bool radv_device_entrypoint_is_enabled(int index, uint32_t core_version,
279 const struct radv_instance_extension_table *instance,
280 const struct radv_device_extension_table *device);
281
282 void *radv_lookup_entrypoint(const char *name);
283
284 struct radv_physical_device {
285 VK_LOADER_DATA _loader_data;
286
287 struct radv_instance * instance;
288
289 struct radeon_winsys *ws;
290 struct radeon_info rad_info;
291 char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
292 uint8_t driver_uuid[VK_UUID_SIZE];
293 uint8_t device_uuid[VK_UUID_SIZE];
294 uint8_t cache_uuid[VK_UUID_SIZE];
295
296 int local_fd;
297 int master_fd;
298 struct wsi_device wsi_device;
299
300 bool out_of_order_rast_allowed;
301
302 /* Whether DCC should be enabled for MSAA textures. */
303 bool dcc_msaa_allowed;
304
305 /* Whether to enable the AMD_shader_ballot extension */
306 bool use_shader_ballot;
307
308 /* Whether to enable NGG. */
309 bool use_ngg;
310
311 /* Whether to enable NGG GS. */
312 bool use_ngg_gs;
313
314 /* Whether to enable NGG streamout. */
315 bool use_ngg_streamout;
316
317 /* Number of threads per wave. */
318 uint8_t ps_wave_size;
319 uint8_t cs_wave_size;
320 uint8_t ge_wave_size;
321
322 /* Whether to use the experimental compiler backend */
323 bool use_aco;
324
325 /* This is the drivers on-disk cache used as a fallback as opposed to
326 * the pipeline cache defined by apps.
327 */
328 struct disk_cache * disk_cache;
329
330 VkPhysicalDeviceMemoryProperties memory_properties;
331 enum radeon_bo_domain memory_domains[VK_MAX_MEMORY_TYPES];
332 enum radeon_bo_flag memory_flags[VK_MAX_MEMORY_TYPES];
333
334 drmPciBusInfo bus_info;
335
336 struct radv_device_extension_table supported_extensions;
337 };
338
339 struct radv_instance {
340 VK_LOADER_DATA _loader_data;
341
342 VkAllocationCallbacks alloc;
343
344 uint32_t apiVersion;
345 int physicalDeviceCount;
346 struct radv_physical_device physicalDevices[RADV_MAX_DRM_DEVICES];
347
348 char * engineName;
349 uint32_t engineVersion;
350
351 uint64_t debug_flags;
352 uint64_t perftest_flags;
353 uint8_t num_sc_threads;
354
355 struct vk_debug_report_instance debug_report_callbacks;
356
357 struct radv_instance_extension_table enabled_extensions;
358 struct radv_instance_dispatch_table dispatch;
359 struct radv_physical_device_dispatch_table physical_device_dispatch;
360 struct radv_device_dispatch_table device_dispatch;
361
362 struct driOptionCache dri_options;
363 struct driOptionCache available_dri_options;
364 };
365
366 static inline
367 bool radv_device_use_secure_compile(struct radv_instance *instance)
368 {
369 return instance->num_sc_threads;
370 }
371
372 VkResult radv_init_wsi(struct radv_physical_device *physical_device);
373 void radv_finish_wsi(struct radv_physical_device *physical_device);
374
375 bool radv_instance_extension_supported(const char *name);
376 uint32_t radv_physical_device_api_version(struct radv_physical_device *dev);
377 bool radv_physical_device_extension_supported(struct radv_physical_device *dev,
378 const char *name);
379
380 struct cache_entry;
381
382 struct radv_pipeline_cache {
383 struct radv_device * device;
384 pthread_mutex_t mutex;
385
386 uint32_t total_size;
387 uint32_t table_size;
388 uint32_t kernel_count;
389 struct cache_entry ** hash_table;
390 bool modified;
391
392 VkAllocationCallbacks alloc;
393 };
394
395 struct radv_pipeline_key {
396 uint32_t instance_rate_inputs;
397 uint32_t instance_rate_divisors[MAX_VERTEX_ATTRIBS];
398 uint8_t vertex_attribute_formats[MAX_VERTEX_ATTRIBS];
399 uint32_t vertex_attribute_bindings[MAX_VERTEX_ATTRIBS];
400 uint32_t vertex_attribute_offsets[MAX_VERTEX_ATTRIBS];
401 uint32_t vertex_attribute_strides[MAX_VERTEX_ATTRIBS];
402 uint64_t vertex_alpha_adjust;
403 uint32_t vertex_post_shuffle;
404 unsigned tess_input_vertices;
405 uint32_t col_format;
406 uint32_t is_int8;
407 uint32_t is_int10;
408 uint8_t log2_ps_iter_samples;
409 uint8_t num_samples;
410 uint32_t has_multiview_view_index : 1;
411 uint32_t optimisations_disabled : 1;
412 uint8_t topology;
413
414 /* Non-zero if a required subgroup size is specified via
415 * VK_EXT_subgroup_size_control.
416 */
417 uint8_t compute_subgroup_size;
418 };
419
420 struct radv_shader_binary;
421 struct radv_shader_variant;
422
423 void
424 radv_pipeline_cache_init(struct radv_pipeline_cache *cache,
425 struct radv_device *device);
426 void
427 radv_pipeline_cache_finish(struct radv_pipeline_cache *cache);
428 bool
429 radv_pipeline_cache_load(struct radv_pipeline_cache *cache,
430 const void *data, size_t size);
431
432 bool
433 radv_create_shader_variants_from_pipeline_cache(struct radv_device *device,
434 struct radv_pipeline_cache *cache,
435 const unsigned char *sha1,
436 struct radv_shader_variant **variants,
437 bool *found_in_application_cache);
438
439 void
440 radv_pipeline_cache_insert_shaders(struct radv_device *device,
441 struct radv_pipeline_cache *cache,
442 const unsigned char *sha1,
443 struct radv_shader_variant **variants,
444 struct radv_shader_binary *const *binaries);
445
446 enum radv_blit_ds_layout {
447 RADV_BLIT_DS_LAYOUT_TILE_ENABLE,
448 RADV_BLIT_DS_LAYOUT_TILE_DISABLE,
449 RADV_BLIT_DS_LAYOUT_COUNT,
450 };
451
452 static inline enum radv_blit_ds_layout radv_meta_blit_ds_to_type(VkImageLayout layout)
453 {
454 return (layout == VK_IMAGE_LAYOUT_GENERAL) ? RADV_BLIT_DS_LAYOUT_TILE_DISABLE : RADV_BLIT_DS_LAYOUT_TILE_ENABLE;
455 }
456
457 static inline VkImageLayout radv_meta_blit_ds_to_layout(enum radv_blit_ds_layout ds_layout)
458 {
459 return ds_layout == RADV_BLIT_DS_LAYOUT_TILE_ENABLE ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL;
460 }
461
462 enum radv_meta_dst_layout {
463 RADV_META_DST_LAYOUT_GENERAL,
464 RADV_META_DST_LAYOUT_OPTIMAL,
465 RADV_META_DST_LAYOUT_COUNT,
466 };
467
468 static inline enum radv_meta_dst_layout radv_meta_dst_layout_from_layout(VkImageLayout layout)
469 {
470 return (layout == VK_IMAGE_LAYOUT_GENERAL) ? RADV_META_DST_LAYOUT_GENERAL : RADV_META_DST_LAYOUT_OPTIMAL;
471 }
472
473 static inline VkImageLayout radv_meta_dst_layout_to_layout(enum radv_meta_dst_layout layout)
474 {
475 return layout == RADV_META_DST_LAYOUT_OPTIMAL ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL;
476 }
477
478 struct radv_meta_state {
479 VkAllocationCallbacks alloc;
480
481 struct radv_pipeline_cache cache;
482
483 /*
484 * For on-demand pipeline creation, makes sure that
485 * only one thread tries to build a pipeline at the same time.
486 */
487 mtx_t mtx;
488
489 /**
490 * Use array element `i` for images with `2^i` samples.
491 */
492 struct {
493 VkRenderPass render_pass[NUM_META_FS_KEYS];
494 VkPipeline color_pipelines[NUM_META_FS_KEYS];
495
496 VkRenderPass depthstencil_rp;
497 VkPipeline depth_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
498 VkPipeline stencil_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
499 VkPipeline depthstencil_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
500
501 VkPipeline depth_only_unrestricted_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
502 VkPipeline stencil_only_unrestricted_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
503 VkPipeline depthstencil_unrestricted_pipeline[NUM_DEPTH_CLEAR_PIPELINES];
504 } clear[MAX_SAMPLES_LOG2];
505
506 VkPipelineLayout clear_color_p_layout;
507 VkPipelineLayout clear_depth_p_layout;
508 VkPipelineLayout clear_depth_unrestricted_p_layout;
509
510 /* Optimized compute fast HTILE clear for stencil or depth only. */
511 VkPipeline clear_htile_mask_pipeline;
512 VkPipelineLayout clear_htile_mask_p_layout;
513 VkDescriptorSetLayout clear_htile_mask_ds_layout;
514
515 struct {
516 VkRenderPass render_pass[NUM_META_FS_KEYS][RADV_META_DST_LAYOUT_COUNT];
517
518 /** Pipeline that blits from a 1D image. */
519 VkPipeline pipeline_1d_src[NUM_META_FS_KEYS];
520
521 /** Pipeline that blits from a 2D image. */
522 VkPipeline pipeline_2d_src[NUM_META_FS_KEYS];
523
524 /** Pipeline that blits from a 3D image. */
525 VkPipeline pipeline_3d_src[NUM_META_FS_KEYS];
526
527 VkRenderPass depth_only_rp[RADV_BLIT_DS_LAYOUT_COUNT];
528 VkPipeline depth_only_1d_pipeline;
529 VkPipeline depth_only_2d_pipeline;
530 VkPipeline depth_only_3d_pipeline;
531
532 VkRenderPass stencil_only_rp[RADV_BLIT_DS_LAYOUT_COUNT];
533 VkPipeline stencil_only_1d_pipeline;
534 VkPipeline stencil_only_2d_pipeline;
535 VkPipeline stencil_only_3d_pipeline;
536 VkPipelineLayout pipeline_layout;
537 VkDescriptorSetLayout ds_layout;
538 } blit;
539
540 struct {
541 VkPipelineLayout p_layouts[5];
542 VkDescriptorSetLayout ds_layouts[5];
543 VkPipeline pipelines[5][NUM_META_FS_KEYS];
544
545 VkPipeline depth_only_pipeline[5];
546
547 VkPipeline stencil_only_pipeline[5];
548 } blit2d[MAX_SAMPLES_LOG2];
549
550 VkRenderPass blit2d_render_passes[NUM_META_FS_KEYS][RADV_META_DST_LAYOUT_COUNT];
551 VkRenderPass blit2d_depth_only_rp[RADV_BLIT_DS_LAYOUT_COUNT];
552 VkRenderPass blit2d_stencil_only_rp[RADV_BLIT_DS_LAYOUT_COUNT];
553
554 struct {
555 VkPipelineLayout img_p_layout;
556 VkDescriptorSetLayout img_ds_layout;
557 VkPipeline pipeline;
558 VkPipeline pipeline_3d;
559 } itob;
560 struct {
561 VkPipelineLayout img_p_layout;
562 VkDescriptorSetLayout img_ds_layout;
563 VkPipeline pipeline;
564 VkPipeline pipeline_3d;
565 } btoi;
566 struct {
567 VkPipelineLayout img_p_layout;
568 VkDescriptorSetLayout img_ds_layout;
569 VkPipeline pipeline;
570 } btoi_r32g32b32;
571 struct {
572 VkPipelineLayout img_p_layout;
573 VkDescriptorSetLayout img_ds_layout;
574 VkPipeline pipeline;
575 VkPipeline pipeline_3d;
576 } itoi;
577 struct {
578 VkPipelineLayout img_p_layout;
579 VkDescriptorSetLayout img_ds_layout;
580 VkPipeline pipeline;
581 } itoi_r32g32b32;
582 struct {
583 VkPipelineLayout img_p_layout;
584 VkDescriptorSetLayout img_ds_layout;
585 VkPipeline pipeline;
586 VkPipeline pipeline_3d;
587 } cleari;
588 struct {
589 VkPipelineLayout img_p_layout;
590 VkDescriptorSetLayout img_ds_layout;
591 VkPipeline pipeline;
592 } cleari_r32g32b32;
593
594 struct {
595 VkPipelineLayout p_layout;
596 VkPipeline pipeline[NUM_META_FS_KEYS];
597 VkRenderPass pass[NUM_META_FS_KEYS];
598 } resolve;
599
600 struct {
601 VkDescriptorSetLayout ds_layout;
602 VkPipelineLayout p_layout;
603 struct {
604 VkPipeline pipeline;
605 VkPipeline i_pipeline;
606 VkPipeline srgb_pipeline;
607 } rc[MAX_SAMPLES_LOG2];
608
609 VkPipeline depth_zero_pipeline;
610 struct {
611 VkPipeline average_pipeline;
612 VkPipeline max_pipeline;
613 VkPipeline min_pipeline;
614 } depth[MAX_SAMPLES_LOG2];
615
616 VkPipeline stencil_zero_pipeline;
617 struct {
618 VkPipeline max_pipeline;
619 VkPipeline min_pipeline;
620 } stencil[MAX_SAMPLES_LOG2];
621 } resolve_compute;
622
623 struct {
624 VkDescriptorSetLayout ds_layout;
625 VkPipelineLayout p_layout;
626
627 struct {
628 VkRenderPass render_pass[NUM_META_FS_KEYS][RADV_META_DST_LAYOUT_COUNT];
629 VkPipeline pipeline[NUM_META_FS_KEYS];
630 } rc[MAX_SAMPLES_LOG2];
631
632 VkRenderPass depth_render_pass;
633 VkPipeline depth_zero_pipeline;
634 struct {
635 VkPipeline average_pipeline;
636 VkPipeline max_pipeline;
637 VkPipeline min_pipeline;
638 } depth[MAX_SAMPLES_LOG2];
639
640 VkRenderPass stencil_render_pass;
641 VkPipeline stencil_zero_pipeline;
642 struct {
643 VkPipeline max_pipeline;
644 VkPipeline min_pipeline;
645 } stencil[MAX_SAMPLES_LOG2];
646 } resolve_fragment;
647
648 struct {
649 VkPipelineLayout p_layout;
650 VkPipeline decompress_pipeline[NUM_DEPTH_DECOMPRESS_PIPELINES];
651 VkPipeline resummarize_pipeline;
652 VkRenderPass pass;
653 } depth_decomp[MAX_SAMPLES_LOG2];
654
655 struct {
656 VkPipelineLayout p_layout;
657 VkPipeline cmask_eliminate_pipeline;
658 VkPipeline fmask_decompress_pipeline;
659 VkPipeline dcc_decompress_pipeline;
660 VkRenderPass pass;
661
662 VkDescriptorSetLayout dcc_decompress_compute_ds_layout;
663 VkPipelineLayout dcc_decompress_compute_p_layout;
664 VkPipeline dcc_decompress_compute_pipeline;
665 } fast_clear_flush;
666
667 struct {
668 VkPipelineLayout fill_p_layout;
669 VkPipelineLayout copy_p_layout;
670 VkDescriptorSetLayout fill_ds_layout;
671 VkDescriptorSetLayout copy_ds_layout;
672 VkPipeline fill_pipeline;
673 VkPipeline copy_pipeline;
674 } buffer;
675
676 struct {
677 VkDescriptorSetLayout ds_layout;
678 VkPipelineLayout p_layout;
679 VkPipeline occlusion_query_pipeline;
680 VkPipeline pipeline_statistics_query_pipeline;
681 VkPipeline tfb_query_pipeline;
682 VkPipeline timestamp_query_pipeline;
683 } query;
684
685 struct {
686 VkDescriptorSetLayout ds_layout;
687 VkPipelineLayout p_layout;
688 VkPipeline pipeline[MAX_SAMPLES_LOG2];
689 } fmask_expand;
690 };
691
692 /* queue types */
693 #define RADV_QUEUE_GENERAL 0
694 #define RADV_QUEUE_COMPUTE 1
695 #define RADV_QUEUE_TRANSFER 2
696
697 #define RADV_MAX_QUEUE_FAMILIES 3
698
699 enum ring_type radv_queue_family_to_ring(int f);
700
701 struct radv_queue {
702 VK_LOADER_DATA _loader_data;
703 struct radv_device * device;
704 struct radeon_winsys_ctx *hw_ctx;
705 enum radeon_ctx_priority priority;
706 uint32_t queue_family_index;
707 int queue_idx;
708 VkDeviceQueueCreateFlags flags;
709
710 uint32_t scratch_size_per_wave;
711 uint32_t scratch_waves;
712 uint32_t compute_scratch_size_per_wave;
713 uint32_t compute_scratch_waves;
714 uint32_t esgs_ring_size;
715 uint32_t gsvs_ring_size;
716 bool has_tess_rings;
717 bool has_gds;
718 bool has_gds_oa;
719 bool has_sample_positions;
720
721 struct radeon_winsys_bo *scratch_bo;
722 struct radeon_winsys_bo *descriptor_bo;
723 struct radeon_winsys_bo *compute_scratch_bo;
724 struct radeon_winsys_bo *esgs_ring_bo;
725 struct radeon_winsys_bo *gsvs_ring_bo;
726 struct radeon_winsys_bo *tess_rings_bo;
727 struct radeon_winsys_bo *gds_bo;
728 struct radeon_winsys_bo *gds_oa_bo;
729 struct radeon_cmdbuf *initial_preamble_cs;
730 struct radeon_cmdbuf *initial_full_flush_preamble_cs;
731 struct radeon_cmdbuf *continue_preamble_cs;
732
733 struct list_head pending_submissions;
734 pthread_mutex_t pending_mutex;
735 };
736
737 struct radv_bo_list {
738 struct radv_winsys_bo_list list;
739 unsigned capacity;
740 pthread_mutex_t mutex;
741 };
742
743 VkResult radv_bo_list_add(struct radv_device *device,
744 struct radeon_winsys_bo *bo);
745 void radv_bo_list_remove(struct radv_device *device,
746 struct radeon_winsys_bo *bo);
747
748 struct radv_secure_compile_process {
749 /* Secure process file descriptors. Used to communicate between the
750 * user facing device and the idle forked device used to fork a clean
751 * process for each new pipeline compile.
752 */
753 int fd_secure_input;
754 int fd_secure_output;
755
756 /* FIFO file descriptors used to communicate between the user facing
757 * device and the secure process that does the actual secure compile.
758 */
759 int fd_server;
760 int fd_client;
761
762 /* Secure compile process id */
763 pid_t sc_pid;
764
765 /* Is the secure compile process currently in use by a thread */
766 bool in_use;
767 };
768
769 struct radv_secure_compile_state {
770 struct radv_secure_compile_process *secure_compile_processes;
771 uint32_t secure_compile_thread_counter;
772 mtx_t secure_compile_mutex;
773
774 /* Unique process ID used to build name for FIFO file descriptor */
775 char *uid;
776 };
777
778 struct radv_device {
779 VK_LOADER_DATA _loader_data;
780
781 VkAllocationCallbacks alloc;
782
783 struct radv_instance * instance;
784 struct radeon_winsys *ws;
785
786 struct radv_meta_state meta_state;
787
788 struct radv_queue *queues[RADV_MAX_QUEUE_FAMILIES];
789 int queue_count[RADV_MAX_QUEUE_FAMILIES];
790 struct radeon_cmdbuf *empty_cs[RADV_MAX_QUEUE_FAMILIES];
791
792 bool always_use_syncobj;
793 bool pbb_allowed;
794 bool dfsm_allowed;
795 uint32_t tess_offchip_block_dw_size;
796 uint32_t scratch_waves;
797 uint32_t dispatch_initiator;
798
799 uint32_t gs_table_depth;
800
801 /* MSAA sample locations.
802 * The first index is the sample index.
803 * The second index is the coordinate: X, Y. */
804 float sample_locations_1x[1][2];
805 float sample_locations_2x[2][2];
806 float sample_locations_4x[4][2];
807 float sample_locations_8x[8][2];
808
809 /* GFX7 and later */
810 uint32_t gfx_init_size_dw;
811 struct radeon_winsys_bo *gfx_init;
812
813 struct radeon_winsys_bo *trace_bo;
814 uint32_t *trace_id_ptr;
815
816 /* Whether to keep shader debug info, for tracing or VK_AMD_shader_info */
817 bool keep_shader_info;
818
819 struct radv_physical_device *physical_device;
820
821 /* Backup in-memory cache to be used if the app doesn't provide one */
822 struct radv_pipeline_cache * mem_cache;
823
824 /*
825 * use different counters so MSAA MRTs get consecutive surface indices,
826 * even if MASK is allocated in between.
827 */
828 uint32_t image_mrt_offset_counter;
829 uint32_t fmask_mrt_offset_counter;
830 struct list_head shader_slabs;
831 mtx_t shader_slab_mutex;
832
833 /* For detecting VM faults reported by dmesg. */
834 uint64_t dmesg_timestamp;
835
836 struct radv_device_extension_table enabled_extensions;
837 struct radv_device_dispatch_table dispatch;
838
839 /* Whether the app has enabled the robustBufferAccess feature. */
840 bool robust_buffer_access;
841
842 /* Whether the driver uses a global BO list. */
843 bool use_global_bo_list;
844
845 struct radv_bo_list bo_list;
846
847 /* Whether anisotropy is forced with RADV_TEX_ANISO (-1 is disabled). */
848 int force_aniso;
849
850 struct radv_secure_compile_state *sc_state;
851
852 /* Condition variable for legacy timelines, to notify waiters when a
853 * new point gets submitted. */
854 pthread_cond_t timeline_cond;
855
856 /* Thread trace. */
857 struct radeon_cmdbuf *thread_trace_start_cs[2];
858 struct radeon_cmdbuf *thread_trace_stop_cs[2];
859 struct radeon_winsys_bo *thread_trace_bo;
860 void *thread_trace_ptr;
861 uint32_t thread_trace_buffer_size;
862 int thread_trace_start_frame;
863
864 /* Overallocation. */
865 bool overallocation_disallowed;
866 uint64_t allocated_memory_size[VK_MAX_MEMORY_HEAPS];
867 mtx_t overallocation_mutex;
868 };
869
870 struct radv_device_memory {
871 struct radeon_winsys_bo *bo;
872 /* for dedicated allocations */
873 struct radv_image *image;
874 struct radv_buffer *buffer;
875 uint32_t heap_index;
876 uint64_t alloc_size;
877 void * map;
878 void * user_ptr;
879
880 #if RADV_SUPPORT_ANDROID_HARDWARE_BUFFER
881 struct AHardwareBuffer * android_hardware_buffer;
882 #endif
883 };
884
885
886 struct radv_descriptor_range {
887 uint64_t va;
888 uint32_t size;
889 };
890
891 struct radv_descriptor_set {
892 const struct radv_descriptor_set_layout *layout;
893 uint32_t size;
894 uint32_t buffer_count;
895
896 struct radeon_winsys_bo *bo;
897 uint64_t va;
898 uint32_t *mapped_ptr;
899 struct radv_descriptor_range *dynamic_descriptors;
900
901 struct radeon_winsys_bo *descriptors[0];
902 };
903
904 struct radv_push_descriptor_set
905 {
906 struct radv_descriptor_set set;
907 uint32_t capacity;
908 };
909
910 struct radv_descriptor_pool_entry {
911 uint32_t offset;
912 uint32_t size;
913 struct radv_descriptor_set *set;
914 };
915
916 struct radv_descriptor_pool {
917 struct radeon_winsys_bo *bo;
918 uint8_t *mapped_ptr;
919 uint64_t current_offset;
920 uint64_t size;
921
922 uint8_t *host_memory_base;
923 uint8_t *host_memory_ptr;
924 uint8_t *host_memory_end;
925
926 uint32_t entry_count;
927 uint32_t max_entry_count;
928 struct radv_descriptor_pool_entry entries[0];
929 };
930
931 struct radv_descriptor_update_template_entry {
932 VkDescriptorType descriptor_type;
933
934 /* The number of descriptors to update */
935 uint32_t descriptor_count;
936
937 /* Into mapped_ptr or dynamic_descriptors, in units of the respective array */
938 uint32_t dst_offset;
939
940 /* In dwords. Not valid/used for dynamic descriptors */
941 uint32_t dst_stride;
942
943 uint32_t buffer_offset;
944
945 /* Only valid for combined image samplers and samplers */
946 uint8_t has_sampler;
947 uint8_t sampler_offset;
948
949 /* In bytes */
950 size_t src_offset;
951 size_t src_stride;
952
953 /* For push descriptors */
954 const uint32_t *immutable_samplers;
955 };
956
957 struct radv_descriptor_update_template {
958 uint32_t entry_count;
959 VkPipelineBindPoint bind_point;
960 struct radv_descriptor_update_template_entry entry[0];
961 };
962
963 struct radv_buffer {
964 VkDeviceSize size;
965
966 VkBufferUsageFlags usage;
967 VkBufferCreateFlags flags;
968
969 /* Set when bound */
970 struct radeon_winsys_bo * bo;
971 VkDeviceSize offset;
972
973 bool shareable;
974 };
975
976 enum radv_dynamic_state_bits {
977 RADV_DYNAMIC_VIEWPORT = 1 << 0,
978 RADV_DYNAMIC_SCISSOR = 1 << 1,
979 RADV_DYNAMIC_LINE_WIDTH = 1 << 2,
980 RADV_DYNAMIC_DEPTH_BIAS = 1 << 3,
981 RADV_DYNAMIC_BLEND_CONSTANTS = 1 << 4,
982 RADV_DYNAMIC_DEPTH_BOUNDS = 1 << 5,
983 RADV_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6,
984 RADV_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7,
985 RADV_DYNAMIC_STENCIL_REFERENCE = 1 << 8,
986 RADV_DYNAMIC_DISCARD_RECTANGLE = 1 << 9,
987 RADV_DYNAMIC_SAMPLE_LOCATIONS = 1 << 10,
988 RADV_DYNAMIC_LINE_STIPPLE = 1 << 11,
989 RADV_DYNAMIC_ALL = (1 << 12) - 1,
990 };
991
992 enum radv_cmd_dirty_bits {
993 /* Keep the dynamic state dirty bits in sync with
994 * enum radv_dynamic_state_bits */
995 RADV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0,
996 RADV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1,
997 RADV_CMD_DIRTY_DYNAMIC_LINE_WIDTH = 1 << 2,
998 RADV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS = 1 << 3,
999 RADV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS = 1 << 4,
1000 RADV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS = 1 << 5,
1001 RADV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6,
1002 RADV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7,
1003 RADV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE = 1 << 8,
1004 RADV_CMD_DIRTY_DYNAMIC_DISCARD_RECTANGLE = 1 << 9,
1005 RADV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS = 1 << 10,
1006 RADV_CMD_DIRTY_DYNAMIC_LINE_STIPPLE = 1 << 11,
1007 RADV_CMD_DIRTY_DYNAMIC_ALL = (1 << 12) - 1,
1008 RADV_CMD_DIRTY_PIPELINE = 1 << 12,
1009 RADV_CMD_DIRTY_INDEX_BUFFER = 1 << 13,
1010 RADV_CMD_DIRTY_FRAMEBUFFER = 1 << 14,
1011 RADV_CMD_DIRTY_VERTEX_BUFFER = 1 << 15,
1012 RADV_CMD_DIRTY_STREAMOUT_BUFFER = 1 << 16,
1013 };
1014
1015 enum radv_cmd_flush_bits {
1016 /* Instruction cache. */
1017 RADV_CMD_FLAG_INV_ICACHE = 1 << 0,
1018 /* Scalar L1 cache. */
1019 RADV_CMD_FLAG_INV_SCACHE = 1 << 1,
1020 /* Vector L1 cache. */
1021 RADV_CMD_FLAG_INV_VCACHE = 1 << 2,
1022 /* L2 cache + L2 metadata cache writeback & invalidate.
1023 * GFX6-8: Used by shaders only. GFX9-10: Used by everything. */
1024 RADV_CMD_FLAG_INV_L2 = 1 << 3,
1025 /* L2 writeback (write dirty L2 lines to memory for non-L2 clients).
1026 * Only used for coherency with non-L2 clients like CB, DB, CP on GFX6-8.
1027 * GFX6-7 will do complete invalidation, because the writeback is unsupported. */
1028 RADV_CMD_FLAG_WB_L2 = 1 << 4,
1029 /* Framebuffer caches */
1030 RADV_CMD_FLAG_FLUSH_AND_INV_CB_META = 1 << 5,
1031 RADV_CMD_FLAG_FLUSH_AND_INV_DB_META = 1 << 6,
1032 RADV_CMD_FLAG_FLUSH_AND_INV_DB = 1 << 7,
1033 RADV_CMD_FLAG_FLUSH_AND_INV_CB = 1 << 8,
1034 /* Engine synchronization. */
1035 RADV_CMD_FLAG_VS_PARTIAL_FLUSH = 1 << 9,
1036 RADV_CMD_FLAG_PS_PARTIAL_FLUSH = 1 << 10,
1037 RADV_CMD_FLAG_CS_PARTIAL_FLUSH = 1 << 11,
1038 RADV_CMD_FLAG_VGT_FLUSH = 1 << 12,
1039 /* Pipeline query controls. */
1040 RADV_CMD_FLAG_START_PIPELINE_STATS = 1 << 13,
1041 RADV_CMD_FLAG_STOP_PIPELINE_STATS = 1 << 14,
1042 RADV_CMD_FLAG_VGT_STREAMOUT_SYNC = 1 << 15,
1043
1044 RADV_CMD_FLUSH_AND_INV_FRAMEBUFFER = (RADV_CMD_FLAG_FLUSH_AND_INV_CB |
1045 RADV_CMD_FLAG_FLUSH_AND_INV_CB_META |
1046 RADV_CMD_FLAG_FLUSH_AND_INV_DB |
1047 RADV_CMD_FLAG_FLUSH_AND_INV_DB_META)
1048 };
1049
1050 struct radv_vertex_binding {
1051 struct radv_buffer * buffer;
1052 VkDeviceSize offset;
1053 };
1054
1055 struct radv_streamout_binding {
1056 struct radv_buffer *buffer;
1057 VkDeviceSize offset;
1058 VkDeviceSize size;
1059 };
1060
1061 struct radv_streamout_state {
1062 /* Mask of bound streamout buffers. */
1063 uint8_t enabled_mask;
1064
1065 /* External state that comes from the last vertex stage, it must be
1066 * set explicitely when binding a new graphics pipeline.
1067 */
1068 uint16_t stride_in_dw[MAX_SO_BUFFERS];
1069 uint32_t enabled_stream_buffers_mask; /* stream0 buffers0-3 in 4 LSB */
1070
1071 /* State of VGT_STRMOUT_BUFFER_(CONFIG|END) */
1072 uint32_t hw_enabled_mask;
1073
1074 /* State of VGT_STRMOUT_(CONFIG|EN) */
1075 bool streamout_enabled;
1076 };
1077
1078 struct radv_viewport_state {
1079 uint32_t count;
1080 VkViewport viewports[MAX_VIEWPORTS];
1081 };
1082
1083 struct radv_scissor_state {
1084 uint32_t count;
1085 VkRect2D scissors[MAX_SCISSORS];
1086 };
1087
1088 struct radv_discard_rectangle_state {
1089 uint32_t count;
1090 VkRect2D rectangles[MAX_DISCARD_RECTANGLES];
1091 };
1092
1093 struct radv_sample_locations_state {
1094 VkSampleCountFlagBits per_pixel;
1095 VkExtent2D grid_size;
1096 uint32_t count;
1097 VkSampleLocationEXT locations[MAX_SAMPLE_LOCATIONS];
1098 };
1099
1100 struct radv_dynamic_state {
1101 /**
1102 * Bitmask of (1 << VK_DYNAMIC_STATE_*).
1103 * Defines the set of saved dynamic state.
1104 */
1105 uint32_t mask;
1106
1107 struct radv_viewport_state viewport;
1108
1109 struct radv_scissor_state scissor;
1110
1111 float line_width;
1112
1113 struct {
1114 float bias;
1115 float clamp;
1116 float slope;
1117 } depth_bias;
1118
1119 float blend_constants[4];
1120
1121 struct {
1122 float min;
1123 float max;
1124 } depth_bounds;
1125
1126 struct {
1127 uint32_t front;
1128 uint32_t back;
1129 } stencil_compare_mask;
1130
1131 struct {
1132 uint32_t front;
1133 uint32_t back;
1134 } stencil_write_mask;
1135
1136 struct {
1137 uint32_t front;
1138 uint32_t back;
1139 } stencil_reference;
1140
1141 struct radv_discard_rectangle_state discard_rectangle;
1142
1143 struct radv_sample_locations_state sample_location;
1144
1145 struct {
1146 uint32_t factor;
1147 uint16_t pattern;
1148 } line_stipple;
1149 };
1150
1151 extern const struct radv_dynamic_state default_dynamic_state;
1152
1153 const char *
1154 radv_get_debug_option_name(int id);
1155
1156 const char *
1157 radv_get_perftest_option_name(int id);
1158
1159 struct radv_color_buffer_info {
1160 uint64_t cb_color_base;
1161 uint64_t cb_color_cmask;
1162 uint64_t cb_color_fmask;
1163 uint64_t cb_dcc_base;
1164 uint32_t cb_color_slice;
1165 uint32_t cb_color_view;
1166 uint32_t cb_color_info;
1167 uint32_t cb_color_attrib;
1168 uint32_t cb_color_attrib2; /* GFX9 and later */
1169 uint32_t cb_color_attrib3; /* GFX10 and later */
1170 uint32_t cb_dcc_control;
1171 uint32_t cb_color_cmask_slice;
1172 uint32_t cb_color_fmask_slice;
1173 union {
1174 uint32_t cb_color_pitch; // GFX6-GFX8
1175 uint32_t cb_mrt_epitch; // GFX9+
1176 };
1177 };
1178
1179 struct radv_ds_buffer_info {
1180 uint64_t db_z_read_base;
1181 uint64_t db_stencil_read_base;
1182 uint64_t db_z_write_base;
1183 uint64_t db_stencil_write_base;
1184 uint64_t db_htile_data_base;
1185 uint32_t db_depth_info;
1186 uint32_t db_z_info;
1187 uint32_t db_stencil_info;
1188 uint32_t db_depth_view;
1189 uint32_t db_depth_size;
1190 uint32_t db_depth_slice;
1191 uint32_t db_htile_surface;
1192 uint32_t pa_su_poly_offset_db_fmt_cntl;
1193 uint32_t db_z_info2; /* GFX9 only */
1194 uint32_t db_stencil_info2; /* GFX9 only */
1195 float offset_scale;
1196 };
1197
1198 void
1199 radv_initialise_color_surface(struct radv_device *device,
1200 struct radv_color_buffer_info *cb,
1201 struct radv_image_view *iview);
1202 void
1203 radv_initialise_ds_surface(struct radv_device *device,
1204 struct radv_ds_buffer_info *ds,
1205 struct radv_image_view *iview);
1206
1207 bool
1208 radv_sc_read(int fd, void *buf, size_t size, bool timeout);
1209
1210 /**
1211 * Attachment state when recording a renderpass instance.
1212 *
1213 * The clear value is valid only if there exists a pending clear.
1214 */
1215 struct radv_attachment_state {
1216 VkImageAspectFlags pending_clear_aspects;
1217 uint32_t cleared_views;
1218 VkClearValue clear_value;
1219 VkImageLayout current_layout;
1220 VkImageLayout current_stencil_layout;
1221 bool current_in_render_loop;
1222 struct radv_sample_locations_state sample_location;
1223
1224 union {
1225 struct radv_color_buffer_info cb;
1226 struct radv_ds_buffer_info ds;
1227 };
1228 struct radv_image_view *iview;
1229 };
1230
1231 struct radv_descriptor_state {
1232 struct radv_descriptor_set *sets[MAX_SETS];
1233 uint32_t dirty;
1234 uint32_t valid;
1235 struct radv_push_descriptor_set push_set;
1236 bool push_dirty;
1237 uint32_t dynamic_buffers[4 * MAX_DYNAMIC_BUFFERS];
1238 };
1239
1240 struct radv_subpass_sample_locs_state {
1241 uint32_t subpass_idx;
1242 struct radv_sample_locations_state sample_location;
1243 };
1244
1245 struct radv_cmd_state {
1246 /* Vertex descriptors */
1247 uint64_t vb_va;
1248 unsigned vb_size;
1249
1250 bool predicating;
1251 uint32_t dirty;
1252
1253 uint32_t prefetch_L2_mask;
1254
1255 struct radv_pipeline * pipeline;
1256 struct radv_pipeline * emitted_pipeline;
1257 struct radv_pipeline * compute_pipeline;
1258 struct radv_pipeline * emitted_compute_pipeline;
1259 struct radv_framebuffer * framebuffer;
1260 struct radv_render_pass * pass;
1261 const struct radv_subpass * subpass;
1262 struct radv_dynamic_state dynamic;
1263 struct radv_attachment_state * attachments;
1264 struct radv_streamout_state streamout;
1265 VkRect2D render_area;
1266
1267 uint32_t num_subpass_sample_locs;
1268 struct radv_subpass_sample_locs_state * subpass_sample_locs;
1269
1270 /* Index buffer */
1271 struct radv_buffer *index_buffer;
1272 uint64_t index_offset;
1273 uint32_t index_type;
1274 uint32_t max_index_count;
1275 uint64_t index_va;
1276 int32_t last_index_type;
1277
1278 int32_t last_primitive_reset_en;
1279 uint32_t last_primitive_reset_index;
1280 enum radv_cmd_flush_bits flush_bits;
1281 unsigned active_occlusion_queries;
1282 bool perfect_occlusion_queries_enabled;
1283 unsigned active_pipeline_queries;
1284 unsigned active_pipeline_gds_queries;
1285 float offset_scale;
1286 uint32_t trace_id;
1287 uint32_t last_ia_multi_vgt_param;
1288
1289 uint32_t last_num_instances;
1290 uint32_t last_first_instance;
1291 uint32_t last_vertex_offset;
1292
1293 uint32_t last_sx_ps_downconvert;
1294 uint32_t last_sx_blend_opt_epsilon;
1295 uint32_t last_sx_blend_opt_control;
1296
1297 /* Whether CP DMA is busy/idle. */
1298 bool dma_is_busy;
1299
1300 /* Conditional rendering info. */
1301 int predication_type; /* -1: disabled, 0: normal, 1: inverted */
1302 uint64_t predication_va;
1303
1304 /* Inheritance info. */
1305 VkQueryPipelineStatisticFlags inherited_pipeline_statistics;
1306
1307 bool context_roll_without_scissor_emitted;
1308
1309 /* SQTT related state. */
1310 uint32_t current_event_type;
1311 uint32_t num_events;
1312 uint32_t num_layout_transitions;
1313 };
1314
1315 struct radv_cmd_pool {
1316 VkAllocationCallbacks alloc;
1317 struct list_head cmd_buffers;
1318 struct list_head free_cmd_buffers;
1319 uint32_t queue_family_index;
1320 };
1321
1322 struct radv_cmd_buffer_upload {
1323 uint8_t *map;
1324 unsigned offset;
1325 uint64_t size;
1326 struct radeon_winsys_bo *upload_bo;
1327 struct list_head list;
1328 };
1329
1330 enum radv_cmd_buffer_status {
1331 RADV_CMD_BUFFER_STATUS_INVALID,
1332 RADV_CMD_BUFFER_STATUS_INITIAL,
1333 RADV_CMD_BUFFER_STATUS_RECORDING,
1334 RADV_CMD_BUFFER_STATUS_EXECUTABLE,
1335 RADV_CMD_BUFFER_STATUS_PENDING,
1336 };
1337
1338 struct radv_cmd_buffer {
1339 VK_LOADER_DATA _loader_data;
1340
1341 struct radv_device * device;
1342
1343 struct radv_cmd_pool * pool;
1344 struct list_head pool_link;
1345
1346 VkCommandBufferUsageFlags usage_flags;
1347 VkCommandBufferLevel level;
1348 enum radv_cmd_buffer_status status;
1349 struct radeon_cmdbuf *cs;
1350 struct radv_cmd_state state;
1351 struct radv_vertex_binding vertex_bindings[MAX_VBS];
1352 struct radv_streamout_binding streamout_bindings[MAX_SO_BUFFERS];
1353 uint32_t queue_family_index;
1354
1355 uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE];
1356 VkShaderStageFlags push_constant_stages;
1357 struct radv_descriptor_set meta_push_descriptors;
1358
1359 struct radv_descriptor_state descriptors[VK_PIPELINE_BIND_POINT_RANGE_SIZE];
1360
1361 struct radv_cmd_buffer_upload upload;
1362
1363 uint32_t scratch_size_per_wave_needed;
1364 uint32_t scratch_waves_wanted;
1365 uint32_t compute_scratch_size_per_wave_needed;
1366 uint32_t compute_scratch_waves_wanted;
1367 uint32_t esgs_ring_size_needed;
1368 uint32_t gsvs_ring_size_needed;
1369 bool tess_rings_needed;
1370 bool gds_needed; /* for GFX10 streamout and NGG GS queries */
1371 bool gds_oa_needed; /* for GFX10 streamout */
1372 bool sample_positions_needed;
1373
1374 VkResult record_result;
1375
1376 uint64_t gfx9_fence_va;
1377 uint32_t gfx9_fence_idx;
1378 uint64_t gfx9_eop_bug_va;
1379
1380 /**
1381 * Whether a query pool has been resetted and we have to flush caches.
1382 */
1383 bool pending_reset_query;
1384
1385 /**
1386 * Bitmask of pending active query flushes.
1387 */
1388 enum radv_cmd_flush_bits active_query_flush_bits;
1389 };
1390
1391 struct radv_image;
1392 struct radv_image_view;
1393
1394 bool radv_cmd_buffer_uses_mec(struct radv_cmd_buffer *cmd_buffer);
1395
1396 void si_emit_graphics(struct radv_device *device,
1397 struct radeon_cmdbuf *cs);
1398 void si_emit_compute(struct radv_physical_device *physical_device,
1399 struct radeon_cmdbuf *cs);
1400
1401 void cik_create_gfx_config(struct radv_device *device);
1402
1403 void si_write_viewport(struct radeon_cmdbuf *cs, int first_vp,
1404 int count, const VkViewport *viewports);
1405 void si_write_scissors(struct radeon_cmdbuf *cs, int first,
1406 int count, const VkRect2D *scissors,
1407 const VkViewport *viewports, bool can_use_guardband);
1408 uint32_t si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer,
1409 bool instanced_draw, bool indirect_draw,
1410 bool count_from_stream_output,
1411 uint32_t draw_vertex_count);
1412 void si_cs_emit_write_event_eop(struct radeon_cmdbuf *cs,
1413 enum chip_class chip_class,
1414 bool is_mec,
1415 unsigned event, unsigned event_flags,
1416 unsigned dst_sel, unsigned data_sel,
1417 uint64_t va,
1418 uint32_t new_fence,
1419 uint64_t gfx9_eop_bug_va);
1420
1421 void radv_cp_wait_mem(struct radeon_cmdbuf *cs, uint32_t op, uint64_t va,
1422 uint32_t ref, uint32_t mask);
1423 void si_cs_emit_cache_flush(struct radeon_cmdbuf *cs,
1424 enum chip_class chip_class,
1425 uint32_t *fence_ptr, uint64_t va,
1426 bool is_mec,
1427 enum radv_cmd_flush_bits flush_bits,
1428 uint64_t gfx9_eop_bug_va);
1429 void si_emit_cache_flush(struct radv_cmd_buffer *cmd_buffer);
1430 void si_emit_set_predication_state(struct radv_cmd_buffer *cmd_buffer,
1431 bool inverted, uint64_t va);
1432 void si_cp_dma_buffer_copy(struct radv_cmd_buffer *cmd_buffer,
1433 uint64_t src_va, uint64_t dest_va,
1434 uint64_t size);
1435 void si_cp_dma_prefetch(struct radv_cmd_buffer *cmd_buffer, uint64_t va,
1436 unsigned size);
1437 void si_cp_dma_clear_buffer(struct radv_cmd_buffer *cmd_buffer, uint64_t va,
1438 uint64_t size, unsigned value);
1439 void si_cp_dma_wait_for_idle(struct radv_cmd_buffer *cmd_buffer);
1440
1441 void radv_set_db_count_control(struct radv_cmd_buffer *cmd_buffer);
1442 bool
1443 radv_cmd_buffer_upload_alloc(struct radv_cmd_buffer *cmd_buffer,
1444 unsigned size,
1445 unsigned alignment,
1446 unsigned *out_offset,
1447 void **ptr);
1448 void
1449 radv_cmd_buffer_set_subpass(struct radv_cmd_buffer *cmd_buffer,
1450 const struct radv_subpass *subpass);
1451 bool
1452 radv_cmd_buffer_upload_data(struct radv_cmd_buffer *cmd_buffer,
1453 unsigned size, unsigned alignmnet,
1454 const void *data, unsigned *out_offset);
1455
1456 void radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer *cmd_buffer);
1457 void radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer);
1458 void radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer);
1459 void radv_depth_stencil_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer,
1460 VkImageAspectFlags aspects,
1461 VkResolveModeFlagBits resolve_mode);
1462 void radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer);
1463 void radv_depth_stencil_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer,
1464 VkImageAspectFlags aspects,
1465 VkResolveModeFlagBits resolve_mode);
1466 void radv_emit_default_sample_locations(struct radeon_cmdbuf *cs, int nr_samples);
1467 unsigned radv_get_default_max_sample_dist(int log_samples);
1468 void radv_device_init_msaa(struct radv_device *device);
1469
1470 void radv_update_ds_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
1471 const struct radv_image_view *iview,
1472 VkClearDepthStencilValue ds_clear_value,
1473 VkImageAspectFlags aspects);
1474
1475 void radv_update_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
1476 const struct radv_image_view *iview,
1477 int cb_idx,
1478 uint32_t color_values[2]);
1479
1480 void radv_update_fce_metadata(struct radv_cmd_buffer *cmd_buffer,
1481 struct radv_image *image,
1482 const VkImageSubresourceRange *range, bool value);
1483
1484 void radv_update_dcc_metadata(struct radv_cmd_buffer *cmd_buffer,
1485 struct radv_image *image,
1486 const VkImageSubresourceRange *range, bool value);
1487
1488 uint32_t radv_fill_buffer(struct radv_cmd_buffer *cmd_buffer,
1489 struct radeon_winsys_bo *bo,
1490 uint64_t offset, uint64_t size, uint32_t value);
1491 void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer *cmd_buffer);
1492 bool radv_get_memory_fd(struct radv_device *device,
1493 struct radv_device_memory *memory,
1494 int *pFD);
1495
1496 static inline void
1497 radv_emit_shader_pointer_head(struct radeon_cmdbuf *cs,
1498 unsigned sh_offset, unsigned pointer_count,
1499 bool use_32bit_pointers)
1500 {
1501 radeon_emit(cs, PKT3(PKT3_SET_SH_REG, pointer_count * (use_32bit_pointers ? 1 : 2), 0));
1502 radeon_emit(cs, (sh_offset - SI_SH_REG_OFFSET) >> 2);
1503 }
1504
1505 static inline void
1506 radv_emit_shader_pointer_body(struct radv_device *device,
1507 struct radeon_cmdbuf *cs,
1508 uint64_t va, bool use_32bit_pointers)
1509 {
1510 radeon_emit(cs, va);
1511
1512 if (use_32bit_pointers) {
1513 assert(va == 0 ||
1514 (va >> 32) == device->physical_device->rad_info.address32_hi);
1515 } else {
1516 radeon_emit(cs, va >> 32);
1517 }
1518 }
1519
1520 static inline void
1521 radv_emit_shader_pointer(struct radv_device *device,
1522 struct radeon_cmdbuf *cs,
1523 uint32_t sh_offset, uint64_t va, bool global)
1524 {
1525 bool use_32bit_pointers = !global;
1526
1527 radv_emit_shader_pointer_head(cs, sh_offset, 1, use_32bit_pointers);
1528 radv_emit_shader_pointer_body(device, cs, va, use_32bit_pointers);
1529 }
1530
1531 static inline struct radv_descriptor_state *
1532 radv_get_descriptors_state(struct radv_cmd_buffer *cmd_buffer,
1533 VkPipelineBindPoint bind_point)
1534 {
1535 assert(bind_point == VK_PIPELINE_BIND_POINT_GRAPHICS ||
1536 bind_point == VK_PIPELINE_BIND_POINT_COMPUTE);
1537 return &cmd_buffer->descriptors[bind_point];
1538 }
1539
1540 /*
1541 * Takes x,y,z as exact numbers of invocations, instead of blocks.
1542 *
1543 * Limitations: Can't call normal dispatch functions without binding or rebinding
1544 * the compute pipeline.
1545 */
1546 void radv_unaligned_dispatch(
1547 struct radv_cmd_buffer *cmd_buffer,
1548 uint32_t x,
1549 uint32_t y,
1550 uint32_t z);
1551
1552 struct radv_event {
1553 struct radeon_winsys_bo *bo;
1554 uint64_t *map;
1555 };
1556
1557 struct radv_shader_module;
1558
1559 #define RADV_HASH_SHADER_NO_NGG (1 << 0)
1560 #define RADV_HASH_SHADER_CS_WAVE32 (1 << 1)
1561 #define RADV_HASH_SHADER_PS_WAVE32 (1 << 2)
1562 #define RADV_HASH_SHADER_GE_WAVE32 (1 << 3)
1563 #define RADV_HASH_SHADER_ACO (1 << 4)
1564
1565 void
1566 radv_hash_shaders(unsigned char *hash,
1567 const VkPipelineShaderStageCreateInfo **stages,
1568 const struct radv_pipeline_layout *layout,
1569 const struct radv_pipeline_key *key,
1570 uint32_t flags);
1571
1572 static inline gl_shader_stage
1573 vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
1574 {
1575 assert(__builtin_popcount(vk_stage) == 1);
1576 return ffs(vk_stage) - 1;
1577 }
1578
1579 static inline VkShaderStageFlagBits
1580 mesa_to_vk_shader_stage(gl_shader_stage mesa_stage)
1581 {
1582 return (1 << mesa_stage);
1583 }
1584
1585 #define RADV_STAGE_MASK ((1 << MESA_SHADER_STAGES) - 1)
1586
1587 #define radv_foreach_stage(stage, stage_bits) \
1588 for (gl_shader_stage stage, \
1589 __tmp = (gl_shader_stage)((stage_bits) & RADV_STAGE_MASK); \
1590 stage = __builtin_ffs(__tmp) - 1, __tmp; \
1591 __tmp &= ~(1 << (stage)))
1592
1593 extern const VkFormat radv_fs_key_format_exemplars[NUM_META_FS_KEYS];
1594 unsigned radv_format_meta_fs_key(VkFormat format);
1595
1596 struct radv_multisample_state {
1597 uint32_t db_eqaa;
1598 uint32_t pa_sc_line_cntl;
1599 uint32_t pa_sc_mode_cntl_0;
1600 uint32_t pa_sc_mode_cntl_1;
1601 uint32_t pa_sc_aa_config;
1602 uint32_t pa_sc_aa_mask[2];
1603 unsigned num_samples;
1604 };
1605
1606 struct radv_prim_vertex_count {
1607 uint8_t min;
1608 uint8_t incr;
1609 };
1610
1611 struct radv_vertex_elements_info {
1612 uint32_t format_size[MAX_VERTEX_ATTRIBS];
1613 };
1614
1615 struct radv_ia_multi_vgt_param_helpers {
1616 uint32_t base;
1617 bool partial_es_wave;
1618 uint8_t primgroup_size;
1619 bool wd_switch_on_eop;
1620 bool ia_switch_on_eoi;
1621 bool partial_vs_wave;
1622 };
1623
1624 struct radv_binning_state {
1625 uint32_t pa_sc_binner_cntl_0;
1626 uint32_t db_dfsm_control;
1627 };
1628
1629 #define SI_GS_PER_ES 128
1630
1631 struct radv_pipeline {
1632 struct radv_device * device;
1633 struct radv_dynamic_state dynamic_state;
1634
1635 struct radv_pipeline_layout * layout;
1636
1637 bool need_indirect_descriptor_sets;
1638 struct radv_shader_variant * shaders[MESA_SHADER_STAGES];
1639 struct radv_shader_variant *gs_copy_shader;
1640 VkShaderStageFlags active_stages;
1641
1642 struct radeon_cmdbuf cs;
1643 uint32_t ctx_cs_hash;
1644 struct radeon_cmdbuf ctx_cs;
1645
1646 struct radv_vertex_elements_info vertex_elements;
1647
1648 uint32_t binding_stride[MAX_VBS];
1649 uint8_t num_vertex_bindings;
1650
1651 uint32_t user_data_0[MESA_SHADER_STAGES];
1652 union {
1653 struct {
1654 struct radv_multisample_state ms;
1655 struct radv_binning_state binning;
1656 uint32_t spi_baryc_cntl;
1657 bool prim_restart_enable;
1658 unsigned esgs_ring_size;
1659 unsigned gsvs_ring_size;
1660 uint32_t vtx_base_sgpr;
1661 struct radv_ia_multi_vgt_param_helpers ia_multi_vgt_param;
1662 uint8_t vtx_emit_num;
1663 struct radv_prim_vertex_count prim_vertex_count;
1664 bool can_use_guardband;
1665 uint32_t needed_dynamic_state;
1666 bool disable_out_of_order_rast_for_occlusion;
1667 uint8_t topology;
1668
1669 /* Used for rbplus */
1670 uint32_t col_format;
1671 uint32_t cb_target_mask;
1672 } graphics;
1673 };
1674
1675 unsigned max_waves;
1676 unsigned scratch_bytes_per_wave;
1677
1678 /* Not NULL if graphics pipeline uses streamout. */
1679 struct radv_shader_variant *streamout_shader;
1680 };
1681
1682 static inline bool radv_pipeline_has_gs(const struct radv_pipeline *pipeline)
1683 {
1684 return pipeline->shaders[MESA_SHADER_GEOMETRY] ? true : false;
1685 }
1686
1687 static inline bool radv_pipeline_has_tess(const struct radv_pipeline *pipeline)
1688 {
1689 return pipeline->shaders[MESA_SHADER_TESS_CTRL] ? true : false;
1690 }
1691
1692 bool radv_pipeline_has_ngg(const struct radv_pipeline *pipeline);
1693
1694 bool radv_pipeline_has_ngg_passthrough(const struct radv_pipeline *pipeline);
1695
1696 bool radv_pipeline_has_gs_copy_shader(const struct radv_pipeline *pipeline);
1697
1698 struct radv_userdata_info *radv_lookup_user_sgpr(struct radv_pipeline *pipeline,
1699 gl_shader_stage stage,
1700 int idx);
1701
1702 struct radv_shader_variant *radv_get_shader(struct radv_pipeline *pipeline,
1703 gl_shader_stage stage);
1704
1705 struct radv_graphics_pipeline_create_info {
1706 bool use_rectlist;
1707 bool db_depth_clear;
1708 bool db_stencil_clear;
1709 bool db_depth_disable_expclear;
1710 bool db_stencil_disable_expclear;
1711 bool depth_compress_disable;
1712 bool stencil_compress_disable;
1713 bool resummarize_enable;
1714 uint32_t custom_blend_mode;
1715 };
1716
1717 VkResult
1718 radv_graphics_pipeline_create(VkDevice device,
1719 VkPipelineCache cache,
1720 const VkGraphicsPipelineCreateInfo *pCreateInfo,
1721 const struct radv_graphics_pipeline_create_info *extra,
1722 const VkAllocationCallbacks *alloc,
1723 VkPipeline *pPipeline);
1724
1725 struct radv_binning_settings {
1726 unsigned context_states_per_bin; /* allowed range: [1, 6] */
1727 unsigned persistent_states_per_bin; /* allowed range: [1, 32] */
1728 unsigned fpovs_per_batch; /* allowed range: [0, 255], 0 = unlimited */
1729 };
1730
1731 struct radv_binning_settings
1732 radv_get_binning_settings(const struct radv_physical_device *pdev);
1733
1734 struct vk_format_description;
1735 uint32_t radv_translate_buffer_dataformat(const struct vk_format_description *desc,
1736 int first_non_void);
1737 uint32_t radv_translate_buffer_numformat(const struct vk_format_description *desc,
1738 int first_non_void);
1739 bool radv_is_buffer_format_supported(VkFormat format, bool *scaled);
1740 uint32_t radv_translate_colorformat(VkFormat format);
1741 uint32_t radv_translate_color_numformat(VkFormat format,
1742 const struct vk_format_description *desc,
1743 int first_non_void);
1744 uint32_t radv_colorformat_endian_swap(uint32_t colorformat);
1745 unsigned radv_translate_colorswap(VkFormat format, bool do_endian_swap);
1746 uint32_t radv_translate_dbformat(VkFormat format);
1747 uint32_t radv_translate_tex_dataformat(VkFormat format,
1748 const struct vk_format_description *desc,
1749 int first_non_void);
1750 uint32_t radv_translate_tex_numformat(VkFormat format,
1751 const struct vk_format_description *desc,
1752 int first_non_void);
1753 bool radv_format_pack_clear_color(VkFormat format,
1754 uint32_t clear_vals[2],
1755 VkClearColorValue *value);
1756 bool radv_is_colorbuffer_format_supported(VkFormat format, bool *blendable);
1757 bool radv_dcc_formats_compatible(VkFormat format1,
1758 VkFormat format2);
1759 bool radv_device_supports_etc(struct radv_physical_device *physical_device);
1760
1761 struct radv_image_plane {
1762 VkFormat format;
1763 struct radeon_surf surface;
1764 uint64_t offset;
1765 };
1766
1767 struct radv_image {
1768 VkImageType type;
1769 /* The original VkFormat provided by the client. This may not match any
1770 * of the actual surface formats.
1771 */
1772 VkFormat vk_format;
1773 VkImageAspectFlags aspects;
1774 VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
1775 struct ac_surf_info info;
1776 VkImageTiling tiling; /** VkImageCreateInfo::tiling */
1777 VkImageCreateFlags flags; /** VkImageCreateInfo::flags */
1778
1779 VkDeviceSize size;
1780 uint32_t alignment;
1781
1782 unsigned queue_family_mask;
1783 bool exclusive;
1784 bool shareable;
1785
1786 /* Set when bound */
1787 struct radeon_winsys_bo *bo;
1788 VkDeviceSize offset;
1789 uint64_t dcc_offset;
1790 uint64_t htile_offset;
1791 bool tc_compatible_htile;
1792 bool tc_compatible_cmask;
1793
1794 uint64_t cmask_offset;
1795 uint64_t fmask_offset;
1796 uint64_t clear_value_offset;
1797 uint64_t fce_pred_offset;
1798 uint64_t dcc_pred_offset;
1799
1800 /*
1801 * Metadata for the TC-compat zrange workaround. If the 32-bit value
1802 * stored at this offset is UINT_MAX, the driver will emit
1803 * DB_Z_INFO.ZRANGE_PRECISION=0, otherwise it will skip the
1804 * SET_CONTEXT_REG packet.
1805 */
1806 uint64_t tc_compat_zrange_offset;
1807
1808 /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */
1809 VkDeviceMemory owned_memory;
1810
1811 unsigned plane_count;
1812 struct radv_image_plane planes[0];
1813 };
1814
1815 /* Whether the image has a htile that is known consistent with the contents of
1816 * the image and is allowed to be in compressed form.
1817 *
1818 * If this is false reads that don't use the htile should be able to return
1819 * correct results.
1820 */
1821 bool radv_layout_is_htile_compressed(const struct radv_image *image,
1822 VkImageLayout layout,
1823 bool in_render_loop,
1824 unsigned queue_mask);
1825
1826 bool radv_layout_can_fast_clear(const struct radv_image *image,
1827 VkImageLayout layout,
1828 bool in_render_loop,
1829 unsigned queue_mask);
1830
1831 bool radv_layout_dcc_compressed(const struct radv_device *device,
1832 const struct radv_image *image,
1833 VkImageLayout layout,
1834 bool in_render_loop,
1835 unsigned queue_mask);
1836
1837 /**
1838 * Return whether the image has CMASK metadata for color surfaces.
1839 */
1840 static inline bool
1841 radv_image_has_cmask(const struct radv_image *image)
1842 {
1843 return image->cmask_offset;
1844 }
1845
1846 /**
1847 * Return whether the image has FMASK metadata for color surfaces.
1848 */
1849 static inline bool
1850 radv_image_has_fmask(const struct radv_image *image)
1851 {
1852 return image->fmask_offset;
1853 }
1854
1855 /**
1856 * Return whether the image has DCC metadata for color surfaces.
1857 */
1858 static inline bool
1859 radv_image_has_dcc(const struct radv_image *image)
1860 {
1861 return image->planes[0].surface.dcc_size;
1862 }
1863
1864 /**
1865 * Return whether the image is TC-compatible CMASK.
1866 */
1867 static inline bool
1868 radv_image_is_tc_compat_cmask(const struct radv_image *image)
1869 {
1870 return radv_image_has_fmask(image) && image->tc_compatible_cmask;
1871 }
1872
1873 /**
1874 * Return whether DCC metadata is enabled for a level.
1875 */
1876 static inline bool
1877 radv_dcc_enabled(const struct radv_image *image, unsigned level)
1878 {
1879 return radv_image_has_dcc(image) &&
1880 level < image->planes[0].surface.num_dcc_levels;
1881 }
1882
1883 /**
1884 * Return whether the image has CB metadata.
1885 */
1886 static inline bool
1887 radv_image_has_CB_metadata(const struct radv_image *image)
1888 {
1889 return radv_image_has_cmask(image) ||
1890 radv_image_has_fmask(image) ||
1891 radv_image_has_dcc(image);
1892 }
1893
1894 /**
1895 * Return whether the image has HTILE metadata for depth surfaces.
1896 */
1897 static inline bool
1898 radv_image_has_htile(const struct radv_image *image)
1899 {
1900 return image->planes[0].surface.htile_size;
1901 }
1902
1903 /**
1904 * Return whether HTILE metadata is enabled for a level.
1905 */
1906 static inline bool
1907 radv_htile_enabled(const struct radv_image *image, unsigned level)
1908 {
1909 return radv_image_has_htile(image) && level == 0;
1910 }
1911
1912 /**
1913 * Return whether the image is TC-compatible HTILE.
1914 */
1915 static inline bool
1916 radv_image_is_tc_compat_htile(const struct radv_image *image)
1917 {
1918 return radv_image_has_htile(image) && image->tc_compatible_htile;
1919 }
1920
1921 static inline uint64_t
1922 radv_image_get_fast_clear_va(const struct radv_image *image,
1923 uint32_t base_level)
1924 {
1925 uint64_t va = radv_buffer_get_va(image->bo);
1926 va += image->offset + image->clear_value_offset + base_level * 8;
1927 return va;
1928 }
1929
1930 static inline uint64_t
1931 radv_image_get_fce_pred_va(const struct radv_image *image,
1932 uint32_t base_level)
1933 {
1934 uint64_t va = radv_buffer_get_va(image->bo);
1935 va += image->offset + image->fce_pred_offset + base_level * 8;
1936 return va;
1937 }
1938
1939 static inline uint64_t
1940 radv_image_get_dcc_pred_va(const struct radv_image *image,
1941 uint32_t base_level)
1942 {
1943 uint64_t va = radv_buffer_get_va(image->bo);
1944 va += image->offset + image->dcc_pred_offset + base_level * 8;
1945 return va;
1946 }
1947
1948 static inline uint64_t
1949 radv_get_tc_compat_zrange_va(const struct radv_image *image,
1950 uint32_t base_level)
1951 {
1952 uint64_t va = radv_buffer_get_va(image->bo);
1953 va += image->offset + image->tc_compat_zrange_offset + base_level * 4;
1954 return va;
1955 }
1956
1957 static inline uint64_t
1958 radv_get_ds_clear_value_va(const struct radv_image *image,
1959 uint32_t base_level)
1960 {
1961 uint64_t va = radv_buffer_get_va(image->bo);
1962 va += image->offset + image->clear_value_offset + base_level * 8;
1963 return va;
1964 }
1965
1966 unsigned radv_image_queue_family_mask(const struct radv_image *image, uint32_t family, uint32_t queue_family);
1967
1968 static inline uint32_t
1969 radv_get_layerCount(const struct radv_image *image,
1970 const VkImageSubresourceRange *range)
1971 {
1972 return range->layerCount == VK_REMAINING_ARRAY_LAYERS ?
1973 image->info.array_size - range->baseArrayLayer : range->layerCount;
1974 }
1975
1976 static inline uint32_t
1977 radv_get_levelCount(const struct radv_image *image,
1978 const VkImageSubresourceRange *range)
1979 {
1980 return range->levelCount == VK_REMAINING_MIP_LEVELS ?
1981 image->info.levels - range->baseMipLevel : range->levelCount;
1982 }
1983
1984 struct radeon_bo_metadata;
1985 void
1986 radv_init_metadata(struct radv_device *device,
1987 struct radv_image *image,
1988 struct radeon_bo_metadata *metadata);
1989
1990 void
1991 radv_image_override_offset_stride(struct radv_device *device,
1992 struct radv_image *image,
1993 uint64_t offset, uint32_t stride);
1994
1995 union radv_descriptor {
1996 struct {
1997 uint32_t plane0_descriptor[8];
1998 uint32_t fmask_descriptor[8];
1999 };
2000 struct {
2001 uint32_t plane_descriptors[3][8];
2002 };
2003 };
2004
2005 struct radv_image_view {
2006 struct radv_image *image; /**< VkImageViewCreateInfo::image */
2007 struct radeon_winsys_bo *bo;
2008
2009 VkImageViewType type;
2010 VkImageAspectFlags aspect_mask;
2011 VkFormat vk_format;
2012 unsigned plane_id;
2013 bool multiple_planes;
2014 uint32_t base_layer;
2015 uint32_t layer_count;
2016 uint32_t base_mip;
2017 uint32_t level_count;
2018 VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
2019
2020 union radv_descriptor descriptor;
2021
2022 /* Descriptor for use as a storage image as opposed to a sampled image.
2023 * This has a few differences for cube maps (e.g. type).
2024 */
2025 union radv_descriptor storage_descriptor;
2026 };
2027
2028 struct radv_image_create_info {
2029 const VkImageCreateInfo *vk_info;
2030 bool scanout;
2031 bool no_metadata_planes;
2032 const struct radeon_bo_metadata *bo_metadata;
2033 };
2034
2035 VkResult
2036 radv_image_create_layout(struct radv_device *device,
2037 struct radv_image_create_info create_info,
2038 struct radv_image *image);
2039
2040 VkResult radv_image_create(VkDevice _device,
2041 const struct radv_image_create_info *info,
2042 const VkAllocationCallbacks* alloc,
2043 VkImage *pImage);
2044
2045 bool vi_alpha_is_on_msb(struct radv_device *device, VkFormat format);
2046
2047 VkResult
2048 radv_image_from_gralloc(VkDevice device_h,
2049 const VkImageCreateInfo *base_info,
2050 const VkNativeBufferANDROID *gralloc_info,
2051 const VkAllocationCallbacks *alloc,
2052 VkImage *out_image_h);
2053 uint64_t
2054 radv_ahb_usage_from_vk_usage(const VkImageCreateFlags vk_create,
2055 const VkImageUsageFlags vk_usage);
2056 VkResult
2057 radv_import_ahb_memory(struct radv_device *device,
2058 struct radv_device_memory *mem,
2059 unsigned priority,
2060 const VkImportAndroidHardwareBufferInfoANDROID *info);
2061 VkResult
2062 radv_create_ahb_memory(struct radv_device *device,
2063 struct radv_device_memory *mem,
2064 unsigned priority,
2065 const VkMemoryAllocateInfo *pAllocateInfo);
2066
2067 VkFormat
2068 radv_select_android_external_format(const void *next, VkFormat default_format);
2069
2070 bool radv_android_gralloc_supports_format(VkFormat format, VkImageUsageFlagBits usage);
2071
2072 struct radv_image_view_extra_create_info {
2073 bool disable_compression;
2074 };
2075
2076 void radv_image_view_init(struct radv_image_view *view,
2077 struct radv_device *device,
2078 const VkImageViewCreateInfo *pCreateInfo,
2079 const struct radv_image_view_extra_create_info* extra_create_info);
2080
2081 VkFormat radv_get_aspect_format(struct radv_image *image, VkImageAspectFlags mask);
2082
2083 struct radv_sampler_ycbcr_conversion {
2084 VkFormat format;
2085 VkSamplerYcbcrModelConversion ycbcr_model;
2086 VkSamplerYcbcrRange ycbcr_range;
2087 VkComponentMapping components;
2088 VkChromaLocation chroma_offsets[2];
2089 VkFilter chroma_filter;
2090 };
2091
2092 struct radv_buffer_view {
2093 struct radeon_winsys_bo *bo;
2094 VkFormat vk_format;
2095 uint64_t range; /**< VkBufferViewCreateInfo::range */
2096 uint32_t state[4];
2097 };
2098 void radv_buffer_view_init(struct radv_buffer_view *view,
2099 struct radv_device *device,
2100 const VkBufferViewCreateInfo* pCreateInfo);
2101
2102 static inline struct VkExtent3D
2103 radv_sanitize_image_extent(const VkImageType imageType,
2104 const struct VkExtent3D imageExtent)
2105 {
2106 switch (imageType) {
2107 case VK_IMAGE_TYPE_1D:
2108 return (VkExtent3D) { imageExtent.width, 1, 1 };
2109 case VK_IMAGE_TYPE_2D:
2110 return (VkExtent3D) { imageExtent.width, imageExtent.height, 1 };
2111 case VK_IMAGE_TYPE_3D:
2112 return imageExtent;
2113 default:
2114 unreachable("invalid image type");
2115 }
2116 }
2117
2118 static inline struct VkOffset3D
2119 radv_sanitize_image_offset(const VkImageType imageType,
2120 const struct VkOffset3D imageOffset)
2121 {
2122 switch (imageType) {
2123 case VK_IMAGE_TYPE_1D:
2124 return (VkOffset3D) { imageOffset.x, 0, 0 };
2125 case VK_IMAGE_TYPE_2D:
2126 return (VkOffset3D) { imageOffset.x, imageOffset.y, 0 };
2127 case VK_IMAGE_TYPE_3D:
2128 return imageOffset;
2129 default:
2130 unreachable("invalid image type");
2131 }
2132 }
2133
2134 static inline bool
2135 radv_image_extent_compare(const struct radv_image *image,
2136 const VkExtent3D *extent)
2137 {
2138 if (extent->width != image->info.width ||
2139 extent->height != image->info.height ||
2140 extent->depth != image->info.depth)
2141 return false;
2142 return true;
2143 }
2144
2145 struct radv_sampler {
2146 uint32_t state[4];
2147 struct radv_sampler_ycbcr_conversion *ycbcr_sampler;
2148 };
2149
2150 struct radv_framebuffer {
2151 uint32_t width;
2152 uint32_t height;
2153 uint32_t layers;
2154
2155 uint32_t attachment_count;
2156 struct radv_image_view *attachments[0];
2157 };
2158
2159 struct radv_subpass_barrier {
2160 VkPipelineStageFlags src_stage_mask;
2161 VkAccessFlags src_access_mask;
2162 VkAccessFlags dst_access_mask;
2163 };
2164
2165 void radv_subpass_barrier(struct radv_cmd_buffer *cmd_buffer,
2166 const struct radv_subpass_barrier *barrier);
2167
2168 struct radv_subpass_attachment {
2169 uint32_t attachment;
2170 VkImageLayout layout;
2171 VkImageLayout stencil_layout;
2172 bool in_render_loop;
2173 };
2174
2175 struct radv_subpass {
2176 uint32_t attachment_count;
2177 struct radv_subpass_attachment * attachments;
2178
2179 uint32_t input_count;
2180 uint32_t color_count;
2181 struct radv_subpass_attachment * input_attachments;
2182 struct radv_subpass_attachment * color_attachments;
2183 struct radv_subpass_attachment * resolve_attachments;
2184 struct radv_subpass_attachment * depth_stencil_attachment;
2185 struct radv_subpass_attachment * ds_resolve_attachment;
2186 VkResolveModeFlagBits depth_resolve_mode;
2187 VkResolveModeFlagBits stencil_resolve_mode;
2188
2189 /** Subpass has at least one color resolve attachment */
2190 bool has_color_resolve;
2191
2192 /** Subpass has at least one color attachment */
2193 bool has_color_att;
2194
2195 struct radv_subpass_barrier start_barrier;
2196
2197 uint32_t view_mask;
2198
2199 VkSampleCountFlagBits color_sample_count;
2200 VkSampleCountFlagBits depth_sample_count;
2201 VkSampleCountFlagBits max_sample_count;
2202 };
2203
2204 uint32_t
2205 radv_get_subpass_id(struct radv_cmd_buffer *cmd_buffer);
2206
2207 struct radv_render_pass_attachment {
2208 VkFormat format;
2209 uint32_t samples;
2210 VkAttachmentLoadOp load_op;
2211 VkAttachmentLoadOp stencil_load_op;
2212 VkImageLayout initial_layout;
2213 VkImageLayout final_layout;
2214 VkImageLayout stencil_initial_layout;
2215 VkImageLayout stencil_final_layout;
2216
2217 /* The subpass id in which the attachment will be used first/last. */
2218 uint32_t first_subpass_idx;
2219 uint32_t last_subpass_idx;
2220 };
2221
2222 struct radv_render_pass {
2223 uint32_t attachment_count;
2224 uint32_t subpass_count;
2225 struct radv_subpass_attachment * subpass_attachments;
2226 struct radv_render_pass_attachment * attachments;
2227 struct radv_subpass_barrier end_barrier;
2228 struct radv_subpass subpasses[0];
2229 };
2230
2231 VkResult radv_device_init_meta(struct radv_device *device);
2232 void radv_device_finish_meta(struct radv_device *device);
2233
2234 struct radv_query_pool {
2235 struct radeon_winsys_bo *bo;
2236 uint32_t stride;
2237 uint32_t availability_offset;
2238 uint64_t size;
2239 char *ptr;
2240 VkQueryType type;
2241 uint32_t pipeline_stats_mask;
2242 };
2243
2244 typedef enum {
2245 RADV_SEMAPHORE_NONE,
2246 RADV_SEMAPHORE_WINSYS,
2247 RADV_SEMAPHORE_SYNCOBJ,
2248 RADV_SEMAPHORE_TIMELINE,
2249 } radv_semaphore_kind;
2250
2251 struct radv_deferred_queue_submission;
2252
2253 struct radv_timeline_waiter {
2254 struct list_head list;
2255 struct radv_deferred_queue_submission *submission;
2256 uint64_t value;
2257 };
2258
2259 struct radv_timeline_point {
2260 struct list_head list;
2261
2262 uint64_t value;
2263 uint32_t syncobj;
2264
2265 /* Separate from the list to accomodate CPU wait being async, as well
2266 * as prevent point deletion during submission. */
2267 unsigned wait_count;
2268 };
2269
2270 struct radv_timeline {
2271 /* Using a pthread mutex to be compatible with condition variables. */
2272 pthread_mutex_t mutex;
2273
2274 uint64_t highest_signaled;
2275 uint64_t highest_submitted;
2276
2277 struct list_head points;
2278
2279 /* Keep free points on hand so we do not have to recreate syncobjs all
2280 * the time. */
2281 struct list_head free_points;
2282
2283 /* Submissions that are deferred waiting for a specific value to be
2284 * submitted. */
2285 struct list_head waiters;
2286 };
2287
2288 struct radv_semaphore_part {
2289 radv_semaphore_kind kind;
2290 union {
2291 uint32_t syncobj;
2292 struct radeon_winsys_sem *ws_sem;
2293 struct radv_timeline timeline;
2294 };
2295 };
2296
2297 struct radv_semaphore {
2298 struct radv_semaphore_part permanent;
2299 struct radv_semaphore_part temporary;
2300 };
2301
2302 bool radv_queue_internal_submit(struct radv_queue *queue,
2303 struct radeon_cmdbuf *cs);
2304
2305 void radv_set_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
2306 VkPipelineBindPoint bind_point,
2307 struct radv_descriptor_set *set,
2308 unsigned idx);
2309
2310 void
2311 radv_update_descriptor_sets(struct radv_device *device,
2312 struct radv_cmd_buffer *cmd_buffer,
2313 VkDescriptorSet overrideSet,
2314 uint32_t descriptorWriteCount,
2315 const VkWriteDescriptorSet *pDescriptorWrites,
2316 uint32_t descriptorCopyCount,
2317 const VkCopyDescriptorSet *pDescriptorCopies);
2318
2319 void
2320 radv_update_descriptor_set_with_template(struct radv_device *device,
2321 struct radv_cmd_buffer *cmd_buffer,
2322 struct radv_descriptor_set *set,
2323 VkDescriptorUpdateTemplate descriptorUpdateTemplate,
2324 const void *pData);
2325
2326 void radv_meta_push_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
2327 VkPipelineBindPoint pipelineBindPoint,
2328 VkPipelineLayout _layout,
2329 uint32_t set,
2330 uint32_t descriptorWriteCount,
2331 const VkWriteDescriptorSet *pDescriptorWrites);
2332
2333 void radv_initialize_dcc(struct radv_cmd_buffer *cmd_buffer,
2334 struct radv_image *image,
2335 const VkImageSubresourceRange *range, uint32_t value);
2336
2337 void radv_initialize_fmask(struct radv_cmd_buffer *cmd_buffer,
2338 struct radv_image *image,
2339 const VkImageSubresourceRange *range);
2340
2341 struct radv_fence {
2342 struct radeon_winsys_fence *fence;
2343 struct wsi_fence *fence_wsi;
2344
2345 uint32_t syncobj;
2346 uint32_t temp_syncobj;
2347 };
2348
2349 /* radv_nir_to_llvm.c */
2350 struct radv_shader_args;
2351
2352 void llvm_compile_shader(struct radv_device *device,
2353 unsigned shader_count,
2354 struct nir_shader *const *shaders,
2355 struct radv_shader_binary **binary,
2356 struct radv_shader_args *args);
2357
2358 unsigned radv_nir_get_max_workgroup_size(enum chip_class chip_class,
2359 gl_shader_stage stage,
2360 const struct nir_shader *nir);
2361
2362 /* radv_shader_info.h */
2363 struct radv_shader_info;
2364 struct radv_shader_variant_key;
2365
2366 void radv_nir_shader_info_pass(const struct nir_shader *nir,
2367 const struct radv_pipeline_layout *layout,
2368 const struct radv_shader_variant_key *key,
2369 struct radv_shader_info *info);
2370
2371 void radv_nir_shader_info_init(struct radv_shader_info *info);
2372
2373 /* radv_sqtt.c */
2374 struct radv_thread_trace_info {
2375 uint32_t cur_offset;
2376 uint32_t trace_status;
2377 union {
2378 uint32_t gfx9_write_counter;
2379 uint32_t gfx10_dropped_cntr;
2380 };
2381 };
2382
2383 struct radv_thread_trace_se {
2384 struct radv_thread_trace_info info;
2385 void *data_ptr;
2386 uint32_t shader_engine;
2387 uint32_t compute_unit;
2388 };
2389
2390 struct radv_thread_trace {
2391 uint32_t num_traces;
2392 struct radv_thread_trace_se traces[4];
2393 };
2394
2395 bool radv_thread_trace_init(struct radv_device *device);
2396 void radv_thread_trace_finish(struct radv_device *device);
2397 bool radv_begin_thread_trace(struct radv_queue *queue);
2398 bool radv_end_thread_trace(struct radv_queue *queue);
2399 bool radv_get_thread_trace(struct radv_queue *queue,
2400 struct radv_thread_trace *thread_trace);
2401 void radv_emit_thread_trace_userdata(struct radeon_cmdbuf *cs,
2402 const void *data, uint32_t num_dwords);
2403
2404 /* radv_rgp.c */
2405 int radv_dump_thread_trace(struct radv_device *device,
2406 const struct radv_thread_trace *trace);
2407
2408 /* radv_sqtt_layer_.c */
2409 struct radv_barrier_data {
2410 union {
2411 struct {
2412 uint16_t depth_stencil_expand : 1;
2413 uint16_t htile_hiz_range_expand : 1;
2414 uint16_t depth_stencil_resummarize : 1;
2415 uint16_t dcc_decompress : 1;
2416 uint16_t fmask_decompress : 1;
2417 uint16_t fast_clear_eliminate : 1;
2418 uint16_t fmask_color_expand : 1;
2419 uint16_t init_mask_ram : 1;
2420 uint16_t reserved : 8;
2421 };
2422 uint16_t all;
2423 } layout_transitions;
2424 };
2425
2426 /**
2427 * Value for the reason field of an RGP barrier start marker originating from
2428 * the Vulkan client (does not include PAL-defined values). (Table 15)
2429 */
2430 enum rgp_barrier_reason {
2431 RGP_BARRIER_UNKNOWN_REASON = 0xFFFFFFFF,
2432
2433 /* External app-generated barrier reasons, i.e. API synchronization
2434 * commands Range of valid values: [0x00000001 ... 0x7FFFFFFF].
2435 */
2436 RGP_BARRIER_EXTERNAL_CMD_PIPELINE_BARRIER = 0x00000001,
2437 RGP_BARRIER_EXTERNAL_RENDER_PASS_SYNC = 0x00000002,
2438 RGP_BARRIER_EXTERNAL_CMD_WAIT_EVENTS = 0x00000003,
2439
2440 /* Internal barrier reasons, i.e. implicit synchronization inserted by
2441 * the Vulkan driver Range of valid values: [0xC0000000 ... 0xFFFFFFFE].
2442 */
2443 RGP_BARRIER_INTERNAL_BASE = 0xC0000000,
2444 RGP_BARRIER_INTERNAL_PRE_RESET_QUERY_POOL_SYNC = RGP_BARRIER_INTERNAL_BASE + 0,
2445 RGP_BARRIER_INTERNAL_POST_RESET_QUERY_POOL_SYNC = RGP_BARRIER_INTERNAL_BASE + 1,
2446 RGP_BARRIER_INTERNAL_GPU_EVENT_RECYCLE_STALL = RGP_BARRIER_INTERNAL_BASE + 2,
2447 RGP_BARRIER_INTERNAL_PRE_COPY_QUERY_POOL_RESULTS_SYNC = RGP_BARRIER_INTERNAL_BASE + 3
2448 };
2449
2450 void radv_describe_begin_cmd_buffer(struct radv_cmd_buffer *cmd_buffer);
2451 void radv_describe_end_cmd_buffer(struct radv_cmd_buffer *cmd_buffer);
2452 void radv_describe_draw(struct radv_cmd_buffer *cmd_buffer);
2453 void radv_describe_dispatch(struct radv_cmd_buffer *cmd_buffer, int x, int y, int z);
2454 void radv_describe_begin_render_pass_clear(struct radv_cmd_buffer *cmd_buffer,
2455 VkImageAspectFlagBits aspects);
2456 void radv_describe_end_render_pass_clear(struct radv_cmd_buffer *cmd_buffer);
2457 void radv_describe_barrier_start(struct radv_cmd_buffer *cmd_buffer,
2458 enum rgp_barrier_reason reason);
2459 void radv_describe_barrier_end(struct radv_cmd_buffer *cmd_buffer);
2460 void radv_describe_layout_transition(struct radv_cmd_buffer *cmd_buffer,
2461 const struct radv_barrier_data *barrier);
2462
2463 struct radeon_winsys_sem;
2464
2465 uint64_t radv_get_current_time(void);
2466
2467 static inline uint32_t
2468 si_conv_gl_prim_to_vertices(unsigned gl_prim)
2469 {
2470 switch (gl_prim) {
2471 case 0: /* GL_POINTS */
2472 return 1;
2473 case 1: /* GL_LINES */
2474 case 3: /* GL_LINE_STRIP */
2475 return 2;
2476 case 4: /* GL_TRIANGLES */
2477 case 5: /* GL_TRIANGLE_STRIP */
2478 return 3;
2479 case 0xA: /* GL_LINE_STRIP_ADJACENCY_ARB */
2480 return 4;
2481 case 0xc: /* GL_TRIANGLES_ADJACENCY_ARB */
2482 return 6;
2483 case 7: /* GL_QUADS */
2484 return V_028A6C_OUTPRIM_TYPE_TRISTRIP;
2485 default:
2486 assert(0);
2487 return 0;
2488 }
2489 }
2490
2491 void radv_cmd_buffer_begin_render_pass(struct radv_cmd_buffer *cmd_buffer,
2492 const VkRenderPassBeginInfo *pRenderPassBegin);
2493 void radv_cmd_buffer_end_render_pass(struct radv_cmd_buffer *cmd_buffer);
2494
2495 #define RADV_DEFINE_HANDLE_CASTS(__radv_type, __VkType) \
2496 \
2497 static inline struct __radv_type * \
2498 __radv_type ## _from_handle(__VkType _handle) \
2499 { \
2500 return (struct __radv_type *) _handle; \
2501 } \
2502 \
2503 static inline __VkType \
2504 __radv_type ## _to_handle(struct __radv_type *_obj) \
2505 { \
2506 return (__VkType) _obj; \
2507 }
2508
2509 #define RADV_DEFINE_NONDISP_HANDLE_CASTS(__radv_type, __VkType) \
2510 \
2511 static inline struct __radv_type * \
2512 __radv_type ## _from_handle(__VkType _handle) \
2513 { \
2514 return (struct __radv_type *)(uintptr_t) _handle; \
2515 } \
2516 \
2517 static inline __VkType \
2518 __radv_type ## _to_handle(struct __radv_type *_obj) \
2519 { \
2520 return (__VkType)(uintptr_t) _obj; \
2521 }
2522
2523 #define RADV_FROM_HANDLE(__radv_type, __name, __handle) \
2524 struct __radv_type *__name = __radv_type ## _from_handle(__handle)
2525
2526 RADV_DEFINE_HANDLE_CASTS(radv_cmd_buffer, VkCommandBuffer)
2527 RADV_DEFINE_HANDLE_CASTS(radv_device, VkDevice)
2528 RADV_DEFINE_HANDLE_CASTS(radv_instance, VkInstance)
2529 RADV_DEFINE_HANDLE_CASTS(radv_physical_device, VkPhysicalDevice)
2530 RADV_DEFINE_HANDLE_CASTS(radv_queue, VkQueue)
2531
2532 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_cmd_pool, VkCommandPool)
2533 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer, VkBuffer)
2534 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer_view, VkBufferView)
2535 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_pool, VkDescriptorPool)
2536 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set, VkDescriptorSet)
2537 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set_layout, VkDescriptorSetLayout)
2538 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_update_template, VkDescriptorUpdateTemplate)
2539 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_device_memory, VkDeviceMemory)
2540 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_fence, VkFence)
2541 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_event, VkEvent)
2542 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_framebuffer, VkFramebuffer)
2543 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image, VkImage)
2544 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image_view, VkImageView);
2545 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_cache, VkPipelineCache)
2546 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline, VkPipeline)
2547 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_layout, VkPipelineLayout)
2548 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_query_pool, VkQueryPool)
2549 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_render_pass, VkRenderPass)
2550 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler, VkSampler)
2551 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler_ycbcr_conversion, VkSamplerYcbcrConversion)
2552 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_shader_module, VkShaderModule)
2553 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_semaphore, VkSemaphore)
2554
2555 #endif /* RADV_PRIVATE_H */