2 * Copyright © 2016 Red Hat.
3 * Copyright © 2016 Bas Nieuwenhuizen
5 * based in part on anv driver which is:
6 * Copyright © 2015 Intel Corporation
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:
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
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
28 #ifndef RADV_PRIVATE_H
29 #define RADV_PRIVATE_H
46 #include "c11/threads.h"
48 #include "compiler/shader_enums.h"
49 #include "util/macros.h"
50 #include "util/list.h"
51 #include "util/xmlconfig.h"
52 #include "main/macros.h"
54 #include "vk_debug_report.h"
56 #include "radv_radeon_winsys.h"
57 #include "ac_binary.h"
58 #include "ac_nir_to_llvm.h"
59 #include "ac_gpu_info.h"
60 #include "ac_surface.h"
61 #include "ac_llvm_build.h"
62 #include "ac_llvm_util.h"
63 #include "radv_descriptor_set.h"
64 #include "radv_extensions.h"
67 #include <llvm-c/TargetMachine.h>
69 /* Pre-declarations needed for WSI entrypoints */
72 typedef struct xcb_connection_t xcb_connection_t
;
73 typedef uint32_t xcb_visualid_t
;
74 typedef uint32_t xcb_window_t
;
76 #include <vulkan/vulkan.h>
77 #include <vulkan/vulkan_intel.h>
78 #include <vulkan/vk_icd.h>
79 #include <vulkan/vk_android_native_buffer.h>
81 #include "radv_entrypoints.h"
83 #include "wsi_common.h"
84 #include "wsi_common_display.h"
87 unsigned img_format
:9;
89 /* Various formats are only supported with workarounds for vertex fetch,
90 * and some 32_32_32 formats are supported natively, but only for buffers
91 * (possibly with some image support, actually, but no filtering). */
95 #include "gfx10_format_table.h"
97 #define ATI_VENDOR_ID 0x1002
100 #define MAX_VERTEX_ATTRIBS 32
102 #define MAX_VIEWPORTS 16
103 #define MAX_SCISSORS 16
104 #define MAX_DISCARD_RECTANGLES 4
105 #define MAX_SAMPLE_LOCATIONS 32
106 #define MAX_PUSH_CONSTANTS_SIZE 128
107 #define MAX_PUSH_DESCRIPTORS 32
108 #define MAX_DYNAMIC_UNIFORM_BUFFERS 16
109 #define MAX_DYNAMIC_STORAGE_BUFFERS 8
110 #define MAX_DYNAMIC_BUFFERS (MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
111 #define MAX_SAMPLES_LOG2 4
112 #define NUM_META_FS_KEYS 12
113 #define RADV_MAX_DRM_DEVICES 8
115 #define MAX_SO_STREAMS 4
116 #define MAX_SO_BUFFERS 4
117 #define MAX_SO_OUTPUTS 64
118 #define MAX_INLINE_UNIFORM_BLOCK_SIZE (4ull * 1024 * 1024)
119 #define MAX_INLINE_UNIFORM_BLOCK_COUNT 64
121 #define NUM_DEPTH_CLEAR_PIPELINES 3
124 * This is the point we switch from using CP to compute shader
125 * for certain buffer operations.
127 #define RADV_BUFFER_OPS_CS_THRESHOLD 4096
129 #define RADV_BUFFER_UPDATE_THRESHOLD 1024
133 RADV_MEM_HEAP_VRAM_CPU_ACCESS
,
140 RADV_MEM_TYPE_GTT_WRITE_COMBINE
,
141 RADV_MEM_TYPE_VRAM_CPU_ACCESS
,
142 RADV_MEM_TYPE_GTT_CACHED
,
146 #define radv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
148 static inline uint32_t
149 align_u32(uint32_t v
, uint32_t a
)
151 assert(a
!= 0 && a
== (a
& -a
));
152 return (v
+ a
- 1) & ~(a
- 1);
155 static inline uint32_t
156 align_u32_npot(uint32_t v
, uint32_t a
)
158 return (v
+ a
- 1) / a
* a
;
161 static inline uint64_t
162 align_u64(uint64_t v
, uint64_t a
)
164 assert(a
!= 0 && a
== (a
& -a
));
165 return (v
+ a
- 1) & ~(a
- 1);
168 static inline int32_t
169 align_i32(int32_t v
, int32_t a
)
171 assert(a
!= 0 && a
== (a
& -a
));
172 return (v
+ a
- 1) & ~(a
- 1);
175 /** Alignment must be a power of 2. */
177 radv_is_aligned(uintmax_t n
, uintmax_t a
)
179 assert(a
== (a
& -a
));
180 return (n
& (a
- 1)) == 0;
183 static inline uint32_t
184 round_up_u32(uint32_t v
, uint32_t a
)
186 return (v
+ a
- 1) / a
;
189 static inline uint64_t
190 round_up_u64(uint64_t v
, uint64_t a
)
192 return (v
+ a
- 1) / a
;
195 static inline uint32_t
196 radv_minify(uint32_t n
, uint32_t levels
)
198 if (unlikely(n
== 0))
201 return MAX2(n
>> levels
, 1);
204 radv_clamp_f(float f
, float min
, float max
)
217 radv_clear_mask(uint32_t *inout_mask
, uint32_t clear_mask
)
219 if (*inout_mask
& clear_mask
) {
220 *inout_mask
&= ~clear_mask
;
227 #define for_each_bit(b, dword) \
228 for (uint32_t __dword = (dword); \
229 (b) = __builtin_ffs(__dword) - 1, __dword; \
230 __dword &= ~(1 << (b)))
232 #define typed_memcpy(dest, src, count) ({ \
233 STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
234 memcpy((dest), (src), (count) * sizeof(*(src))); \
237 /* Whenever we generate an error, pass it through this function. Useful for
238 * debugging, where we can break on it. Only call at error site, not when
239 * propagating errors. Might be useful to plug in a stack trace here.
242 struct radv_instance
;
244 VkResult
__vk_errorf(struct radv_instance
*instance
, VkResult error
, const char *file
, int line
, const char *format
, ...);
246 #define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
247 #define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
249 void __radv_finishme(const char *file
, int line
, const char *format
, ...)
250 radv_printflike(3, 4);
251 void radv_loge(const char *format
, ...) radv_printflike(1, 2);
252 void radv_loge_v(const char *format
, va_list va
);
253 void radv_logi(const char *format
, ...) radv_printflike(1, 2);
254 void radv_logi_v(const char *format
, va_list va
);
257 * Print a FINISHME message, including its source location.
259 #define radv_finishme(format, ...) \
261 static bool reported = false; \
263 __radv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); \
268 /* A non-fatal assert. Useful for debugging. */
270 #define radv_assert(x) ({ \
271 if (unlikely(!(x))) \
272 fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \
275 #define radv_assert(x)
278 #define stub_return(v) \
280 radv_finishme("stub %s", __func__); \
286 radv_finishme("stub %s", __func__); \
290 void *radv_lookup_entrypoint_unchecked(const char *name
);
291 void *radv_lookup_entrypoint_checked(const char *name
,
292 uint32_t core_version
,
293 const struct radv_instance_extension_table
*instance
,
294 const struct radv_device_extension_table
*device
);
295 void *radv_lookup_physical_device_entrypoint_checked(const char *name
,
296 uint32_t core_version
,
297 const struct radv_instance_extension_table
*instance
);
299 struct radv_physical_device
{
300 VK_LOADER_DATA _loader_data
;
302 struct radv_instance
* instance
;
304 struct radeon_winsys
*ws
;
305 struct radeon_info rad_info
;
306 char name
[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE
];
307 uint8_t driver_uuid
[VK_UUID_SIZE
];
308 uint8_t device_uuid
[VK_UUID_SIZE
];
309 uint8_t cache_uuid
[VK_UUID_SIZE
];
313 struct wsi_device wsi_device
;
315 bool has_rbplus
; /* if RB+ register exist */
316 bool rbplus_allowed
; /* if RB+ is allowed */
317 bool has_clear_state
;
318 bool cpdma_prefetch_writes_memory
;
319 bool has_scissor_bug
;
321 bool has_out_of_order_rast
;
322 bool out_of_order_rast_allowed
;
324 /* Whether DCC should be enabled for MSAA textures. */
325 bool dcc_msaa_allowed
;
327 /* Whether LOAD_CONTEXT_REG packets are supported. */
328 bool has_load_ctx_reg_pkt
;
330 /* Whether to enable the AMD_shader_ballot extension */
331 bool use_shader_ballot
;
333 /* Whether DISABLE_CONSTANT_ENCODE_REG is supported. */
334 bool has_dcc_constant_encode
;
336 /* This is the drivers on-disk cache used as a fallback as opposed to
337 * the pipeline cache defined by apps.
339 struct disk_cache
* disk_cache
;
341 VkPhysicalDeviceMemoryProperties memory_properties
;
342 enum radv_mem_type mem_type_indices
[RADV_MEM_TYPE_COUNT
];
344 drmPciBusInfo bus_info
;
346 struct radv_device_extension_table supported_extensions
;
349 struct radv_instance
{
350 VK_LOADER_DATA _loader_data
;
352 VkAllocationCallbacks alloc
;
355 int physicalDeviceCount
;
356 struct radv_physical_device physicalDevices
[RADV_MAX_DRM_DEVICES
];
358 uint64_t debug_flags
;
359 uint64_t perftest_flags
;
361 struct vk_debug_report_instance debug_report_callbacks
;
363 struct radv_instance_extension_table enabled_extensions
;
365 struct driOptionCache dri_options
;
366 struct driOptionCache available_dri_options
;
369 VkResult
radv_init_wsi(struct radv_physical_device
*physical_device
);
370 void radv_finish_wsi(struct radv_physical_device
*physical_device
);
372 bool radv_instance_extension_supported(const char *name
);
373 uint32_t radv_physical_device_api_version(struct radv_physical_device
*dev
);
374 bool radv_physical_device_extension_supported(struct radv_physical_device
*dev
,
379 struct radv_pipeline_cache
{
380 struct radv_device
* device
;
381 pthread_mutex_t mutex
;
385 uint32_t kernel_count
;
386 struct cache_entry
** hash_table
;
389 VkAllocationCallbacks alloc
;
392 struct radv_pipeline_key
{
393 uint32_t instance_rate_inputs
;
394 uint32_t instance_rate_divisors
[MAX_VERTEX_ATTRIBS
];
395 uint8_t vertex_attribute_formats
[MAX_VERTEX_ATTRIBS
];
396 uint32_t vertex_attribute_bindings
[MAX_VERTEX_ATTRIBS
];
397 uint32_t vertex_attribute_offsets
[MAX_VERTEX_ATTRIBS
];
398 uint32_t vertex_attribute_strides
[MAX_VERTEX_ATTRIBS
];
399 uint64_t vertex_alpha_adjust
;
400 uint32_t vertex_post_shuffle
;
401 unsigned tess_input_vertices
;
405 uint8_t log2_ps_iter_samples
;
407 uint32_t has_multiview_view_index
: 1;
408 uint32_t optimisations_disabled
: 1;
411 struct radv_shader_binary
;
412 struct radv_shader_variant
;
415 radv_pipeline_cache_init(struct radv_pipeline_cache
*cache
,
416 struct radv_device
*device
);
418 radv_pipeline_cache_finish(struct radv_pipeline_cache
*cache
);
420 radv_pipeline_cache_load(struct radv_pipeline_cache
*cache
,
421 const void *data
, size_t size
);
424 radv_create_shader_variants_from_pipeline_cache(struct radv_device
*device
,
425 struct radv_pipeline_cache
*cache
,
426 const unsigned char *sha1
,
427 struct radv_shader_variant
**variants
,
428 bool *found_in_application_cache
);
431 radv_pipeline_cache_insert_shaders(struct radv_device
*device
,
432 struct radv_pipeline_cache
*cache
,
433 const unsigned char *sha1
,
434 struct radv_shader_variant
**variants
,
435 struct radv_shader_binary
*const *binaries
);
437 enum radv_blit_ds_layout
{
438 RADV_BLIT_DS_LAYOUT_TILE_ENABLE
,
439 RADV_BLIT_DS_LAYOUT_TILE_DISABLE
,
440 RADV_BLIT_DS_LAYOUT_COUNT
,
443 static inline enum radv_blit_ds_layout
radv_meta_blit_ds_to_type(VkImageLayout layout
)
445 return (layout
== VK_IMAGE_LAYOUT_GENERAL
) ? RADV_BLIT_DS_LAYOUT_TILE_DISABLE
: RADV_BLIT_DS_LAYOUT_TILE_ENABLE
;
448 static inline VkImageLayout
radv_meta_blit_ds_to_layout(enum radv_blit_ds_layout ds_layout
)
450 return ds_layout
== RADV_BLIT_DS_LAYOUT_TILE_ENABLE
? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
: VK_IMAGE_LAYOUT_GENERAL
;
453 enum radv_meta_dst_layout
{
454 RADV_META_DST_LAYOUT_GENERAL
,
455 RADV_META_DST_LAYOUT_OPTIMAL
,
456 RADV_META_DST_LAYOUT_COUNT
,
459 static inline enum radv_meta_dst_layout
radv_meta_dst_layout_from_layout(VkImageLayout layout
)
461 return (layout
== VK_IMAGE_LAYOUT_GENERAL
) ? RADV_META_DST_LAYOUT_GENERAL
: RADV_META_DST_LAYOUT_OPTIMAL
;
464 static inline VkImageLayout
radv_meta_dst_layout_to_layout(enum radv_meta_dst_layout layout
)
466 return layout
== RADV_META_DST_LAYOUT_OPTIMAL
? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
: VK_IMAGE_LAYOUT_GENERAL
;
469 struct radv_meta_state
{
470 VkAllocationCallbacks alloc
;
472 struct radv_pipeline_cache cache
;
475 * For on-demand pipeline creation, makes sure that
476 * only one thread tries to build a pipeline at the same time.
481 * Use array element `i` for images with `2^i` samples.
484 VkRenderPass render_pass
[NUM_META_FS_KEYS
];
485 VkPipeline color_pipelines
[NUM_META_FS_KEYS
];
487 VkRenderPass depthstencil_rp
;
488 VkPipeline depth_only_pipeline
[NUM_DEPTH_CLEAR_PIPELINES
];
489 VkPipeline stencil_only_pipeline
[NUM_DEPTH_CLEAR_PIPELINES
];
490 VkPipeline depthstencil_pipeline
[NUM_DEPTH_CLEAR_PIPELINES
];
491 } clear
[1 + MAX_SAMPLES_LOG2
];
493 VkPipelineLayout clear_color_p_layout
;
494 VkPipelineLayout clear_depth_p_layout
;
496 /* Optimized compute fast HTILE clear for stencil or depth only. */
497 VkPipeline clear_htile_mask_pipeline
;
498 VkPipelineLayout clear_htile_mask_p_layout
;
499 VkDescriptorSetLayout clear_htile_mask_ds_layout
;
502 VkRenderPass render_pass
[NUM_META_FS_KEYS
][RADV_META_DST_LAYOUT_COUNT
];
504 /** Pipeline that blits from a 1D image. */
505 VkPipeline pipeline_1d_src
[NUM_META_FS_KEYS
];
507 /** Pipeline that blits from a 2D image. */
508 VkPipeline pipeline_2d_src
[NUM_META_FS_KEYS
];
510 /** Pipeline that blits from a 3D image. */
511 VkPipeline pipeline_3d_src
[NUM_META_FS_KEYS
];
513 VkRenderPass depth_only_rp
[RADV_BLIT_DS_LAYOUT_COUNT
];
514 VkPipeline depth_only_1d_pipeline
;
515 VkPipeline depth_only_2d_pipeline
;
516 VkPipeline depth_only_3d_pipeline
;
518 VkRenderPass stencil_only_rp
[RADV_BLIT_DS_LAYOUT_COUNT
];
519 VkPipeline stencil_only_1d_pipeline
;
520 VkPipeline stencil_only_2d_pipeline
;
521 VkPipeline stencil_only_3d_pipeline
;
522 VkPipelineLayout pipeline_layout
;
523 VkDescriptorSetLayout ds_layout
;
527 VkPipelineLayout p_layouts
[5];
528 VkDescriptorSetLayout ds_layouts
[5];
529 VkPipeline pipelines
[5][NUM_META_FS_KEYS
];
531 VkPipeline depth_only_pipeline
[5];
533 VkPipeline stencil_only_pipeline
[5];
534 } blit2d
[1 + MAX_SAMPLES_LOG2
];
536 VkRenderPass blit2d_render_passes
[NUM_META_FS_KEYS
][RADV_META_DST_LAYOUT_COUNT
];
537 VkRenderPass blit2d_depth_only_rp
[RADV_BLIT_DS_LAYOUT_COUNT
];
538 VkRenderPass blit2d_stencil_only_rp
[RADV_BLIT_DS_LAYOUT_COUNT
];
541 VkPipelineLayout img_p_layout
;
542 VkDescriptorSetLayout img_ds_layout
;
544 VkPipeline pipeline_3d
;
547 VkPipelineLayout img_p_layout
;
548 VkDescriptorSetLayout img_ds_layout
;
550 VkPipeline pipeline_3d
;
553 VkPipelineLayout img_p_layout
;
554 VkDescriptorSetLayout img_ds_layout
;
558 VkPipelineLayout img_p_layout
;
559 VkDescriptorSetLayout img_ds_layout
;
561 VkPipeline pipeline_3d
;
564 VkPipelineLayout img_p_layout
;
565 VkDescriptorSetLayout img_ds_layout
;
569 VkPipelineLayout img_p_layout
;
570 VkDescriptorSetLayout img_ds_layout
;
572 VkPipeline pipeline_3d
;
575 VkPipelineLayout img_p_layout
;
576 VkDescriptorSetLayout img_ds_layout
;
581 VkPipelineLayout p_layout
;
582 VkPipeline pipeline
[NUM_META_FS_KEYS
];
583 VkRenderPass pass
[NUM_META_FS_KEYS
];
587 VkDescriptorSetLayout ds_layout
;
588 VkPipelineLayout p_layout
;
591 VkPipeline i_pipeline
;
592 VkPipeline srgb_pipeline
;
593 } rc
[MAX_SAMPLES_LOG2
];
595 VkPipeline depth_zero_pipeline
;
597 VkPipeline average_pipeline
;
598 VkPipeline max_pipeline
;
599 VkPipeline min_pipeline
;
600 } depth
[MAX_SAMPLES_LOG2
];
602 VkPipeline stencil_zero_pipeline
;
604 VkPipeline max_pipeline
;
605 VkPipeline min_pipeline
;
606 } stencil
[MAX_SAMPLES_LOG2
];
610 VkDescriptorSetLayout ds_layout
;
611 VkPipelineLayout p_layout
;
614 VkRenderPass render_pass
[NUM_META_FS_KEYS
][RADV_META_DST_LAYOUT_COUNT
];
615 VkPipeline pipeline
[NUM_META_FS_KEYS
];
616 } rc
[MAX_SAMPLES_LOG2
];
618 VkRenderPass depth_render_pass
;
619 VkPipeline depth_zero_pipeline
;
621 VkPipeline average_pipeline
;
622 VkPipeline max_pipeline
;
623 VkPipeline min_pipeline
;
624 } depth
[MAX_SAMPLES_LOG2
];
626 VkRenderPass stencil_render_pass
;
627 VkPipeline stencil_zero_pipeline
;
629 VkPipeline max_pipeline
;
630 VkPipeline min_pipeline
;
631 } stencil
[MAX_SAMPLES_LOG2
];
635 VkPipelineLayout p_layout
;
636 VkPipeline decompress_pipeline
;
637 VkPipeline resummarize_pipeline
;
639 } depth_decomp
[1 + MAX_SAMPLES_LOG2
];
642 VkPipelineLayout p_layout
;
643 VkPipeline cmask_eliminate_pipeline
;
644 VkPipeline fmask_decompress_pipeline
;
645 VkPipeline dcc_decompress_pipeline
;
648 VkDescriptorSetLayout dcc_decompress_compute_ds_layout
;
649 VkPipelineLayout dcc_decompress_compute_p_layout
;
650 VkPipeline dcc_decompress_compute_pipeline
;
654 VkPipelineLayout fill_p_layout
;
655 VkPipelineLayout copy_p_layout
;
656 VkDescriptorSetLayout fill_ds_layout
;
657 VkDescriptorSetLayout copy_ds_layout
;
658 VkPipeline fill_pipeline
;
659 VkPipeline copy_pipeline
;
663 VkDescriptorSetLayout ds_layout
;
664 VkPipelineLayout p_layout
;
665 VkPipeline occlusion_query_pipeline
;
666 VkPipeline pipeline_statistics_query_pipeline
;
667 VkPipeline tfb_query_pipeline
;
671 VkDescriptorSetLayout ds_layout
;
672 VkPipelineLayout p_layout
;
673 VkPipeline pipeline
[MAX_SAMPLES_LOG2
];
678 #define RADV_QUEUE_GENERAL 0
679 #define RADV_QUEUE_COMPUTE 1
680 #define RADV_QUEUE_TRANSFER 2
682 #define RADV_MAX_QUEUE_FAMILIES 3
684 enum ring_type
radv_queue_family_to_ring(int f
);
687 VK_LOADER_DATA _loader_data
;
688 struct radv_device
* device
;
689 struct radeon_winsys_ctx
*hw_ctx
;
690 enum radeon_ctx_priority priority
;
691 uint32_t queue_family_index
;
693 VkDeviceQueueCreateFlags flags
;
695 uint32_t scratch_size
;
696 uint32_t compute_scratch_size
;
697 uint32_t esgs_ring_size
;
698 uint32_t gsvs_ring_size
;
700 bool has_sample_positions
;
702 struct radeon_winsys_bo
*scratch_bo
;
703 struct radeon_winsys_bo
*descriptor_bo
;
704 struct radeon_winsys_bo
*compute_scratch_bo
;
705 struct radeon_winsys_bo
*esgs_ring_bo
;
706 struct radeon_winsys_bo
*gsvs_ring_bo
;
707 struct radeon_winsys_bo
*tess_rings_bo
;
708 struct radeon_cmdbuf
*initial_preamble_cs
;
709 struct radeon_cmdbuf
*initial_full_flush_preamble_cs
;
710 struct radeon_cmdbuf
*continue_preamble_cs
;
713 struct radv_bo_list
{
714 struct radv_winsys_bo_list list
;
716 pthread_mutex_t mutex
;
720 VK_LOADER_DATA _loader_data
;
722 VkAllocationCallbacks alloc
;
724 struct radv_instance
* instance
;
725 struct radeon_winsys
*ws
;
727 struct radv_meta_state meta_state
;
729 struct radv_queue
*queues
[RADV_MAX_QUEUE_FAMILIES
];
730 int queue_count
[RADV_MAX_QUEUE_FAMILIES
];
731 struct radeon_cmdbuf
*empty_cs
[RADV_MAX_QUEUE_FAMILIES
];
733 bool always_use_syncobj
;
734 bool has_distributed_tess
;
737 uint32_t tess_offchip_block_dw_size
;
738 uint32_t scratch_waves
;
739 uint32_t dispatch_initiator
;
741 uint32_t gs_table_depth
;
743 /* MSAA sample locations.
744 * The first index is the sample index.
745 * The second index is the coordinate: X, Y. */
746 float sample_locations_1x
[1][2];
747 float sample_locations_2x
[2][2];
748 float sample_locations_4x
[4][2];
749 float sample_locations_8x
[8][2];
752 uint32_t gfx_init_size_dw
;
753 struct radeon_winsys_bo
*gfx_init
;
755 struct radeon_winsys_bo
*trace_bo
;
756 uint32_t *trace_id_ptr
;
758 /* Whether to keep shader debug info, for tracing or VK_AMD_shader_info */
759 bool keep_shader_info
;
761 struct radv_physical_device
*physical_device
;
763 /* Backup in-memory cache to be used if the app doesn't provide one */
764 struct radv_pipeline_cache
* mem_cache
;
767 * use different counters so MSAA MRTs get consecutive surface indices,
768 * even if MASK is allocated in between.
770 uint32_t image_mrt_offset_counter
;
771 uint32_t fmask_mrt_offset_counter
;
772 struct list_head shader_slabs
;
773 mtx_t shader_slab_mutex
;
775 /* For detecting VM faults reported by dmesg. */
776 uint64_t dmesg_timestamp
;
778 struct radv_device_extension_table enabled_extensions
;
780 /* Whether the driver uses a global BO list. */
781 bool use_global_bo_list
;
783 struct radv_bo_list bo_list
;
785 /* Whether anisotropy is forced with RADV_TEX_ANISO (-1 is disabled). */
789 struct radv_device_memory
{
790 struct radeon_winsys_bo
*bo
;
791 /* for dedicated allocations */
792 struct radv_image
*image
;
793 struct radv_buffer
*buffer
;
795 VkDeviceSize map_size
;
801 struct radv_descriptor_range
{
806 struct radv_descriptor_set
{
807 const struct radv_descriptor_set_layout
*layout
;
810 struct radeon_winsys_bo
*bo
;
812 uint32_t *mapped_ptr
;
813 struct radv_descriptor_range
*dynamic_descriptors
;
815 struct radeon_winsys_bo
*descriptors
[0];
818 struct radv_push_descriptor_set
820 struct radv_descriptor_set set
;
824 struct radv_descriptor_pool_entry
{
827 struct radv_descriptor_set
*set
;
830 struct radv_descriptor_pool
{
831 struct radeon_winsys_bo
*bo
;
833 uint64_t current_offset
;
836 uint8_t *host_memory_base
;
837 uint8_t *host_memory_ptr
;
838 uint8_t *host_memory_end
;
840 uint32_t entry_count
;
841 uint32_t max_entry_count
;
842 struct radv_descriptor_pool_entry entries
[0];
845 struct radv_descriptor_update_template_entry
{
846 VkDescriptorType descriptor_type
;
848 /* The number of descriptors to update */
849 uint32_t descriptor_count
;
851 /* Into mapped_ptr or dynamic_descriptors, in units of the respective array */
854 /* In dwords. Not valid/used for dynamic descriptors */
857 uint32_t buffer_offset
;
859 /* Only valid for combined image samplers and samplers */
861 uint8_t sampler_offset
;
867 /* For push descriptors */
868 const uint32_t *immutable_samplers
;
871 struct radv_descriptor_update_template
{
872 uint32_t entry_count
;
873 VkPipelineBindPoint bind_point
;
874 struct radv_descriptor_update_template_entry entry
[0];
880 VkBufferUsageFlags usage
;
881 VkBufferCreateFlags flags
;
884 struct radeon_winsys_bo
* bo
;
890 enum radv_dynamic_state_bits
{
891 RADV_DYNAMIC_VIEWPORT
= 1 << 0,
892 RADV_DYNAMIC_SCISSOR
= 1 << 1,
893 RADV_DYNAMIC_LINE_WIDTH
= 1 << 2,
894 RADV_DYNAMIC_DEPTH_BIAS
= 1 << 3,
895 RADV_DYNAMIC_BLEND_CONSTANTS
= 1 << 4,
896 RADV_DYNAMIC_DEPTH_BOUNDS
= 1 << 5,
897 RADV_DYNAMIC_STENCIL_COMPARE_MASK
= 1 << 6,
898 RADV_DYNAMIC_STENCIL_WRITE_MASK
= 1 << 7,
899 RADV_DYNAMIC_STENCIL_REFERENCE
= 1 << 8,
900 RADV_DYNAMIC_DISCARD_RECTANGLE
= 1 << 9,
901 RADV_DYNAMIC_SAMPLE_LOCATIONS
= 1 << 10,
902 RADV_DYNAMIC_ALL
= (1 << 11) - 1,
905 enum radv_cmd_dirty_bits
{
906 /* Keep the dynamic state dirty bits in sync with
907 * enum radv_dynamic_state_bits */
908 RADV_CMD_DIRTY_DYNAMIC_VIEWPORT
= 1 << 0,
909 RADV_CMD_DIRTY_DYNAMIC_SCISSOR
= 1 << 1,
910 RADV_CMD_DIRTY_DYNAMIC_LINE_WIDTH
= 1 << 2,
911 RADV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS
= 1 << 3,
912 RADV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS
= 1 << 4,
913 RADV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS
= 1 << 5,
914 RADV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK
= 1 << 6,
915 RADV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK
= 1 << 7,
916 RADV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE
= 1 << 8,
917 RADV_CMD_DIRTY_DYNAMIC_DISCARD_RECTANGLE
= 1 << 9,
918 RADV_CMD_DIRTY_DYNAMIC_SAMPLE_LOCATIONS
= 1 << 10,
919 RADV_CMD_DIRTY_DYNAMIC_ALL
= (1 << 11) - 1,
920 RADV_CMD_DIRTY_PIPELINE
= 1 << 11,
921 RADV_CMD_DIRTY_INDEX_BUFFER
= 1 << 12,
922 RADV_CMD_DIRTY_FRAMEBUFFER
= 1 << 13,
923 RADV_CMD_DIRTY_VERTEX_BUFFER
= 1 << 14,
924 RADV_CMD_DIRTY_STREAMOUT_BUFFER
= 1 << 15,
927 enum radv_cmd_flush_bits
{
928 /* Instruction cache. */
929 RADV_CMD_FLAG_INV_ICACHE
= 1 << 0,
930 /* Scalar L1 cache. */
931 RADV_CMD_FLAG_INV_SCACHE
= 1 << 1,
932 /* Vector L1 cache. */
933 RADV_CMD_FLAG_INV_VCACHE
= 1 << 2,
934 /* L2 cache + L2 metadata cache writeback & invalidate.
935 * GFX6-8: Used by shaders only. GFX9-10: Used by everything. */
936 RADV_CMD_FLAG_INV_L2
= 1 << 3,
937 /* L2 writeback (write dirty L2 lines to memory for non-L2 clients).
938 * Only used for coherency with non-L2 clients like CB, DB, CP on GFX6-8.
939 * GFX6-7 will do complete invalidation, because the writeback is unsupported. */
940 RADV_CMD_FLAG_WB_L2
= 1 << 4,
941 /* Framebuffer caches */
942 RADV_CMD_FLAG_FLUSH_AND_INV_CB_META
= 1 << 5,
943 RADV_CMD_FLAG_FLUSH_AND_INV_DB_META
= 1 << 6,
944 RADV_CMD_FLAG_FLUSH_AND_INV_DB
= 1 << 7,
945 RADV_CMD_FLAG_FLUSH_AND_INV_CB
= 1 << 8,
946 /* Engine synchronization. */
947 RADV_CMD_FLAG_VS_PARTIAL_FLUSH
= 1 << 9,
948 RADV_CMD_FLAG_PS_PARTIAL_FLUSH
= 1 << 10,
949 RADV_CMD_FLAG_CS_PARTIAL_FLUSH
= 1 << 11,
950 RADV_CMD_FLAG_VGT_FLUSH
= 1 << 12,
951 /* Pipeline query controls. */
952 RADV_CMD_FLAG_START_PIPELINE_STATS
= 1 << 13,
953 RADV_CMD_FLAG_STOP_PIPELINE_STATS
= 1 << 14,
954 RADV_CMD_FLAG_VGT_STREAMOUT_SYNC
= 1 << 15,
956 RADV_CMD_FLUSH_AND_INV_FRAMEBUFFER
= (RADV_CMD_FLAG_FLUSH_AND_INV_CB
|
957 RADV_CMD_FLAG_FLUSH_AND_INV_CB_META
|
958 RADV_CMD_FLAG_FLUSH_AND_INV_DB
|
959 RADV_CMD_FLAG_FLUSH_AND_INV_DB_META
)
962 struct radv_vertex_binding
{
963 struct radv_buffer
* buffer
;
967 struct radv_streamout_binding
{
968 struct radv_buffer
*buffer
;
973 struct radv_streamout_state
{
974 /* Mask of bound streamout buffers. */
975 uint8_t enabled_mask
;
977 /* External state that comes from the last vertex stage, it must be
978 * set explicitely when binding a new graphics pipeline.
980 uint16_t stride_in_dw
[MAX_SO_BUFFERS
];
981 uint32_t enabled_stream_buffers_mask
; /* stream0 buffers0-3 in 4 LSB */
983 /* State of VGT_STRMOUT_BUFFER_(CONFIG|END) */
984 uint32_t hw_enabled_mask
;
986 /* State of VGT_STRMOUT_(CONFIG|EN) */
987 bool streamout_enabled
;
990 struct radv_viewport_state
{
992 VkViewport viewports
[MAX_VIEWPORTS
];
995 struct radv_scissor_state
{
997 VkRect2D scissors
[MAX_SCISSORS
];
1000 struct radv_discard_rectangle_state
{
1002 VkRect2D rectangles
[MAX_DISCARD_RECTANGLES
];
1005 struct radv_sample_locations_state
{
1006 VkSampleCountFlagBits per_pixel
;
1007 VkExtent2D grid_size
;
1009 VkSampleLocationEXT locations
[MAX_SAMPLE_LOCATIONS
];
1012 struct radv_dynamic_state
{
1014 * Bitmask of (1 << VK_DYNAMIC_STATE_*).
1015 * Defines the set of saved dynamic state.
1019 struct radv_viewport_state viewport
;
1021 struct radv_scissor_state scissor
;
1031 float blend_constants
[4];
1041 } stencil_compare_mask
;
1046 } stencil_write_mask
;
1051 } stencil_reference
;
1053 struct radv_discard_rectangle_state discard_rectangle
;
1055 struct radv_sample_locations_state sample_location
;
1058 extern const struct radv_dynamic_state default_dynamic_state
;
1061 radv_get_debug_option_name(int id
);
1064 radv_get_perftest_option_name(int id
);
1067 * Attachment state when recording a renderpass instance.
1069 * The clear value is valid only if there exists a pending clear.
1071 struct radv_attachment_state
{
1072 VkImageAspectFlags pending_clear_aspects
;
1073 uint32_t cleared_views
;
1074 VkClearValue clear_value
;
1075 VkImageLayout current_layout
;
1076 struct radv_sample_locations_state sample_location
;
1079 struct radv_descriptor_state
{
1080 struct radv_descriptor_set
*sets
[MAX_SETS
];
1083 struct radv_push_descriptor_set push_set
;
1085 uint32_t dynamic_buffers
[4 * MAX_DYNAMIC_BUFFERS
];
1088 struct radv_subpass_sample_locs_state
{
1089 uint32_t subpass_idx
;
1090 struct radv_sample_locations_state sample_location
;
1093 struct radv_cmd_state
{
1094 /* Vertex descriptors */
1101 uint32_t prefetch_L2_mask
;
1103 struct radv_pipeline
* pipeline
;
1104 struct radv_pipeline
* emitted_pipeline
;
1105 struct radv_pipeline
* compute_pipeline
;
1106 struct radv_pipeline
* emitted_compute_pipeline
;
1107 struct radv_framebuffer
* framebuffer
;
1108 struct radv_render_pass
* pass
;
1109 const struct radv_subpass
* subpass
;
1110 struct radv_dynamic_state dynamic
;
1111 struct radv_attachment_state
* attachments
;
1112 struct radv_streamout_state streamout
;
1113 VkRect2D render_area
;
1115 uint32_t num_subpass_sample_locs
;
1116 struct radv_subpass_sample_locs_state
* subpass_sample_locs
;
1119 struct radv_buffer
*index_buffer
;
1120 uint64_t index_offset
;
1121 uint32_t index_type
;
1122 uint32_t max_index_count
;
1124 int32_t last_index_type
;
1126 int32_t last_primitive_reset_en
;
1127 uint32_t last_primitive_reset_index
;
1128 enum radv_cmd_flush_bits flush_bits
;
1129 unsigned active_occlusion_queries
;
1130 bool perfect_occlusion_queries_enabled
;
1131 unsigned active_pipeline_queries
;
1134 uint32_t last_ia_multi_vgt_param
;
1136 uint32_t last_num_instances
;
1137 uint32_t last_first_instance
;
1138 uint32_t last_vertex_offset
;
1140 /* Whether CP DMA is busy/idle. */
1143 /* Conditional rendering info. */
1144 int predication_type
; /* -1: disabled, 0: normal, 1: inverted */
1145 uint64_t predication_va
;
1147 bool context_roll_without_scissor_emitted
;
1150 struct radv_cmd_pool
{
1151 VkAllocationCallbacks alloc
;
1152 struct list_head cmd_buffers
;
1153 struct list_head free_cmd_buffers
;
1154 uint32_t queue_family_index
;
1157 struct radv_cmd_buffer_upload
{
1161 struct radeon_winsys_bo
*upload_bo
;
1162 struct list_head list
;
1165 enum radv_cmd_buffer_status
{
1166 RADV_CMD_BUFFER_STATUS_INVALID
,
1167 RADV_CMD_BUFFER_STATUS_INITIAL
,
1168 RADV_CMD_BUFFER_STATUS_RECORDING
,
1169 RADV_CMD_BUFFER_STATUS_EXECUTABLE
,
1170 RADV_CMD_BUFFER_STATUS_PENDING
,
1173 struct radv_cmd_buffer
{
1174 VK_LOADER_DATA _loader_data
;
1176 struct radv_device
* device
;
1178 struct radv_cmd_pool
* pool
;
1179 struct list_head pool_link
;
1181 VkCommandBufferUsageFlags usage_flags
;
1182 VkCommandBufferLevel level
;
1183 enum radv_cmd_buffer_status status
;
1184 struct radeon_cmdbuf
*cs
;
1185 struct radv_cmd_state state
;
1186 struct radv_vertex_binding vertex_bindings
[MAX_VBS
];
1187 struct radv_streamout_binding streamout_bindings
[MAX_SO_BUFFERS
];
1188 uint32_t queue_family_index
;
1190 uint8_t push_constants
[MAX_PUSH_CONSTANTS_SIZE
];
1191 VkShaderStageFlags push_constant_stages
;
1192 struct radv_descriptor_set meta_push_descriptors
;
1194 struct radv_descriptor_state descriptors
[VK_PIPELINE_BIND_POINT_RANGE_SIZE
];
1196 struct radv_cmd_buffer_upload upload
;
1198 uint32_t scratch_size_needed
;
1199 uint32_t compute_scratch_size_needed
;
1200 uint32_t esgs_ring_size_needed
;
1201 uint32_t gsvs_ring_size_needed
;
1202 bool tess_rings_needed
;
1203 bool sample_positions_needed
;
1205 VkResult record_result
;
1207 uint64_t gfx9_fence_va
;
1208 uint32_t gfx9_fence_idx
;
1209 uint64_t gfx9_eop_bug_va
;
1212 * Whether a query pool has been resetted and we have to flush caches.
1214 bool pending_reset_query
;
1217 * Bitmask of pending active query flushes.
1219 enum radv_cmd_flush_bits active_query_flush_bits
;
1223 struct radv_image_view
;
1225 bool radv_cmd_buffer_uses_mec(struct radv_cmd_buffer
*cmd_buffer
);
1227 void si_emit_graphics(struct radv_physical_device
*physical_device
,
1228 struct radeon_cmdbuf
*cs
);
1229 void si_emit_compute(struct radv_physical_device
*physical_device
,
1230 struct radeon_cmdbuf
*cs
);
1232 void cik_create_gfx_config(struct radv_device
*device
);
1234 void si_write_viewport(struct radeon_cmdbuf
*cs
, int first_vp
,
1235 int count
, const VkViewport
*viewports
);
1236 void si_write_scissors(struct radeon_cmdbuf
*cs
, int first
,
1237 int count
, const VkRect2D
*scissors
,
1238 const VkViewport
*viewports
, bool can_use_guardband
);
1239 uint32_t si_get_ia_multi_vgt_param(struct radv_cmd_buffer
*cmd_buffer
,
1240 bool instanced_draw
, bool indirect_draw
,
1241 bool count_from_stream_output
,
1242 uint32_t draw_vertex_count
);
1243 void si_cs_emit_write_event_eop(struct radeon_cmdbuf
*cs
,
1244 enum chip_class chip_class
,
1246 unsigned event
, unsigned event_flags
,
1250 uint64_t gfx9_eop_bug_va
);
1252 void radv_cp_wait_mem(struct radeon_cmdbuf
*cs
, uint32_t op
, uint64_t va
,
1253 uint32_t ref
, uint32_t mask
);
1254 void si_cs_emit_cache_flush(struct radeon_cmdbuf
*cs
,
1255 enum chip_class chip_class
,
1256 uint32_t *fence_ptr
, uint64_t va
,
1258 enum radv_cmd_flush_bits flush_bits
,
1259 uint64_t gfx9_eop_bug_va
);
1260 void si_emit_cache_flush(struct radv_cmd_buffer
*cmd_buffer
);
1261 void si_emit_set_predication_state(struct radv_cmd_buffer
*cmd_buffer
,
1262 bool inverted
, uint64_t va
);
1263 void si_cp_dma_buffer_copy(struct radv_cmd_buffer
*cmd_buffer
,
1264 uint64_t src_va
, uint64_t dest_va
,
1266 void si_cp_dma_prefetch(struct radv_cmd_buffer
*cmd_buffer
, uint64_t va
,
1268 void si_cp_dma_clear_buffer(struct radv_cmd_buffer
*cmd_buffer
, uint64_t va
,
1269 uint64_t size
, unsigned value
);
1270 void si_cp_dma_wait_for_idle(struct radv_cmd_buffer
*cmd_buffer
);
1272 void radv_set_db_count_control(struct radv_cmd_buffer
*cmd_buffer
);
1274 radv_cmd_buffer_upload_alloc(struct radv_cmd_buffer
*cmd_buffer
,
1277 unsigned *out_offset
,
1280 radv_cmd_buffer_set_subpass(struct radv_cmd_buffer
*cmd_buffer
,
1281 const struct radv_subpass
*subpass
);
1283 radv_cmd_buffer_upload_data(struct radv_cmd_buffer
*cmd_buffer
,
1284 unsigned size
, unsigned alignmnet
,
1285 const void *data
, unsigned *out_offset
);
1287 void radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer
*cmd_buffer
);
1288 void radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer
*cmd_buffer
);
1289 void radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer
*cmd_buffer
);
1290 void radv_depth_stencil_resolve_subpass_cs(struct radv_cmd_buffer
*cmd_buffer
,
1291 VkImageAspectFlags aspects
,
1292 VkResolveModeFlagBitsKHR resolve_mode
);
1293 void radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer
*cmd_buffer
);
1294 void radv_depth_stencil_resolve_subpass_fs(struct radv_cmd_buffer
*cmd_buffer
,
1295 VkImageAspectFlags aspects
,
1296 VkResolveModeFlagBitsKHR resolve_mode
);
1297 void radv_emit_default_sample_locations(struct radeon_cmdbuf
*cs
, int nr_samples
);
1298 unsigned radv_get_default_max_sample_dist(int log_samples
);
1299 void radv_device_init_msaa(struct radv_device
*device
);
1301 void radv_update_ds_clear_metadata(struct radv_cmd_buffer
*cmd_buffer
,
1302 struct radv_image
*image
,
1303 VkClearDepthStencilValue ds_clear_value
,
1304 VkImageAspectFlags aspects
);
1306 void radv_update_color_clear_metadata(struct radv_cmd_buffer
*cmd_buffer
,
1307 const struct radv_image_view
*iview
,
1309 uint32_t color_values
[2]);
1311 void radv_update_fce_metadata(struct radv_cmd_buffer
*cmd_buffer
,
1312 struct radv_image
*image
,
1313 const VkImageSubresourceRange
*range
, bool value
);
1315 void radv_update_dcc_metadata(struct radv_cmd_buffer
*cmd_buffer
,
1316 struct radv_image
*image
,
1317 const VkImageSubresourceRange
*range
, bool value
);
1319 uint32_t radv_fill_buffer(struct radv_cmd_buffer
*cmd_buffer
,
1320 struct radeon_winsys_bo
*bo
,
1321 uint64_t offset
, uint64_t size
, uint32_t value
);
1322 void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer
*cmd_buffer
);
1323 bool radv_get_memory_fd(struct radv_device
*device
,
1324 struct radv_device_memory
*memory
,
1328 radv_emit_shader_pointer_head(struct radeon_cmdbuf
*cs
,
1329 unsigned sh_offset
, unsigned pointer_count
,
1330 bool use_32bit_pointers
)
1332 radeon_emit(cs
, PKT3(PKT3_SET_SH_REG
, pointer_count
* (use_32bit_pointers
? 1 : 2), 0));
1333 radeon_emit(cs
, (sh_offset
- SI_SH_REG_OFFSET
) >> 2);
1337 radv_emit_shader_pointer_body(struct radv_device
*device
,
1338 struct radeon_cmdbuf
*cs
,
1339 uint64_t va
, bool use_32bit_pointers
)
1341 radeon_emit(cs
, va
);
1343 if (use_32bit_pointers
) {
1345 (va
>> 32) == device
->physical_device
->rad_info
.address32_hi
);
1347 radeon_emit(cs
, va
>> 32);
1352 radv_emit_shader_pointer(struct radv_device
*device
,
1353 struct radeon_cmdbuf
*cs
,
1354 uint32_t sh_offset
, uint64_t va
, bool global
)
1356 bool use_32bit_pointers
= !global
;
1358 radv_emit_shader_pointer_head(cs
, sh_offset
, 1, use_32bit_pointers
);
1359 radv_emit_shader_pointer_body(device
, cs
, va
, use_32bit_pointers
);
1362 static inline struct radv_descriptor_state
*
1363 radv_get_descriptors_state(struct radv_cmd_buffer
*cmd_buffer
,
1364 VkPipelineBindPoint bind_point
)
1366 assert(bind_point
== VK_PIPELINE_BIND_POINT_GRAPHICS
||
1367 bind_point
== VK_PIPELINE_BIND_POINT_COMPUTE
);
1368 return &cmd_buffer
->descriptors
[bind_point
];
1372 * Takes x,y,z as exact numbers of invocations, instead of blocks.
1374 * Limitations: Can't call normal dispatch functions without binding or rebinding
1375 * the compute pipeline.
1377 void radv_unaligned_dispatch(
1378 struct radv_cmd_buffer
*cmd_buffer
,
1384 struct radeon_winsys_bo
*bo
;
1388 struct radv_shader_module
;
1390 #define RADV_HASH_SHADER_IS_GEOM_COPY_SHADER (1 << 0)
1391 #define RADV_HASH_SHADER_SISCHED (1 << 1)
1392 #define RADV_HASH_SHADER_UNSAFE_MATH (1 << 2)
1394 radv_hash_shaders(unsigned char *hash
,
1395 const VkPipelineShaderStageCreateInfo
**stages
,
1396 const struct radv_pipeline_layout
*layout
,
1397 const struct radv_pipeline_key
*key
,
1400 static inline gl_shader_stage
1401 vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage
)
1403 assert(__builtin_popcount(vk_stage
) == 1);
1404 return ffs(vk_stage
) - 1;
1407 static inline VkShaderStageFlagBits
1408 mesa_to_vk_shader_stage(gl_shader_stage mesa_stage
)
1410 return (1 << mesa_stage
);
1413 #define RADV_STAGE_MASK ((1 << MESA_SHADER_STAGES) - 1)
1415 #define radv_foreach_stage(stage, stage_bits) \
1416 for (gl_shader_stage stage, \
1417 __tmp = (gl_shader_stage)((stage_bits) & RADV_STAGE_MASK); \
1418 stage = __builtin_ffs(__tmp) - 1, __tmp; \
1419 __tmp &= ~(1 << (stage)))
1421 extern const VkFormat radv_fs_key_format_exemplars
[NUM_META_FS_KEYS
];
1422 unsigned radv_format_meta_fs_key(VkFormat format
);
1424 struct radv_multisample_state
{
1426 uint32_t pa_sc_line_cntl
;
1427 uint32_t pa_sc_mode_cntl_0
;
1428 uint32_t pa_sc_mode_cntl_1
;
1429 uint32_t pa_sc_aa_config
;
1430 uint32_t pa_sc_aa_mask
[2];
1431 unsigned num_samples
;
1434 struct radv_prim_vertex_count
{
1439 struct radv_vertex_elements_info
{
1440 uint32_t format_size
[MAX_VERTEX_ATTRIBS
];
1443 struct radv_ia_multi_vgt_param_helpers
{
1445 bool partial_es_wave
;
1446 uint8_t primgroup_size
;
1447 bool wd_switch_on_eop
;
1448 bool ia_switch_on_eoi
;
1449 bool partial_vs_wave
;
1452 #define SI_GS_PER_ES 128
1454 struct radv_pipeline
{
1455 struct radv_device
* device
;
1456 struct radv_dynamic_state dynamic_state
;
1458 struct radv_pipeline_layout
* layout
;
1460 bool need_indirect_descriptor_sets
;
1461 struct radv_shader_variant
* shaders
[MESA_SHADER_STAGES
];
1462 struct radv_shader_variant
*gs_copy_shader
;
1463 VkShaderStageFlags active_stages
;
1465 struct radeon_cmdbuf cs
;
1466 uint32_t ctx_cs_hash
;
1467 struct radeon_cmdbuf ctx_cs
;
1469 struct radv_vertex_elements_info vertex_elements
;
1471 uint32_t binding_stride
[MAX_VBS
];
1472 uint8_t num_vertex_bindings
;
1474 uint32_t user_data_0
[MESA_SHADER_STAGES
];
1477 struct radv_multisample_state ms
;
1478 uint32_t spi_baryc_cntl
;
1479 bool prim_restart_enable
;
1480 unsigned esgs_ring_size
;
1481 unsigned gsvs_ring_size
;
1482 uint32_t vtx_base_sgpr
;
1483 struct radv_ia_multi_vgt_param_helpers ia_multi_vgt_param
;
1484 uint8_t vtx_emit_num
;
1485 struct radv_prim_vertex_count prim_vertex_count
;
1486 bool can_use_guardband
;
1487 uint32_t needed_dynamic_state
;
1488 bool disable_out_of_order_rast_for_occlusion
;
1490 /* Used for rbplus */
1491 uint32_t col_format
;
1492 uint32_t cb_target_mask
;
1497 unsigned scratch_bytes_per_wave
;
1499 /* Not NULL if graphics pipeline uses streamout. */
1500 struct radv_shader_variant
*streamout_shader
;
1503 static inline bool radv_pipeline_has_gs(const struct radv_pipeline
*pipeline
)
1505 return pipeline
->shaders
[MESA_SHADER_GEOMETRY
] ? true : false;
1508 static inline bool radv_pipeline_has_tess(const struct radv_pipeline
*pipeline
)
1510 return pipeline
->shaders
[MESA_SHADER_TESS_CTRL
] ? true : false;
1513 struct radv_userdata_info
*radv_lookup_user_sgpr(struct radv_pipeline
*pipeline
,
1514 gl_shader_stage stage
,
1517 struct radv_shader_variant
*radv_get_shader(struct radv_pipeline
*pipeline
,
1518 gl_shader_stage stage
);
1520 struct radv_graphics_pipeline_create_info
{
1522 bool db_depth_clear
;
1523 bool db_stencil_clear
;
1524 bool db_depth_disable_expclear
;
1525 bool db_stencil_disable_expclear
;
1526 bool db_flush_depth_inplace
;
1527 bool db_flush_stencil_inplace
;
1528 bool db_resummarize
;
1529 uint32_t custom_blend_mode
;
1533 radv_graphics_pipeline_create(VkDevice device
,
1534 VkPipelineCache cache
,
1535 const VkGraphicsPipelineCreateInfo
*pCreateInfo
,
1536 const struct radv_graphics_pipeline_create_info
*extra
,
1537 const VkAllocationCallbacks
*alloc
,
1538 VkPipeline
*pPipeline
);
1540 struct vk_format_description
;
1541 uint32_t radv_translate_buffer_dataformat(const struct vk_format_description
*desc
,
1542 int first_non_void
);
1543 uint32_t radv_translate_buffer_numformat(const struct vk_format_description
*desc
,
1544 int first_non_void
);
1545 bool radv_is_buffer_format_supported(VkFormat format
, bool *scaled
);
1546 uint32_t radv_translate_colorformat(VkFormat format
);
1547 uint32_t radv_translate_color_numformat(VkFormat format
,
1548 const struct vk_format_description
*desc
,
1549 int first_non_void
);
1550 uint32_t radv_colorformat_endian_swap(uint32_t colorformat
);
1551 unsigned radv_translate_colorswap(VkFormat format
, bool do_endian_swap
);
1552 uint32_t radv_translate_dbformat(VkFormat format
);
1553 uint32_t radv_translate_tex_dataformat(VkFormat format
,
1554 const struct vk_format_description
*desc
,
1555 int first_non_void
);
1556 uint32_t radv_translate_tex_numformat(VkFormat format
,
1557 const struct vk_format_description
*desc
,
1558 int first_non_void
);
1559 bool radv_format_pack_clear_color(VkFormat format
,
1560 uint32_t clear_vals
[2],
1561 VkClearColorValue
*value
);
1562 bool radv_is_colorbuffer_format_supported(VkFormat format
, bool *blendable
);
1563 bool radv_dcc_formats_compatible(VkFormat format1
,
1565 bool radv_device_supports_etc(struct radv_physical_device
*physical_device
);
1567 struct radv_fmask_info
{
1571 unsigned pitch_in_pixels
;
1572 unsigned bank_height
;
1573 unsigned slice_tile_max
;
1574 unsigned tile_mode_index
;
1575 unsigned tile_swizzle
;
1576 uint64_t slice_size
;
1579 struct radv_cmask_info
{
1583 unsigned slice_tile_max
;
1584 unsigned slice_size
;
1588 struct radv_image_plane
{
1590 struct radeon_surf surface
;
1596 /* The original VkFormat provided by the client. This may not match any
1597 * of the actual surface formats.
1600 VkImageAspectFlags aspects
;
1601 VkImageUsageFlags usage
; /**< Superset of VkImageCreateInfo::usage. */
1602 struct ac_surf_info info
;
1603 VkImageTiling tiling
; /** VkImageCreateInfo::tiling */
1604 VkImageCreateFlags flags
; /** VkImageCreateInfo::flags */
1609 unsigned queue_family_mask
;
1613 /* Set when bound */
1614 struct radeon_winsys_bo
*bo
;
1615 VkDeviceSize offset
;
1616 uint64_t dcc_offset
;
1617 uint64_t htile_offset
;
1618 bool tc_compatible_htile
;
1619 bool tc_compatible_cmask
;
1621 struct radv_fmask_info fmask
;
1622 struct radv_cmask_info cmask
;
1623 uint64_t clear_value_offset
;
1624 uint64_t fce_pred_offset
;
1625 uint64_t dcc_pred_offset
;
1628 * Metadata for the TC-compat zrange workaround. If the 32-bit value
1629 * stored at this offset is UINT_MAX, the driver will emit
1630 * DB_Z_INFO.ZRANGE_PRECISION=0, otherwise it will skip the
1631 * SET_CONTEXT_REG packet.
1633 uint64_t tc_compat_zrange_offset
;
1635 /* For VK_ANDROID_native_buffer, the WSI image owns the memory, */
1636 VkDeviceMemory owned_memory
;
1638 unsigned plane_count
;
1639 struct radv_image_plane planes
[0];
1642 /* Whether the image has a htile that is known consistent with the contents of
1644 bool radv_layout_has_htile(const struct radv_image
*image
,
1645 VkImageLayout layout
,
1646 unsigned queue_mask
);
1648 /* Whether the image has a htile that is known consistent with the contents of
1649 * the image and is allowed to be in compressed form.
1651 * If this is false reads that don't use the htile should be able to return
1654 bool radv_layout_is_htile_compressed(const struct radv_image
*image
,
1655 VkImageLayout layout
,
1656 unsigned queue_mask
);
1658 bool radv_layout_can_fast_clear(const struct radv_image
*image
,
1659 VkImageLayout layout
,
1660 unsigned queue_mask
);
1662 bool radv_layout_dcc_compressed(const struct radv_image
*image
,
1663 VkImageLayout layout
,
1664 unsigned queue_mask
);
1667 * Return whether the image has CMASK metadata for color surfaces.
1670 radv_image_has_cmask(const struct radv_image
*image
)
1672 return image
->cmask
.size
;
1676 * Return whether the image has FMASK metadata for color surfaces.
1679 radv_image_has_fmask(const struct radv_image
*image
)
1681 return image
->fmask
.size
;
1685 * Return whether the image has DCC metadata for color surfaces.
1688 radv_image_has_dcc(const struct radv_image
*image
)
1690 return image
->planes
[0].surface
.dcc_size
;
1694 * Return whether the image is TC-compatible CMASK.
1697 radv_image_is_tc_compat_cmask(const struct radv_image
*image
)
1699 return radv_image_has_fmask(image
) && image
->tc_compatible_cmask
;
1703 * Return whether DCC metadata is enabled for a level.
1706 radv_dcc_enabled(const struct radv_image
*image
, unsigned level
)
1708 return radv_image_has_dcc(image
) &&
1709 level
< image
->planes
[0].surface
.num_dcc_levels
;
1713 * Return whether the image has CB metadata.
1716 radv_image_has_CB_metadata(const struct radv_image
*image
)
1718 return radv_image_has_cmask(image
) ||
1719 radv_image_has_fmask(image
) ||
1720 radv_image_has_dcc(image
);
1724 * Return whether the image has HTILE metadata for depth surfaces.
1727 radv_image_has_htile(const struct radv_image
*image
)
1729 return image
->planes
[0].surface
.htile_size
;
1733 * Return whether HTILE metadata is enabled for a level.
1736 radv_htile_enabled(const struct radv_image
*image
, unsigned level
)
1738 return radv_image_has_htile(image
) && level
== 0;
1742 * Return whether the image is TC-compatible HTILE.
1745 radv_image_is_tc_compat_htile(const struct radv_image
*image
)
1747 return radv_image_has_htile(image
) && image
->tc_compatible_htile
;
1750 static inline uint64_t
1751 radv_image_get_fast_clear_va(const struct radv_image
*image
,
1752 uint32_t base_level
)
1754 uint64_t va
= radv_buffer_get_va(image
->bo
);
1755 va
+= image
->offset
+ image
->clear_value_offset
+ base_level
* 8;
1759 static inline uint64_t
1760 radv_image_get_fce_pred_va(const struct radv_image
*image
,
1761 uint32_t base_level
)
1763 uint64_t va
= radv_buffer_get_va(image
->bo
);
1764 va
+= image
->offset
+ image
->fce_pred_offset
+ base_level
* 8;
1768 static inline uint64_t
1769 radv_image_get_dcc_pred_va(const struct radv_image
*image
,
1770 uint32_t base_level
)
1772 uint64_t va
= radv_buffer_get_va(image
->bo
);
1773 va
+= image
->offset
+ image
->dcc_pred_offset
+ base_level
* 8;
1777 unsigned radv_image_queue_family_mask(const struct radv_image
*image
, uint32_t family
, uint32_t queue_family
);
1779 static inline uint32_t
1780 radv_get_layerCount(const struct radv_image
*image
,
1781 const VkImageSubresourceRange
*range
)
1783 return range
->layerCount
== VK_REMAINING_ARRAY_LAYERS
?
1784 image
->info
.array_size
- range
->baseArrayLayer
: range
->layerCount
;
1787 static inline uint32_t
1788 radv_get_levelCount(const struct radv_image
*image
,
1789 const VkImageSubresourceRange
*range
)
1791 return range
->levelCount
== VK_REMAINING_MIP_LEVELS
?
1792 image
->info
.levels
- range
->baseMipLevel
: range
->levelCount
;
1795 struct radeon_bo_metadata
;
1797 radv_init_metadata(struct radv_device
*device
,
1798 struct radv_image
*image
,
1799 struct radeon_bo_metadata
*metadata
);
1802 radv_image_override_offset_stride(struct radv_device
*device
,
1803 struct radv_image
*image
,
1804 uint64_t offset
, uint32_t stride
);
1806 union radv_descriptor
{
1808 uint32_t plane0_descriptor
[8];
1809 uint32_t fmask_descriptor
[8];
1812 uint32_t plane_descriptors
[3][8];
1816 struct radv_image_view
{
1817 struct radv_image
*image
; /**< VkImageViewCreateInfo::image */
1818 struct radeon_winsys_bo
*bo
;
1820 VkImageViewType type
;
1821 VkImageAspectFlags aspect_mask
;
1824 bool multiple_planes
;
1825 uint32_t base_layer
;
1826 uint32_t layer_count
;
1828 uint32_t level_count
;
1829 VkExtent3D extent
; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
1831 union radv_descriptor descriptor
;
1833 /* Descriptor for use as a storage image as opposed to a sampled image.
1834 * This has a few differences for cube maps (e.g. type).
1836 union radv_descriptor storage_descriptor
;
1839 struct radv_image_create_info
{
1840 const VkImageCreateInfo
*vk_info
;
1842 bool no_metadata_planes
;
1843 const struct radeon_bo_metadata
*bo_metadata
;
1846 VkResult
radv_image_create(VkDevice _device
,
1847 const struct radv_image_create_info
*info
,
1848 const VkAllocationCallbacks
* alloc
,
1852 radv_image_from_gralloc(VkDevice device_h
,
1853 const VkImageCreateInfo
*base_info
,
1854 const VkNativeBufferANDROID
*gralloc_info
,
1855 const VkAllocationCallbacks
*alloc
,
1856 VkImage
*out_image_h
);
1858 void radv_image_view_init(struct radv_image_view
*view
,
1859 struct radv_device
*device
,
1860 const VkImageViewCreateInfo
* pCreateInfo
);
1862 VkFormat
radv_get_aspect_format(struct radv_image
*image
, VkImageAspectFlags mask
);
1864 struct radv_sampler_ycbcr_conversion
{
1866 VkSamplerYcbcrModelConversion ycbcr_model
;
1867 VkSamplerYcbcrRange ycbcr_range
;
1868 VkComponentMapping components
;
1869 VkChromaLocation chroma_offsets
[2];
1870 VkFilter chroma_filter
;
1873 struct radv_buffer_view
{
1874 struct radeon_winsys_bo
*bo
;
1876 uint64_t range
; /**< VkBufferViewCreateInfo::range */
1879 void radv_buffer_view_init(struct radv_buffer_view
*view
,
1880 struct radv_device
*device
,
1881 const VkBufferViewCreateInfo
* pCreateInfo
);
1883 static inline struct VkExtent3D
1884 radv_sanitize_image_extent(const VkImageType imageType
,
1885 const struct VkExtent3D imageExtent
)
1887 switch (imageType
) {
1888 case VK_IMAGE_TYPE_1D
:
1889 return (VkExtent3D
) { imageExtent
.width
, 1, 1 };
1890 case VK_IMAGE_TYPE_2D
:
1891 return (VkExtent3D
) { imageExtent
.width
, imageExtent
.height
, 1 };
1892 case VK_IMAGE_TYPE_3D
:
1895 unreachable("invalid image type");
1899 static inline struct VkOffset3D
1900 radv_sanitize_image_offset(const VkImageType imageType
,
1901 const struct VkOffset3D imageOffset
)
1903 switch (imageType
) {
1904 case VK_IMAGE_TYPE_1D
:
1905 return (VkOffset3D
) { imageOffset
.x
, 0, 0 };
1906 case VK_IMAGE_TYPE_2D
:
1907 return (VkOffset3D
) { imageOffset
.x
, imageOffset
.y
, 0 };
1908 case VK_IMAGE_TYPE_3D
:
1911 unreachable("invalid image type");
1916 radv_image_extent_compare(const struct radv_image
*image
,
1917 const VkExtent3D
*extent
)
1919 if (extent
->width
!= image
->info
.width
||
1920 extent
->height
!= image
->info
.height
||
1921 extent
->depth
!= image
->info
.depth
)
1926 struct radv_sampler
{
1928 struct radv_sampler_ycbcr_conversion
*ycbcr_sampler
;
1931 struct radv_color_buffer_info
{
1932 uint64_t cb_color_base
;
1933 uint64_t cb_color_cmask
;
1934 uint64_t cb_color_fmask
;
1935 uint64_t cb_dcc_base
;
1936 uint32_t cb_color_slice
;
1937 uint32_t cb_color_view
;
1938 uint32_t cb_color_info
;
1939 uint32_t cb_color_attrib
;
1940 uint32_t cb_color_attrib2
; /* GFX9 and later */
1941 uint32_t cb_color_attrib3
; /* GFX10 and later */
1942 uint32_t cb_dcc_control
;
1943 uint32_t cb_color_cmask_slice
;
1944 uint32_t cb_color_fmask_slice
;
1946 uint32_t cb_color_pitch
; // GFX6-GFX8
1947 uint32_t cb_mrt_epitch
; // GFX9+
1951 struct radv_ds_buffer_info
{
1952 uint64_t db_z_read_base
;
1953 uint64_t db_stencil_read_base
;
1954 uint64_t db_z_write_base
;
1955 uint64_t db_stencil_write_base
;
1956 uint64_t db_htile_data_base
;
1957 uint32_t db_depth_info
;
1959 uint32_t db_stencil_info
;
1960 uint32_t db_depth_view
;
1961 uint32_t db_depth_size
;
1962 uint32_t db_depth_slice
;
1963 uint32_t db_htile_surface
;
1964 uint32_t pa_su_poly_offset_db_fmt_cntl
;
1965 uint32_t db_z_info2
; /* GFX9 only */
1966 uint32_t db_stencil_info2
; /* GFX9 only */
1970 struct radv_attachment_info
{
1972 struct radv_color_buffer_info cb
;
1973 struct radv_ds_buffer_info ds
;
1975 struct radv_image_view
*attachment
;
1978 struct radv_framebuffer
{
1983 uint32_t attachment_count
;
1984 struct radv_attachment_info attachments
[0];
1987 struct radv_subpass_barrier
{
1988 VkPipelineStageFlags src_stage_mask
;
1989 VkAccessFlags src_access_mask
;
1990 VkAccessFlags dst_access_mask
;
1993 void radv_subpass_barrier(struct radv_cmd_buffer
*cmd_buffer
,
1994 const struct radv_subpass_barrier
*barrier
);
1996 struct radv_subpass_attachment
{
1997 uint32_t attachment
;
1998 VkImageLayout layout
;
2001 struct radv_subpass
{
2002 uint32_t attachment_count
;
2003 struct radv_subpass_attachment
* attachments
;
2005 uint32_t input_count
;
2006 uint32_t color_count
;
2007 struct radv_subpass_attachment
* input_attachments
;
2008 struct radv_subpass_attachment
* color_attachments
;
2009 struct radv_subpass_attachment
* resolve_attachments
;
2010 struct radv_subpass_attachment
* depth_stencil_attachment
;
2011 struct radv_subpass_attachment
* ds_resolve_attachment
;
2012 VkResolveModeFlagBitsKHR depth_resolve_mode
;
2013 VkResolveModeFlagBitsKHR stencil_resolve_mode
;
2015 /** Subpass has at least one color resolve attachment */
2016 bool has_color_resolve
;
2018 /** Subpass has at least one color attachment */
2021 struct radv_subpass_barrier start_barrier
;
2024 VkSampleCountFlagBits max_sample_count
;
2028 radv_get_subpass_id(struct radv_cmd_buffer
*cmd_buffer
);
2030 struct radv_render_pass_attachment
{
2033 VkAttachmentLoadOp load_op
;
2034 VkAttachmentLoadOp stencil_load_op
;
2035 VkImageLayout initial_layout
;
2036 VkImageLayout final_layout
;
2038 /* The subpass id in which the attachment will be used first/last. */
2039 uint32_t first_subpass_idx
;
2040 uint32_t last_subpass_idx
;
2043 struct radv_render_pass
{
2044 uint32_t attachment_count
;
2045 uint32_t subpass_count
;
2046 struct radv_subpass_attachment
* subpass_attachments
;
2047 struct radv_render_pass_attachment
* attachments
;
2048 struct radv_subpass_barrier end_barrier
;
2049 struct radv_subpass subpasses
[0];
2052 VkResult
radv_device_init_meta(struct radv_device
*device
);
2053 void radv_device_finish_meta(struct radv_device
*device
);
2055 struct radv_query_pool
{
2056 struct radeon_winsys_bo
*bo
;
2058 uint32_t availability_offset
;
2062 uint32_t pipeline_stats_mask
;
2065 struct radv_semaphore
{
2066 /* use a winsys sem for non-exportable */
2067 struct radeon_winsys_sem
*sem
;
2069 uint32_t temp_syncobj
;
2072 void radv_set_descriptor_set(struct radv_cmd_buffer
*cmd_buffer
,
2073 VkPipelineBindPoint bind_point
,
2074 struct radv_descriptor_set
*set
,
2078 radv_update_descriptor_sets(struct radv_device
*device
,
2079 struct radv_cmd_buffer
*cmd_buffer
,
2080 VkDescriptorSet overrideSet
,
2081 uint32_t descriptorWriteCount
,
2082 const VkWriteDescriptorSet
*pDescriptorWrites
,
2083 uint32_t descriptorCopyCount
,
2084 const VkCopyDescriptorSet
*pDescriptorCopies
);
2087 radv_update_descriptor_set_with_template(struct radv_device
*device
,
2088 struct radv_cmd_buffer
*cmd_buffer
,
2089 struct radv_descriptor_set
*set
,
2090 VkDescriptorUpdateTemplate descriptorUpdateTemplate
,
2093 void radv_meta_push_descriptor_set(struct radv_cmd_buffer
*cmd_buffer
,
2094 VkPipelineBindPoint pipelineBindPoint
,
2095 VkPipelineLayout _layout
,
2097 uint32_t descriptorWriteCount
,
2098 const VkWriteDescriptorSet
*pDescriptorWrites
);
2100 void radv_initialize_dcc(struct radv_cmd_buffer
*cmd_buffer
,
2101 struct radv_image
*image
,
2102 const VkImageSubresourceRange
*range
, uint32_t value
);
2104 void radv_initialize_fmask(struct radv_cmd_buffer
*cmd_buffer
,
2105 struct radv_image
*image
,
2106 const VkImageSubresourceRange
*range
);
2109 struct radeon_winsys_fence
*fence
;
2110 struct wsi_fence
*fence_wsi
;
2113 uint32_t temp_syncobj
;
2116 /* radv_nir_to_llvm.c */
2117 struct radv_shader_variant_info
;
2118 struct radv_nir_compiler_options
;
2120 void radv_compile_gs_copy_shader(struct ac_llvm_compiler
*ac_llvm
,
2121 struct nir_shader
*geom_shader
,
2122 struct radv_shader_binary
**rbinary
,
2123 struct radv_shader_variant_info
*shader_info
,
2124 const struct radv_nir_compiler_options
*option
);
2126 void radv_compile_nir_shader(struct ac_llvm_compiler
*ac_llvm
,
2127 struct radv_shader_binary
**rbinary
,
2128 struct radv_shader_variant_info
*shader_info
,
2129 struct nir_shader
*const *nir
,
2131 const struct radv_nir_compiler_options
*options
);
2133 unsigned radv_nir_get_max_workgroup_size(enum chip_class chip_class
,
2134 const struct nir_shader
*nir
);
2136 /* radv_shader_info.h */
2137 struct radv_shader_info
;
2139 void radv_nir_shader_info_pass(const struct nir_shader
*nir
,
2140 const struct radv_nir_compiler_options
*options
,
2141 struct radv_shader_info
*info
);
2143 void radv_nir_shader_info_init(struct radv_shader_info
*info
);
2145 struct radeon_winsys_sem
;
2147 uint64_t radv_get_current_time(void);
2149 #define RADV_DEFINE_HANDLE_CASTS(__radv_type, __VkType) \
2151 static inline struct __radv_type * \
2152 __radv_type ## _from_handle(__VkType _handle) \
2154 return (struct __radv_type *) _handle; \
2157 static inline __VkType \
2158 __radv_type ## _to_handle(struct __radv_type *_obj) \
2160 return (__VkType) _obj; \
2163 #define RADV_DEFINE_NONDISP_HANDLE_CASTS(__radv_type, __VkType) \
2165 static inline struct __radv_type * \
2166 __radv_type ## _from_handle(__VkType _handle) \
2168 return (struct __radv_type *)(uintptr_t) _handle; \
2171 static inline __VkType \
2172 __radv_type ## _to_handle(struct __radv_type *_obj) \
2174 return (__VkType)(uintptr_t) _obj; \
2177 #define RADV_FROM_HANDLE(__radv_type, __name, __handle) \
2178 struct __radv_type *__name = __radv_type ## _from_handle(__handle)
2180 RADV_DEFINE_HANDLE_CASTS(radv_cmd_buffer
, VkCommandBuffer
)
2181 RADV_DEFINE_HANDLE_CASTS(radv_device
, VkDevice
)
2182 RADV_DEFINE_HANDLE_CASTS(radv_instance
, VkInstance
)
2183 RADV_DEFINE_HANDLE_CASTS(radv_physical_device
, VkPhysicalDevice
)
2184 RADV_DEFINE_HANDLE_CASTS(radv_queue
, VkQueue
)
2186 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_cmd_pool
, VkCommandPool
)
2187 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer
, VkBuffer
)
2188 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer_view
, VkBufferView
)
2189 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_pool
, VkDescriptorPool
)
2190 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set
, VkDescriptorSet
)
2191 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set_layout
, VkDescriptorSetLayout
)
2192 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_update_template
, VkDescriptorUpdateTemplate
)
2193 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_device_memory
, VkDeviceMemory
)
2194 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_fence
, VkFence
)
2195 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_event
, VkEvent
)
2196 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_framebuffer
, VkFramebuffer
)
2197 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image
, VkImage
)
2198 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image_view
, VkImageView
);
2199 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_cache
, VkPipelineCache
)
2200 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline
, VkPipeline
)
2201 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_layout
, VkPipelineLayout
)
2202 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_query_pool
, VkQueryPool
)
2203 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_render_pass
, VkRenderPass
)
2204 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler
, VkSampler
)
2205 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler_ycbcr_conversion
, VkSamplerYcbcrConversion
)
2206 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_shader_module
, VkShaderModule
)
2207 RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_semaphore
, VkSemaphore
)
2209 #endif /* RADV_PRIVATE_H */