~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/amd/vulkan/radv_physical_device.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#endif
33
33
 
34
34
#include "util/disk_cache.h"
 
35
#include "util/hex.h"
35
36
#include "util/u_debug.h"
36
37
#include "radv_debug.h"
37
38
#include "radv_private.h"
45
46
#include "drm-uapi/amdgpu_drm.h"
46
47
#include "winsys/amdgpu/radv_amdgpu_winsys_public.h"
47
48
#endif
 
49
#include "winsys/null/radv_null_winsys_public.h"
48
50
#include "git_sha1.h"
49
 
#include "winsys/null/radv_null_winsys_public.h"
50
51
 
51
52
#ifdef LLVM_AVAILABLE
52
53
#include "ac_llvm_util.h"
53
54
#endif
54
55
 
55
 
bool
56
 
radv_thread_trace_enabled(void)
57
 
{
58
 
   return radv_get_int_debug_option("RADV_THREAD_TRACE", -1) >= 0 ||
59
 
          getenv("RADV_THREAD_TRACE_TRIGGER");
60
 
}
61
 
 
62
56
static bool
63
57
radv_perf_query_supported(const struct radv_physical_device *pdev)
64
58
{
65
59
   /* SQTT / SPM interfere with the register states for perf counters, and
66
60
    * the code has only been tested on GFX10.3 */
67
 
   return pdev->rad_info.gfx_level == GFX10_3 && !radv_thread_trace_enabled();
 
61
   return pdev->rad_info.gfx_level == GFX10_3 && !(pdev->instance->vk.trace_mode & RADV_TRACE_MODE_RGP);
68
62
}
69
63
 
70
64
static bool
71
65
radv_taskmesh_enabled(const struct radv_physical_device *pdevice)
72
66
{
73
67
   return pdevice->use_ngg && !pdevice->use_llvm && pdevice->rad_info.gfx_level >= GFX10_3 &&
74
 
          !(pdevice->instance->debug_flags & RADV_DEBUG_NO_COMPUTE_QUEUE) &&
75
 
          pdevice->rad_info.has_gang_submit;
 
68
          !(pdevice->instance->debug_flags & RADV_DEBUG_NO_COMPUTE_QUEUE) && pdevice->rad_info.has_gang_submit;
76
69
}
77
70
 
78
71
static bool
79
72
radv_vrs_attachment_enabled(const struct radv_physical_device *pdevice)
80
73
{
81
 
   return pdevice->rad_info.gfx_level >= GFX11 ||
82
 
          !(pdevice->instance->debug_flags & RADV_DEBUG_NO_HIZ);
 
74
   return pdevice->rad_info.gfx_level >= GFX11 || !(pdevice->instance->debug_flags & RADV_DEBUG_NO_HIZ);
83
75
}
84
76
 
85
77
static bool
86
78
radv_NV_device_generated_commands_enabled(const struct radv_physical_device *device)
87
79
{
88
 
   return device->rad_info.gfx_level >= GFX7 &&
89
 
          !(device->instance->debug_flags & RADV_DEBUG_NO_IBS) &&
90
 
          driQueryOptionb(&device->instance->dri_options, "radv_dgc");
 
80
   return driQueryOptionb(&device->instance->dri_options, "radv_dgc");
91
81
}
92
82
 
93
83
static bool
103
93
      out[i] = 0;
104
94
 
105
95
   for (unsigned i = 0; i < 2 * length; ++i) {
106
 
      unsigned v =
107
 
         in[i] <= '9' ? in[i] - '0' : (in[i] >= 'a' ? (in[i] - 'a' + 10) : (in[i] - 'A' + 10));
 
96
      unsigned v = in[i] <= '9' ? in[i] - '0' : (in[i] >= 'a' ? (in[i] - 'a' + 10) : (in[i] - 'A' + 10));
108
97
      out[i / 2] |= v << (4 * (1 - i % 2));
109
98
   }
110
99
}
113
102
radv_device_get_cache_uuid(struct radv_physical_device *pdevice, void *uuid)
114
103
{
115
104
   enum radeon_family family = pdevice->rad_info.family;
 
105
   bool conformant_trunc_coord = pdevice->rad_info.conformant_trunc_coord;
116
106
   struct mesa_sha1 ctx;
117
107
   unsigned char sha1[20];
118
108
   unsigned ptr_size = sizeof(void *);
133
123
#endif
134
124
 
135
125
#ifdef LLVM_AVAILABLE
136
 
   if (pdevice->use_llvm &&
137
 
       !disk_cache_get_function_identifier(LLVMInitializeAMDGPUTargetInfo, &ctx))
 
126
   if (pdevice->use_llvm && !disk_cache_get_function_identifier(LLVMInitializeAMDGPUTargetInfo, &ctx))
138
127
      return -1;
139
128
#endif
140
129
 
141
130
   _mesa_sha1_update(&ctx, &family, sizeof(family));
 
131
   _mesa_sha1_update(&ctx, &conformant_trunc_coord, sizeof(conformant_trunc_coord));
142
132
   _mesa_sha1_update(&ctx, &ptr_size, sizeof(ptr_size));
143
133
   _mesa_sha1_final(&ctx, sha1);
144
134
 
153
143
}
154
144
 
155
145
static void
156
 
radv_get_device_uuid(struct radeon_info *info, void *uuid)
 
146
radv_get_device_uuid(const struct radeon_info *info, void *uuid)
157
147
{
158
148
   ac_compute_device_uuid(info, uuid, VK_UUID_SIZE);
159
149
}
175
165
   }
176
166
 
177
167
   if (pdevice->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE) {
178
 
      if (pdevice->rad_info.ip[AMD_IP_VCN_DEC].num_queues > 0) {
179
 
         pdevice->vk_queue_to_radv[idx] = RADV_QUEUE_VIDEO_DEC;
180
 
         idx++;
181
 
      }
182
 
 
183
 
      if (radv_has_uvd(pdevice)) {
 
168
      if (pdevice->rad_info.ip[pdevice->vid_decode_ip].num_queues > 0) {
184
169
         pdevice->vk_queue_to_radv[idx] = RADV_QUEUE_VIDEO_DEC;
185
170
         idx++;
186
171
      }
207
192
static uint64_t
208
193
radv_get_visible_vram_size(struct radv_physical_device *device)
209
194
{
210
 
   return MIN2(radv_get_adjusted_vram_size(device),
211
 
               (uint64_t)device->rad_info.vram_vis_size_kb * 1024);
 
195
   return MIN2(radv_get_adjusted_vram_size(device), (uint64_t)device->rad_info.vram_vis_size_kb * 1024);
212
196
}
213
197
 
214
198
static uint64_t
299
283
      device->memory_domains[type_count] = RADEON_DOMAIN_GTT;
300
284
      device->memory_flags[type_count] = RADEON_FLAG_GTT_WC | RADEON_FLAG_CPU_ACCESS;
301
285
      device->memory_properties.memoryTypes[type_count++] = (VkMemoryType){
302
 
         .propertyFlags =
303
 
            VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
 
286
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
304
287
         .heapIndex = gart_index,
305
288
      };
306
289
   }
308
291
      device->memory_domains[type_count] = RADEON_DOMAIN_VRAM;
309
292
      device->memory_flags[type_count] = RADEON_FLAG_CPU_ACCESS;
310
293
      device->memory_properties.memoryTypes[type_count++] = (VkMemoryType){
311
 
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
312
 
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
294
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
313
295
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
314
296
         .heapIndex = visible_vram_index,
315
297
      };
317
299
      device->memory_domains[type_count] = RADEON_DOMAIN_VRAM;
318
300
      device->memory_flags[type_count] = RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_32BIT;
319
301
      device->memory_properties.memoryTypes[type_count++] = (VkMemoryType){
320
 
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
321
 
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
302
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
322
303
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
323
304
         .heapIndex = visible_vram_index,
324
305
      };
328
309
      device->memory_domains[type_count] = RADEON_DOMAIN_GTT;
329
310
      device->memory_flags[type_count] = RADEON_FLAG_CPU_ACCESS;
330
311
      device->memory_properties.memoryTypes[type_count++] = (VkMemoryType){
331
 
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
332
 
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
 
312
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
 
313
                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
333
314
         .heapIndex = gart_index,
334
315
      };
335
316
 
336
317
      device->memory_domains[type_count] = RADEON_DOMAIN_GTT;
337
318
      device->memory_flags[type_count] = RADEON_FLAG_CPU_ACCESS | RADEON_FLAG_32BIT;
338
319
      device->memory_properties.memoryTypes[type_count++] = (VkMemoryType){
339
 
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
340
 
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
 
320
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
 
321
                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
341
322
         .heapIndex = gart_index,
342
323
      };
343
324
   }
347
328
      for (int i = 0; i < device->memory_properties.memoryTypeCount; i++) {
348
329
         VkMemoryType mem_type = device->memory_properties.memoryTypes[i];
349
330
 
350
 
         if (((mem_type.propertyFlags &
351
 
               (VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) ||
 
331
         if (((mem_type.propertyFlags & (VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) ||
352
332
              mem_type.propertyFlags == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) &&
353
333
             !(device->memory_flags[i] & RADEON_FLAG_32BIT)) {
354
334
 
355
 
            VkMemoryPropertyFlags property_flags = mem_type.propertyFlags |
356
 
                                                   VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD |
 
335
            VkMemoryPropertyFlags property_flags = mem_type.propertyFlags | VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD |
357
336
                                                   VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD;
358
337
 
359
338
            device->memory_domains[type_count] = device->memory_domains[i];
374
353
}
375
354
 
376
355
uint32_t
377
 
radv_find_memory_index(struct radv_physical_device *pdevice, VkMemoryPropertyFlags flags)
 
356
radv_find_memory_index(const struct radv_physical_device *pdevice, VkMemoryPropertyFlags flags)
378
357
{
379
 
   VkPhysicalDeviceMemoryProperties *mem_properties = &pdevice->memory_properties;
 
358
   const VkPhysicalDeviceMemoryProperties *mem_properties = &pdevice->memory_properties;
380
359
   for (uint32_t i = 0; i < mem_properties->memoryTypeCount; ++i) {
381
360
      if (mem_properties->memoryTypes[i].propertyFlags == flags) {
382
361
         return i;
386
365
}
387
366
 
388
367
static void
389
 
radv_get_binning_settings(const struct radv_physical_device *pdevice,
390
 
                          struct radv_binning_settings *settings)
 
368
radv_get_binning_settings(const struct radv_physical_device *pdevice, struct radv_binning_settings *settings)
391
369
{
392
370
   settings->context_states_per_bin = 1;
393
371
   settings->persistent_states_per_bin = 1;
421
399
      .KHR_external_semaphore = true,
422
400
      .KHR_external_semaphore_fd = true,
423
401
      .KHR_format_feature_flags2 = true,
 
402
      .KHR_fragment_shader_barycentric = device->rad_info.gfx_level >= GFX10_3,
424
403
      .KHR_fragment_shading_rate = device->rad_info.gfx_level >= GFX10_3,
425
404
      .KHR_get_memory_requirements2 = true,
426
405
      .KHR_global_priority = true,
477
456
      .KHR_variable_pointers = true,
478
457
      .KHR_video_queue = !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
479
458
      .KHR_video_decode_queue = !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
480
 
      .KHR_video_decode_h264 =
481
 
         VIDEO_CODEC_H264DEC && !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
482
 
      .KHR_video_decode_h265 =
483
 
         VIDEO_CODEC_H265DEC && !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
 
459
      .KHR_video_decode_h264 = VIDEO_CODEC_H264DEC && !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
 
460
      .KHR_video_decode_h265 = VIDEO_CODEC_H265DEC && !!(device->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE),
484
461
      .KHR_vulkan_memory_model = true,
485
462
      .KHR_workgroup_memory_explicit_layout = true,
486
463
      .KHR_zero_initialize_workgroup_memory = true,
487
464
      .EXT_4444_formats = true,
 
465
      .EXT_attachment_feedback_loop_dynamic_state = true,
488
466
      .EXT_attachment_feedback_loop_layout = true,
489
467
      .EXT_border_color_swizzle = device->rad_info.gfx_level >= GFX10,
490
468
      .EXT_buffer_device_address = true,
491
 
      .EXT_calibrated_timestamps = RADV_SUPPORT_CALIBRATED_TIMESTAMPS,
 
469
      .EXT_calibrated_timestamps = RADV_SUPPORT_CALIBRATED_TIMESTAMPS &&
 
470
                                   !(device->rad_info.family == CHIP_RAVEN || device->rad_info.family == CHIP_RAVEN2),
492
471
      .EXT_color_write_enable = true,
493
472
      .EXT_conditional_rendering = true,
494
473
      .EXT_conservative_rasterization = device->rad_info.gfx_level >= GFX9,
495
474
      .EXT_custom_border_color = true,
496
 
      .EXT_debug_marker = radv_thread_trace_enabled(),
 
475
      .EXT_debug_marker = device->instance->vk.trace_mode & RADV_TRACE_MODE_RGP,
 
476
      .EXT_depth_bias_control = true,
497
477
      .EXT_depth_clip_control = true,
498
478
      .EXT_depth_clip_enable = true,
499
479
      .EXT_depth_range_unrestricted = true,
503
483
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
504
484
      .EXT_display_control = true,
505
485
#endif
 
486
      .EXT_dynamic_rendering_unused_attachments = true,
506
487
      .EXT_extended_dynamic_state = true,
507
488
      .EXT_extended_dynamic_state2 = true,
508
489
      .EXT_extended_dynamic_state3 = true,
509
490
      .EXT_external_memory_dma_buf = true,
510
491
      .EXT_external_memory_host = device->rad_info.has_userptr,
 
492
      .EXT_fragment_shader_interlock = radv_has_pops(device),
511
493
      .EXT_global_priority = true,
512
494
      .EXT_global_priority_query = true,
513
 
      .EXT_graphics_pipeline_library =
514
 
         !device->use_llvm && !(device->instance->debug_flags & RADV_DEBUG_NO_GPL),
 
495
      .EXT_graphics_pipeline_library = !device->use_llvm && !(device->instance->debug_flags & RADV_DEBUG_NO_GPL),
515
496
      .EXT_host_query_reset = true,
516
497
      .EXT_image_2d_view_of_3d = true,
517
498
      .EXT_image_drm_format_modifier = device->rad_info.gfx_level >= GFX9,
535
516
      .EXT_pipeline_creation_cache_control = true,
536
517
      .EXT_pipeline_creation_feedback = true,
537
518
      .EXT_pipeline_library_group_handles = radv_enable_rt(device, true),
 
519
      .EXT_pipeline_robustness = !device->use_llvm,
538
520
      .EXT_post_depth_coverage = device->rad_info.gfx_level >= GFX10,
539
521
      .EXT_primitive_topology_list_restart = true,
540
522
      .EXT_primitives_generated_query = true,
547
529
      .EXT_scalar_block_layout = device->rad_info.gfx_level >= GFX7,
548
530
      .EXT_separate_stencil_usage = true,
549
531
      .EXT_shader_atomic_float = true,
550
 
#ifdef LLVM_AVAILABLE
551
 
      .EXT_shader_atomic_float2 = !device->use_llvm || LLVM_VERSION_MAJOR >= 14,
552
 
#else
553
532
      .EXT_shader_atomic_float2 = true,
554
 
#endif
555
533
      .EXT_shader_demote_to_helper_invocation = true,
556
534
      .EXT_shader_image_atomic_int64 = true,
557
535
      .EXT_shader_module_identifier = true,
564
542
      .EXT_swapchain_maintenance1 = true,
565
543
#endif
566
544
      .EXT_texel_buffer_alignment = true,
 
545
      .EXT_tooling_info = true,
567
546
      .EXT_transform_feedback = true,
568
547
      .EXT_vertex_attribute_divisor = true,
569
 
      .EXT_vertex_input_dynamic_state =
570
 
         !device->use_llvm && !radv_NV_device_generated_commands_enabled(device),
 
548
      .EXT_vertex_input_dynamic_state = !device->use_llvm && !radv_NV_device_generated_commands_enabled(device),
571
549
      .EXT_ycbcr_image_arrays = true,
572
550
      .AMD_buffer_marker = true,
573
551
      .AMD_device_coherent_memory = true,
601
579
       * using it.
602
580
       */
603
581
      .VALVE_descriptor_set_host_mapping =
604
 
         device->vk.instance->app_info.engine_name &&
605
 
         strcmp(device->vk.instance->app_info.engine_name, "vkd3d") == 0,
 
582
         device->vk.instance->app_info.engine_name && strcmp(device->vk.instance->app_info.engine_name, "vkd3d") == 0,
606
583
      .VALVE_mutable_descriptor_type = true,
607
584
   };
608
585
}
609
586
 
610
 
VKAPI_ATTR void VKAPI_CALL
611
 
radv_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
 
587
static void
 
588
radv_physical_device_get_features(const struct radv_physical_device *pdevice, struct vk_features *features)
612
589
{
613
 
   RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
614
 
   memset(pFeatures, 0, sizeof(*pFeatures));
 
590
   bool taskmesh_en = radv_taskmesh_enabled(pdevice);
 
591
   bool has_perf_query = radv_perf_query_supported(pdevice);
 
592
   bool has_shader_image_float_minmax = pdevice->rad_info.gfx_level != GFX8 && pdevice->rad_info.gfx_level != GFX9 &&
 
593
                                        pdevice->rad_info.gfx_level != GFX11;
 
594
   bool has_fragment_shader_interlock = radv_has_pops(pdevice);
615
595
 
616
 
   *pFeatures = (VkPhysicalDeviceFeatures){
 
596
   *features = (struct vk_features){
 
597
      /* Vulkan 1.0 */
617
598
      .robustBufferAccess = true,
618
599
      .fullDrawIndexUint32 = true,
619
600
      .imageCubeArray = true,
665
646
      .shaderResourceMinLod = true,
666
647
      .shaderResourceResidency = true,
667
648
      .inheritedQueries = true,
668
 
   };
669
 
}
670
 
 
671
 
static void
672
 
radv_get_physical_device_features_1_1(struct radv_physical_device *pdevice,
673
 
                                      VkPhysicalDeviceVulkan11Features *f)
674
 
{
675
 
   assert(f->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES);
676
 
 
677
 
   f->storageBuffer16BitAccess = true;
678
 
   f->uniformAndStorageBuffer16BitAccess = true;
679
 
   f->storagePushConstant16 = true;
680
 
   f->storageInputOutput16 = pdevice->rad_info.has_packed_math_16bit;
681
 
   f->multiview = true;
682
 
   f->multiviewGeometryShader = true;
683
 
   f->multiviewTessellationShader = true;
684
 
   f->variablePointersStorageBuffer = true;
685
 
   f->variablePointers = true;
686
 
   f->protectedMemory = false;
687
 
   f->samplerYcbcrConversion = true;
688
 
   f->shaderDrawParameters = true;
689
 
}
690
 
 
691
 
static void
692
 
radv_get_physical_device_features_1_2(struct radv_physical_device *pdevice,
693
 
                                      VkPhysicalDeviceVulkan12Features *f)
694
 
{
695
 
   assert(f->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES);
696
 
 
697
 
   f->samplerMirrorClampToEdge = true;
698
 
   f->drawIndirectCount = true;
699
 
   f->storageBuffer8BitAccess = true;
700
 
   f->uniformAndStorageBuffer8BitAccess = true;
701
 
   f->storagePushConstant8 = true;
702
 
   f->shaderBufferInt64Atomics = true;
703
 
   f->shaderSharedInt64Atomics = true;
704
 
   f->shaderFloat16 = pdevice->rad_info.has_packed_math_16bit;
705
 
   f->shaderInt8 = true;
706
 
 
707
 
   f->descriptorIndexing = true;
708
 
   f->shaderInputAttachmentArrayDynamicIndexing = true;
709
 
   f->shaderUniformTexelBufferArrayDynamicIndexing = true;
710
 
   f->shaderStorageTexelBufferArrayDynamicIndexing = true;
711
 
   f->shaderUniformBufferArrayNonUniformIndexing = true;
712
 
   f->shaderSampledImageArrayNonUniformIndexing = true;
713
 
   f->shaderStorageBufferArrayNonUniformIndexing = true;
714
 
   f->shaderStorageImageArrayNonUniformIndexing = true;
715
 
   f->shaderInputAttachmentArrayNonUniformIndexing = true;
716
 
   f->shaderUniformTexelBufferArrayNonUniformIndexing = true;
717
 
   f->shaderStorageTexelBufferArrayNonUniformIndexing = true;
718
 
   f->descriptorBindingUniformBufferUpdateAfterBind = true;
719
 
   f->descriptorBindingSampledImageUpdateAfterBind = true;
720
 
   f->descriptorBindingStorageImageUpdateAfterBind = true;
721
 
   f->descriptorBindingStorageBufferUpdateAfterBind = true;
722
 
   f->descriptorBindingUniformTexelBufferUpdateAfterBind = true;
723
 
   f->descriptorBindingStorageTexelBufferUpdateAfterBind = true;
724
 
   f->descriptorBindingUpdateUnusedWhilePending = true;
725
 
   f->descriptorBindingPartiallyBound = true;
726
 
   f->descriptorBindingVariableDescriptorCount = true;
727
 
   f->runtimeDescriptorArray = true;
728
 
 
729
 
   f->samplerFilterMinmax = true;
730
 
   f->scalarBlockLayout = pdevice->rad_info.gfx_level >= GFX7;
731
 
   f->imagelessFramebuffer = true;
732
 
   f->uniformBufferStandardLayout = true;
733
 
   f->shaderSubgroupExtendedTypes = true;
734
 
   f->separateDepthStencilLayouts = true;
735
 
   f->hostQueryReset = true;
736
 
   f->timelineSemaphore = true, f->bufferDeviceAddress = true;
737
 
   f->bufferDeviceAddressCaptureReplay = true;
738
 
   f->bufferDeviceAddressMultiDevice = false;
739
 
   f->vulkanMemoryModel = true;
740
 
   f->vulkanMemoryModelDeviceScope = true;
741
 
   f->vulkanMemoryModelAvailabilityVisibilityChains = false;
742
 
   f->shaderOutputViewportIndex = true;
743
 
   f->shaderOutputLayer = true;
744
 
   f->subgroupBroadcastDynamicId = true;
745
 
}
746
 
 
747
 
static void
748
 
radv_get_physical_device_features_1_3(struct radv_physical_device *pdevice,
749
 
                                      VkPhysicalDeviceVulkan13Features *f)
750
 
{
751
 
   assert(f->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES);
752
 
 
753
 
   f->robustImageAccess = true;
754
 
   f->inlineUniformBlock = true;
755
 
   f->descriptorBindingInlineUniformBlockUpdateAfterBind = true;
756
 
   f->pipelineCreationCacheControl = true;
757
 
   f->privateData = true;
758
 
   f->shaderDemoteToHelperInvocation = true;
759
 
   f->shaderTerminateInvocation = true;
760
 
   f->subgroupSizeControl = true;
761
 
   f->computeFullSubgroups = true;
762
 
   f->synchronization2 = true;
763
 
   f->textureCompressionASTC_HDR = false;
764
 
   f->shaderZeroInitializeWorkgroupMemory = true;
765
 
   f->dynamicRendering = true;
766
 
   f->shaderIntegerDotProduct = true;
767
 
   f->maintenance4 = true;
768
 
}
769
 
 
770
 
VKAPI_ATTR void VKAPI_CALL
771
 
radv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
772
 
                                VkPhysicalDeviceFeatures2 *pFeatures)
773
 
{
774
 
   RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
775
 
   radv_GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features);
776
 
 
777
 
   VkPhysicalDeviceVulkan11Features core_1_1 = {
778
 
      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES,
779
 
   };
780
 
   radv_get_physical_device_features_1_1(pdevice, &core_1_1);
781
 
 
782
 
   VkPhysicalDeviceVulkan12Features core_1_2 = {
783
 
      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
784
 
   };
785
 
   radv_get_physical_device_features_1_2(pdevice, &core_1_2);
786
 
 
787
 
   VkPhysicalDeviceVulkan13Features core_1_3 = {
788
 
      .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES,
789
 
   };
790
 
   radv_get_physical_device_features_1_3(pdevice, &core_1_3);
791
 
 
792
 
#define CORE_FEATURE(major, minor, feature) features->feature = core_##major##_##minor.feature
793
 
 
794
 
   vk_foreach_struct(ext, pFeatures->pNext)
795
 
   {
796
 
      if (vk_get_physical_device_core_1_1_feature_ext(ext, &core_1_1))
797
 
         continue;
798
 
      if (vk_get_physical_device_core_1_2_feature_ext(ext, &core_1_2))
799
 
         continue;
800
 
      if (vk_get_physical_device_core_1_3_feature_ext(ext, &core_1_3))
801
 
         continue;
802
 
 
803
 
      switch (ext->sType) {
804
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT: {
805
 
         VkPhysicalDeviceConditionalRenderingFeaturesEXT *features =
806
 
            (VkPhysicalDeviceConditionalRenderingFeaturesEXT *)ext;
807
 
         features->conditionalRendering = true;
808
 
         features->inheritedConditionalRendering = false;
809
 
         break;
810
 
      }
811
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT: {
812
 
         VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *features =
813
 
            (VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT *)ext;
814
 
         features->vertexAttributeInstanceRateDivisor = true;
815
 
         features->vertexAttributeInstanceRateZeroDivisor = true;
816
 
         break;
817
 
      }
818
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT: {
819
 
         VkPhysicalDeviceTransformFeedbackFeaturesEXT *features =
820
 
            (VkPhysicalDeviceTransformFeedbackFeaturesEXT *)ext;
821
 
         features->transformFeedback = true;
822
 
         features->geometryStreams = true;
823
 
         break;
824
 
      }
825
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES: {
826
 
         VkPhysicalDeviceScalarBlockLayoutFeatures *features =
827
 
            (VkPhysicalDeviceScalarBlockLayoutFeatures *)ext;
828
 
         CORE_FEATURE(1, 2, scalarBlockLayout);
829
 
         break;
830
 
      }
831
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT: {
832
 
         VkPhysicalDeviceMemoryPriorityFeaturesEXT *features =
833
 
            (VkPhysicalDeviceMemoryPriorityFeaturesEXT *)ext;
834
 
         features->memoryPriority = true;
835
 
         break;
836
 
      }
837
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT: {
838
 
         VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *features =
839
 
            (VkPhysicalDeviceBufferDeviceAddressFeaturesEXT *)ext;
840
 
         CORE_FEATURE(1, 2, bufferDeviceAddress);
841
 
         CORE_FEATURE(1, 2, bufferDeviceAddressCaptureReplay);
842
 
         CORE_FEATURE(1, 2, bufferDeviceAddressMultiDevice);
843
 
         break;
844
 
      }
845
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT: {
846
 
         VkPhysicalDeviceDepthClipEnableFeaturesEXT *features =
847
 
            (VkPhysicalDeviceDepthClipEnableFeaturesEXT *)ext;
848
 
         features->depthClipEnable = true;
849
 
         break;
850
 
      }
851
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV: {
852
 
         VkPhysicalDeviceComputeShaderDerivativesFeaturesNV *features =
853
 
            (VkPhysicalDeviceComputeShaderDerivativesFeaturesNV *)ext;
854
 
         features->computeDerivativeGroupQuads = false;
855
 
         features->computeDerivativeGroupLinear = true;
856
 
         break;
857
 
      }
858
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT: {
859
 
         VkPhysicalDeviceYcbcrImageArraysFeaturesEXT *features =
860
 
            (VkPhysicalDeviceYcbcrImageArraysFeaturesEXT *)ext;
861
 
         features->ycbcrImageArrays = true;
862
 
         break;
863
 
      }
864
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT: {
865
 
         VkPhysicalDeviceIndexTypeUint8FeaturesEXT *features =
866
 
            (VkPhysicalDeviceIndexTypeUint8FeaturesEXT *)ext;
867
 
         features->indexTypeUint8 = pdevice->rad_info.gfx_level >= GFX8;
868
 
         break;
869
 
      }
870
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR: {
871
 
         VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR *features =
872
 
            (VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR *)ext;
873
 
         features->pipelineExecutableInfo = true;
874
 
         break;
875
 
      }
876
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR: {
877
 
         VkPhysicalDeviceShaderClockFeaturesKHR *features =
878
 
            (VkPhysicalDeviceShaderClockFeaturesKHR *)ext;
879
 
         features->shaderSubgroupClock = true;
880
 
         features->shaderDeviceClock = pdevice->rad_info.gfx_level >= GFX8;
881
 
         break;
882
 
      }
883
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT: {
884
 
         VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT *features =
885
 
            (VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT *)ext;
886
 
         features->texelBufferAlignment = true;
887
 
         break;
888
 
      }
889
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD: {
890
 
         VkPhysicalDeviceCoherentMemoryFeaturesAMD *features =
891
 
            (VkPhysicalDeviceCoherentMemoryFeaturesAMD *)ext;
892
 
         features->deviceCoherentMemory = pdevice->rad_info.has_l2_uncached;
893
 
         break;
894
 
      }
895
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT: {
896
 
         VkPhysicalDeviceLineRasterizationFeaturesEXT *features =
897
 
            (VkPhysicalDeviceLineRasterizationFeaturesEXT *)ext;
898
 
         features->rectangularLines = true;
899
 
         features->bresenhamLines = true;
900
 
         features->smoothLines = false;
901
 
         features->stippledRectangularLines = false;
902
 
         /* FIXME: Some stippled Bresenham CTS fails on Vega10
903
 
          * but work on Raven.
904
 
          */
905
 
         features->stippledBresenhamLines = pdevice->rad_info.gfx_level != GFX9;
906
 
         features->stippledSmoothLines = false;
907
 
         break;
908
 
      }
909
 
      case VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD: {
910
 
         VkDeviceMemoryOverallocationCreateInfoAMD *features =
911
 
            (VkDeviceMemoryOverallocationCreateInfoAMD *)ext;
912
 
         features->overallocationBehavior = true;
913
 
         break;
914
 
      }
915
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT: {
916
 
         VkPhysicalDeviceRobustness2FeaturesEXT *features =
917
 
            (VkPhysicalDeviceRobustness2FeaturesEXT *)ext;
918
 
         features->robustBufferAccess2 = true;
919
 
         features->robustImageAccess2 = true;
920
 
         features->nullDescriptor = true;
921
 
         break;
922
 
      }
923
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT: {
924
 
         VkPhysicalDeviceCustomBorderColorFeaturesEXT *features =
925
 
            (VkPhysicalDeviceCustomBorderColorFeaturesEXT *)ext;
926
 
         features->customBorderColors = true;
927
 
         features->customBorderColorWithoutFormat = true;
928
 
         break;
929
 
      }
930
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT: {
931
 
         VkPhysicalDeviceExtendedDynamicStateFeaturesEXT *features =
932
 
            (VkPhysicalDeviceExtendedDynamicStateFeaturesEXT *)ext;
933
 
         features->extendedDynamicState = true;
934
 
         break;
935
 
      }
936
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT: {
937
 
         VkPhysicalDeviceShaderAtomicFloatFeaturesEXT *features =
938
 
            (VkPhysicalDeviceShaderAtomicFloatFeaturesEXT *)ext;
939
 
         features->shaderBufferFloat32Atomics = true;
940
 
         features->shaderBufferFloat32AtomicAdd = pdevice->rad_info.gfx_level >= GFX11;
941
 
         features->shaderBufferFloat64Atomics = true;
942
 
         features->shaderBufferFloat64AtomicAdd = false;
943
 
         features->shaderSharedFloat32Atomics = true;
944
 
         features->shaderSharedFloat32AtomicAdd = pdevice->rad_info.gfx_level >= GFX8;
945
 
         features->shaderSharedFloat64Atomics = true;
946
 
         features->shaderSharedFloat64AtomicAdd = false;
947
 
         features->shaderImageFloat32Atomics = true;
948
 
         features->shaderImageFloat32AtomicAdd = false;
949
 
         features->sparseImageFloat32Atomics = true;
950
 
         features->sparseImageFloat32AtomicAdd = false;
951
 
         break;
952
 
      }
953
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT: {
954
 
         VkPhysicalDevice4444FormatsFeaturesEXT *features =
955
 
            (VkPhysicalDevice4444FormatsFeaturesEXT *)ext;
956
 
         features->formatA4R4G4B4 = true;
957
 
         features->formatA4B4G4R4 = true;
958
 
         break;
959
 
      }
960
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT: {
961
 
         VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT *features =
962
 
            (VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT *)ext;
963
 
         features->shaderImageInt64Atomics = true;
964
 
         features->sparseImageInt64Atomics = true;
965
 
         break;
966
 
      }
967
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT: {
968
 
         VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT *features =
969
 
            (VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT *)ext;
970
 
         features->mutableDescriptorType = true;
971
 
         break;
972
 
      }
973
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR: {
974
 
         VkPhysicalDeviceFragmentShadingRateFeaturesKHR *features =
975
 
            (VkPhysicalDeviceFragmentShadingRateFeaturesKHR *)ext;
976
 
         features->pipelineFragmentShadingRate = true;
977
 
         features->primitiveFragmentShadingRate = true;
978
 
         features->attachmentFragmentShadingRate = radv_vrs_attachment_enabled(pdevice);
979
 
         break;
980
 
      }
981
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR: {
982
 
         VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR *features =
983
 
            (VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR *)ext;
984
 
         features->workgroupMemoryExplicitLayout = true;
985
 
         features->workgroupMemoryExplicitLayoutScalarBlockLayout = true;
986
 
         features->workgroupMemoryExplicitLayout8BitAccess = true;
987
 
         features->workgroupMemoryExplicitLayout16BitAccess = true;
988
 
         break;
989
 
      }
990
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT: {
991
 
         VkPhysicalDeviceProvokingVertexFeaturesEXT *features =
992
 
            (VkPhysicalDeviceProvokingVertexFeaturesEXT *)ext;
993
 
         features->provokingVertexLast = true;
994
 
         features->transformFeedbackPreservesProvokingVertex = true;
995
 
         break;
996
 
      }
997
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT: {
998
 
         VkPhysicalDeviceExtendedDynamicState2FeaturesEXT *features =
999
 
            (VkPhysicalDeviceExtendedDynamicState2FeaturesEXT *)ext;
1000
 
         features->extendedDynamicState2 = true;
1001
 
         features->extendedDynamicState2LogicOp = true;
1002
 
         features->extendedDynamicState2PatchControlPoints = true;
1003
 
         break;
1004
 
      }
1005
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR: {
1006
 
         VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR *features =
1007
 
            (VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR *)ext;
1008
 
         features->globalPriorityQuery = true;
1009
 
         break;
1010
 
      }
1011
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR: {
1012
 
         VkPhysicalDeviceAccelerationStructureFeaturesKHR *features =
1013
 
            (VkPhysicalDeviceAccelerationStructureFeaturesKHR *)ext;
1014
 
         features->accelerationStructure = true;
1015
 
         features->accelerationStructureCaptureReplay = true;
1016
 
         features->accelerationStructureIndirectBuild = false;
1017
 
         features->accelerationStructureHostCommands = false;
1018
 
         features->descriptorBindingAccelerationStructureUpdateAfterBind = true;
1019
 
         break;
1020
 
      }
1021
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR: {
1022
 
         VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR *features =
1023
 
            (VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR *)ext;
1024
 
         features->shaderSubgroupUniformControlFlow = true;
1025
 
         break;
1026
 
      }
1027
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT: {
1028
 
         VkPhysicalDeviceMultiDrawFeaturesEXT *features =
1029
 
            (VkPhysicalDeviceMultiDrawFeaturesEXT *)ext;
1030
 
         features->multiDraw = true;
1031
 
         break;
1032
 
      }
1033
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT: {
1034
 
         VkPhysicalDeviceColorWriteEnableFeaturesEXT *features =
1035
 
            (VkPhysicalDeviceColorWriteEnableFeaturesEXT *)ext;
1036
 
         features->colorWriteEnable = true;
1037
 
         break;
1038
 
      }
1039
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT: {
1040
 
         VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT *features =
1041
 
            (VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT *)ext;
1042
 
         bool has_shader_image_float_minmax = pdevice->rad_info.gfx_level != GFX8 &&
1043
 
                                              pdevice->rad_info.gfx_level != GFX9 &&
1044
 
                                              pdevice->rad_info.gfx_level != GFX11;
1045
 
         features->shaderBufferFloat16Atomics = false;
1046
 
         features->shaderBufferFloat16AtomicAdd = false;
1047
 
         features->shaderBufferFloat16AtomicMinMax = false;
1048
 
         features->shaderBufferFloat32AtomicMinMax =
1049
 
            radv_has_shader_buffer_float_minmax(pdevice, 32);
1050
 
         features->shaderBufferFloat64AtomicMinMax =
1051
 
            radv_has_shader_buffer_float_minmax(pdevice, 64);
1052
 
         features->shaderSharedFloat16Atomics = false;
1053
 
         features->shaderSharedFloat16AtomicAdd = false;
1054
 
         features->shaderSharedFloat16AtomicMinMax = false;
1055
 
         features->shaderSharedFloat32AtomicMinMax = true;
1056
 
         features->shaderSharedFloat64AtomicMinMax = true;
1057
 
         features->shaderImageFloat32AtomicMinMax = has_shader_image_float_minmax;
1058
 
         features->sparseImageFloat32AtomicMinMax = has_shader_image_float_minmax;
1059
 
         break;
1060
 
      }
1061
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR: {
1062
 
         VkPhysicalDevicePresentIdFeaturesKHR *features =
1063
 
            (VkPhysicalDevicePresentIdFeaturesKHR *)ext;
1064
 
         features->presentId = pdevice->vk.supported_extensions.KHR_present_id;
1065
 
         break;
1066
 
      }
1067
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR: {
1068
 
         VkPhysicalDevicePresentWaitFeaturesKHR *features =
1069
 
            (VkPhysicalDevicePresentWaitFeaturesKHR *)ext;
1070
 
         features->presentWait = pdevice->vk.supported_extensions.KHR_present_wait;
1071
 
         break;
1072
 
      }
1073
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT: {
1074
 
         VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT *features =
1075
 
            (VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT *)ext;
1076
 
         features->primitiveTopologyListRestart = true;
1077
 
         features->primitiveTopologyPatchListRestart = false;
1078
 
         break;
1079
 
      }
1080
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR: {
1081
 
         VkPhysicalDeviceRayQueryFeaturesKHR *features = (VkPhysicalDeviceRayQueryFeaturesKHR *)ext;
1082
 
         features->rayQuery = true;
1083
 
         break;
1084
 
      }
1085
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT: {
1086
 
         VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT *features =
1087
 
            (VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT *)ext;
1088
 
         features->pipelineLibraryGroupHandles = true;
1089
 
         break;
1090
 
      }
1091
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR: {
1092
 
         VkPhysicalDeviceRayTracingPipelineFeaturesKHR *features =
1093
 
            (VkPhysicalDeviceRayTracingPipelineFeaturesKHR *)ext;
1094
 
         features->rayTracingPipeline = true;
1095
 
         features->rayTracingPipelineShaderGroupHandleCaptureReplay = true;
1096
 
         features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed = false;
1097
 
         features->rayTracingPipelineTraceRaysIndirect = true;
1098
 
         features->rayTraversalPrimitiveCulling = true;
1099
 
         break;
1100
 
      }
1101
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR: {
1102
 
         VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR *features =
1103
 
            (VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR *)ext;
1104
 
         features->rayTracingMaintenance1 = true;
1105
 
         features->rayTracingPipelineTraceRaysIndirect2 = radv_enable_rt(pdevice, true);
1106
 
         break;
1107
 
      }
1108
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES: {
1109
 
         VkPhysicalDeviceMaintenance4Features *features =
1110
 
            (VkPhysicalDeviceMaintenance4Features *)ext;
1111
 
         features->maintenance4 = true;
1112
 
         break;
1113
 
      }
1114
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT: {
1115
 
         VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT *features =
1116
 
            (VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT *)ext;
1117
 
         features->vertexInputDynamicState = true;
1118
 
         break;
1119
 
      }
1120
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT: {
1121
 
         VkPhysicalDeviceImageViewMinLodFeaturesEXT *features =
1122
 
            (VkPhysicalDeviceImageViewMinLodFeaturesEXT *)ext;
1123
 
         features->minLod = true;
1124
 
         break;
1125
 
      }
1126
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES: {
1127
 
         VkPhysicalDeviceSynchronization2Features *features =
1128
 
            (VkPhysicalDeviceSynchronization2Features *)ext;
1129
 
         features->synchronization2 = true;
1130
 
         break;
1131
 
      }
1132
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES: {
1133
 
         VkPhysicalDeviceDynamicRenderingFeatures *features =
1134
 
            (VkPhysicalDeviceDynamicRenderingFeatures *)ext;
1135
 
         features->dynamicRendering = true;
1136
 
         break;
1137
 
      }
1138
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT: {
1139
 
         VkPhysicalDeviceMeshShaderFeaturesEXT *features =
1140
 
            (VkPhysicalDeviceMeshShaderFeaturesEXT *)ext;
1141
 
         bool taskmesh_en = radv_taskmesh_enabled(pdevice);
1142
 
         features->meshShader = taskmesh_en;
1143
 
         features->taskShader = taskmesh_en;
1144
 
         features->multiviewMeshShader = taskmesh_en;
1145
 
         features->primitiveFragmentShadingRateMeshShader = taskmesh_en;
1146
 
         features->meshShaderQueries = false;
1147
 
         break;
1148
 
      }
1149
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES: {
1150
 
         VkPhysicalDeviceTextureCompressionASTCHDRFeatures *features =
1151
 
            (VkPhysicalDeviceTextureCompressionASTCHDRFeatures *)ext;
1152
 
         features->textureCompressionASTC_HDR = false;
1153
 
         break;
1154
 
      }
1155
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE: {
1156
 
         VkPhysicalDeviceDescriptorSetHostMappingFeaturesVALVE *features =
1157
 
            (VkPhysicalDeviceDescriptorSetHostMappingFeaturesVALVE *)ext;
1158
 
         features->descriptorSetHostMapping = true;
1159
 
         break;
1160
 
      }
1161
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT: {
1162
 
         VkPhysicalDeviceDepthClipControlFeaturesEXT *features =
1163
 
            (VkPhysicalDeviceDepthClipControlFeaturesEXT *)ext;
1164
 
         features->depthClipControl = true;
1165
 
         break;
1166
 
      }
1167
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT: {
1168
 
         VkPhysicalDeviceImage2DViewOf3DFeaturesEXT *features =
1169
 
            (VkPhysicalDeviceImage2DViewOf3DFeaturesEXT *)ext;
1170
 
         features->image2DViewOf3D = true;
1171
 
         features->sampler2DViewOf3D = false;
1172
 
         break;
1173
 
      }
1174
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL: {
1175
 
         VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL *features =
1176
 
            (VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL *)ext;
1177
 
         features->shaderIntegerFunctions2 = true;
1178
 
         break;
1179
 
      }
1180
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT: {
1181
 
         VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT *features =
1182
 
            (VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT *)ext;
1183
 
         features->primitivesGeneratedQuery = true;
1184
 
         features->primitivesGeneratedQueryWithRasterizerDiscard = true;
1185
 
         features->primitivesGeneratedQueryWithNonZeroStreams = true;
1186
 
         break;
1187
 
      }
1188
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT: {
1189
 
         VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT *features =
1190
 
            (VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT *)ext;
1191
 
         features->nonSeamlessCubeMap = true;
1192
 
         break;
1193
 
      }
1194
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT: {
1195
 
         VkPhysicalDeviceBorderColorSwizzleFeaturesEXT *features =
1196
 
            (VkPhysicalDeviceBorderColorSwizzleFeaturesEXT *)ext;
1197
 
         features->borderColorSwizzle = true;
1198
 
         features->borderColorSwizzleFromImage = true;
1199
 
         break;
1200
 
      }
1201
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT: {
1202
 
         VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT *features =
1203
 
            (VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT *)ext;
1204
 
         features->shaderModuleIdentifier = true;
1205
 
         break;
1206
 
      }
1207
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR: {
1208
 
         VkPhysicalDevicePerformanceQueryFeaturesKHR *features =
1209
 
            (VkPhysicalDevicePerformanceQueryFeaturesKHR *)ext;
1210
 
         features->performanceCounterQueryPools = radv_perf_query_supported(pdevice);
1211
 
         features->performanceCounterMultipleQueryPools = features->performanceCounterQueryPools;
1212
 
         break;
1213
 
      }
1214
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV: {
1215
 
         VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV *features =
1216
 
            (VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV *)ext;
1217
 
         features->deviceGeneratedCommands = true;
1218
 
         break;
1219
 
      }
1220
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT: {
1221
 
         VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *features =
1222
 
            (VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *)ext;
1223
 
         features->attachmentFeedbackLoopLayout = true;
1224
 
         break;
1225
 
      }
1226
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT: {
1227
 
         VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT *features =
1228
 
            (VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT *)ext;
1229
 
         features->graphicsPipelineLibrary = true;
1230
 
         break;
1231
 
      }
1232
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT: {
1233
 
         VkPhysicalDeviceExtendedDynamicState3FeaturesEXT *features =
1234
 
            (VkPhysicalDeviceExtendedDynamicState3FeaturesEXT *)ext;
1235
 
         features->extendedDynamicState3TessellationDomainOrigin = true;
1236
 
         features->extendedDynamicState3PolygonMode = true;
1237
 
         features->extendedDynamicState3SampleMask = true;
1238
 
         features->extendedDynamicState3AlphaToCoverageEnable = pdevice->rad_info.gfx_level < GFX11;
1239
 
         features->extendedDynamicState3LogicOpEnable = true;
1240
 
         features->extendedDynamicState3LineStippleEnable = true;
1241
 
         features->extendedDynamicState3ColorBlendEnable = true;
1242
 
         features->extendedDynamicState3DepthClipEnable = true;
1243
 
         features->extendedDynamicState3ConservativeRasterizationMode = pdevice->rad_info.gfx_level >= GFX9;
1244
 
         features->extendedDynamicState3DepthClipNegativeOneToOne = true;
1245
 
         features->extendedDynamicState3ProvokingVertexMode = true;
1246
 
         features->extendedDynamicState3DepthClampEnable = true;
1247
 
         features->extendedDynamicState3ColorWriteMask = true;
1248
 
         features->extendedDynamicState3RasterizationSamples = true;
1249
 
         features->extendedDynamicState3ColorBlendEquation = true;
1250
 
         features->extendedDynamicState3SampleLocationsEnable = false; /* TODO */
1251
 
         features->extendedDynamicState3LineRasterizationMode = true;
1252
 
         features->extendedDynamicState3ExtraPrimitiveOverestimationSize = false;
1253
 
         features->extendedDynamicState3AlphaToOneEnable = false;
1254
 
         features->extendedDynamicState3RasterizationStream = false;
1255
 
         features->extendedDynamicState3ColorBlendAdvanced = false;
1256
 
         features->extendedDynamicState3ViewportWScalingEnable = false;
1257
 
         features->extendedDynamicState3ViewportSwizzle = false;
1258
 
         features->extendedDynamicState3CoverageToColorEnable = false;
1259
 
         features->extendedDynamicState3CoverageToColorLocation = false;
1260
 
         features->extendedDynamicState3CoverageModulationMode = false;
1261
 
         features->extendedDynamicState3CoverageModulationTableEnable = false;
1262
 
         features->extendedDynamicState3CoverageModulationTable = false;
1263
 
         features->extendedDynamicState3CoverageReductionMode = false;
1264
 
         features->extendedDynamicState3RepresentativeFragmentTestEnable = false;
1265
 
         features->extendedDynamicState3ShadingRateImageEnable = false;
1266
 
         break;
1267
 
      }
1268
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT: {
1269
 
         VkPhysicalDeviceDescriptorBufferFeaturesEXT *features =
1270
 
            (VkPhysicalDeviceDescriptorBufferFeaturesEXT *)ext;
1271
 
         features->descriptorBuffer = true;
1272
 
         features->descriptorBufferCaptureReplay = false;
1273
 
         features->descriptorBufferImageLayoutIgnored = true;
1274
 
         features->descriptorBufferPushDescriptors = true;
1275
 
         break;
1276
 
      }
1277
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD: {
1278
 
         VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD *features =
1279
 
            (VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD *)ext;
1280
 
         features->shaderEarlyAndLateFragmentTests = true;
1281
 
         break;
1282
 
      }
1283
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT: {
1284
 
         VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT *features =
1285
 
            (VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT *)ext;
1286
 
         features->imageSlicedViewOf3D = true;
1287
 
         break;
1288
 
      }
 
649
 
 
650
      /* Vulkan 1.1 */
 
651
      .storageBuffer16BitAccess = true,
 
652
      .uniformAndStorageBuffer16BitAccess = true,
 
653
      .storagePushConstant16 = true,
 
654
      .storageInputOutput16 = pdevice->rad_info.has_packed_math_16bit,
 
655
      .multiview = true,
 
656
      .multiviewGeometryShader = true,
 
657
      .multiviewTessellationShader = true,
 
658
      .variablePointersStorageBuffer = true,
 
659
      .variablePointers = true,
 
660
      .protectedMemory = false,
 
661
      .samplerYcbcrConversion = true,
 
662
      .shaderDrawParameters = true,
 
663
 
 
664
      /* Vulkan 1.2 */
 
665
      .samplerMirrorClampToEdge = true,
 
666
      .drawIndirectCount = true,
 
667
      .storageBuffer8BitAccess = true,
 
668
      .uniformAndStorageBuffer8BitAccess = true,
 
669
      .storagePushConstant8 = true,
 
670
      .shaderBufferInt64Atomics = true,
 
671
      .shaderSharedInt64Atomics = true,
 
672
      .shaderFloat16 = pdevice->rad_info.has_packed_math_16bit,
 
673
      .shaderInt8 = true,
 
674
 
 
675
      .descriptorIndexing = true,
 
676
      .shaderInputAttachmentArrayDynamicIndexing = true,
 
677
      .shaderUniformTexelBufferArrayDynamicIndexing = true,
 
678
      .shaderStorageTexelBufferArrayDynamicIndexing = true,
 
679
      .shaderUniformBufferArrayNonUniformIndexing = true,
 
680
      .shaderSampledImageArrayNonUniformIndexing = true,
 
681
      .shaderStorageBufferArrayNonUniformIndexing = true,
 
682
      .shaderStorageImageArrayNonUniformIndexing = true,
 
683
      .shaderInputAttachmentArrayNonUniformIndexing = true,
 
684
      .shaderUniformTexelBufferArrayNonUniformIndexing = true,
 
685
      .shaderStorageTexelBufferArrayNonUniformIndexing = true,
 
686
      .descriptorBindingUniformBufferUpdateAfterBind = true,
 
687
      .descriptorBindingSampledImageUpdateAfterBind = true,
 
688
      .descriptorBindingStorageImageUpdateAfterBind = true,
 
689
      .descriptorBindingStorageBufferUpdateAfterBind = true,
 
690
      .descriptorBindingUniformTexelBufferUpdateAfterBind = true,
 
691
      .descriptorBindingStorageTexelBufferUpdateAfterBind = true,
 
692
      .descriptorBindingUpdateUnusedWhilePending = true,
 
693
      .descriptorBindingPartiallyBound = true,
 
694
      .descriptorBindingVariableDescriptorCount = true,
 
695
      .runtimeDescriptorArray = true,
 
696
 
 
697
      .samplerFilterMinmax = true,
 
698
      .scalarBlockLayout = pdevice->rad_info.gfx_level >= GFX7,
 
699
      .imagelessFramebuffer = true,
 
700
      .uniformBufferStandardLayout = true,
 
701
      .shaderSubgroupExtendedTypes = true,
 
702
      .separateDepthStencilLayouts = true,
 
703
      .hostQueryReset = true,
 
704
      .timelineSemaphore = true,
 
705
      .bufferDeviceAddress = true,
 
706
      .bufferDeviceAddressCaptureReplay = true,
 
707
      .bufferDeviceAddressMultiDevice = false,
 
708
      .vulkanMemoryModel = true,
 
709
      .vulkanMemoryModelDeviceScope = true,
 
710
      .vulkanMemoryModelAvailabilityVisibilityChains = false,
 
711
      .shaderOutputViewportIndex = true,
 
712
      .shaderOutputLayer = true,
 
713
      .subgroupBroadcastDynamicId = true,
 
714
 
 
715
      /* Vulkan 1.3 */
 
716
      .robustImageAccess = true,
 
717
      .inlineUniformBlock = true,
 
718
      .descriptorBindingInlineUniformBlockUpdateAfterBind = true,
 
719
      .pipelineCreationCacheControl = true,
 
720
      .privateData = true,
 
721
      .shaderDemoteToHelperInvocation = true,
 
722
      .shaderTerminateInvocation = true,
 
723
      .subgroupSizeControl = true,
 
724
      .computeFullSubgroups = true,
 
725
      .synchronization2 = true,
 
726
      .textureCompressionASTC_HDR = false,
 
727
      .shaderZeroInitializeWorkgroupMemory = true,
 
728
      .dynamicRendering = true,
 
729
      .shaderIntegerDotProduct = true,
 
730
      .maintenance4 = true,
 
731
 
 
732
      /* VK_EXT_conditional_rendering */
 
733
      .conditionalRendering = true,
 
734
      .inheritedConditionalRendering = false,
 
735
 
 
736
      /* VK_EXT_vertex_attribute_divisor */
 
737
      .vertexAttributeInstanceRateDivisor = true,
 
738
      .vertexAttributeInstanceRateZeroDivisor = true,
 
739
 
 
740
      /* VK_EXT_transform_feedback */
 
741
      .transformFeedback = true,
 
742
      .geometryStreams = true,
 
743
 
 
744
      /* VK_EXT_memory_priority */
 
745
      .memoryPriority = true,
 
746
 
 
747
      /* VK_EXT_depth_clip_enable */
 
748
      .depthClipEnable = true,
 
749
 
 
750
      /* VK_NV_compute_shader_derivatives */
 
751
      .computeDerivativeGroupQuads = false,
 
752
      .computeDerivativeGroupLinear = true,
 
753
 
 
754
      /* VK_EXT_ycbcr_image_arrays */
 
755
      .ycbcrImageArrays = true,
 
756
 
 
757
      /* VK_EXT_index_type_uint8 */
 
758
      .indexTypeUint8 = pdevice->rad_info.gfx_level >= GFX8,
 
759
 
 
760
      /* VK_KHR_pipeline_executable_properties */
 
761
      .pipelineExecutableInfo = true,
 
762
 
 
763
      /* VK_KHR_shader_clock */
 
764
      .shaderSubgroupClock = true,
 
765
      .shaderDeviceClock = pdevice->rad_info.gfx_level >= GFX8,
 
766
 
 
767
      /* VK_EXT_texel_buffer_alignment */
 
768
      .texelBufferAlignment = true,
 
769
 
 
770
      /* VK_AMD_device_coherent_memory */
 
771
      .deviceCoherentMemory = pdevice->rad_info.has_l2_uncached,
 
772
 
 
773
      /* VK_EXT_line_rasterization */
 
774
      .rectangularLines = true,
 
775
      .bresenhamLines = true,
 
776
      .smoothLines = true,
 
777
      .stippledRectangularLines = false,
 
778
      /* FIXME: Some stippled Bresenham CTS fails on Vega10
 
779
       * but work on Raven.
 
780
       */
 
781
      .stippledBresenhamLines = pdevice->rad_info.gfx_level != GFX9,
 
782
      .stippledSmoothLines = false,
 
783
 
 
784
      /* VK_EXT_robustness2 */
 
785
      .robustBufferAccess2 = true,
 
786
      .robustImageAccess2 = true,
 
787
      .nullDescriptor = true,
 
788
 
 
789
      /* VK_EXT_custom_border_color */
 
790
      .customBorderColors = true,
 
791
      .customBorderColorWithoutFormat = true,
 
792
 
 
793
      /* VK_EXT_extended_dynamic_state */
 
794
      .extendedDynamicState = true,
 
795
 
 
796
      /* VK_EXT_shader_atomic_float */
 
797
      .shaderBufferFloat32Atomics = true,
 
798
      .shaderBufferFloat32AtomicAdd = pdevice->rad_info.gfx_level >= GFX11,
 
799
      .shaderBufferFloat64Atomics = true,
 
800
      .shaderBufferFloat64AtomicAdd = false,
 
801
      .shaderSharedFloat32Atomics = true,
 
802
      .shaderSharedFloat32AtomicAdd = pdevice->rad_info.gfx_level >= GFX8,
 
803
      .shaderSharedFloat64Atomics = true,
 
804
      .shaderSharedFloat64AtomicAdd = false,
 
805
      .shaderImageFloat32Atomics = true,
 
806
      .shaderImageFloat32AtomicAdd = false,
 
807
      .sparseImageFloat32Atomics = true,
 
808
      .sparseImageFloat32AtomicAdd = false,
 
809
 
 
810
      /* VK_EXT_4444_formats */
 
811
      .formatA4R4G4B4 = true,
 
812
      .formatA4B4G4R4 = true,
 
813
 
 
814
      /* VK_EXT_shader_image_atomic_int64 */
 
815
      .shaderImageInt64Atomics = true,
 
816
      .sparseImageInt64Atomics = true,
 
817
 
 
818
      /* VK_EXT_mutable_descriptor_type */
 
819
      .mutableDescriptorType = true,
 
820
 
 
821
      /* VK_KHR_fragment_shading_rate */
 
822
      .pipelineFragmentShadingRate = true,
 
823
      .primitiveFragmentShadingRate = true,
 
824
      .attachmentFragmentShadingRate = radv_vrs_attachment_enabled(pdevice),
 
825
 
 
826
      /* VK_KHR_workgroup_memory_explicit_layout */
 
827
      .workgroupMemoryExplicitLayout = true,
 
828
      .workgroupMemoryExplicitLayoutScalarBlockLayout = true,
 
829
      .workgroupMemoryExplicitLayout8BitAccess = true,
 
830
      .workgroupMemoryExplicitLayout16BitAccess = true,
 
831
 
 
832
      /* VK_EXT_provoking_vertex */
 
833
      .provokingVertexLast = true,
 
834
      .transformFeedbackPreservesProvokingVertex = true,
 
835
 
 
836
      /* VK_EXT_extended_dynamic_state2 */
 
837
      .extendedDynamicState2 = true,
 
838
      .extendedDynamicState2LogicOp = true,
 
839
      .extendedDynamicState2PatchControlPoints = true,
 
840
 
 
841
      /* VK_EXT_global_priority_query */
 
842
      .globalPriorityQuery = true,
 
843
 
 
844
      /* VK_KHR_acceleration_structure */
 
845
      .accelerationStructure = true,
 
846
      .accelerationStructureCaptureReplay = true,
 
847
      .accelerationStructureIndirectBuild = false,
 
848
      .accelerationStructureHostCommands = false,
 
849
      .descriptorBindingAccelerationStructureUpdateAfterBind = true,
 
850
 
 
851
      /* VK_EXT_buffer_device_address */
 
852
      .bufferDeviceAddressCaptureReplayEXT = true,
 
853
 
 
854
      /* VK_KHR_shader_subgroup_uniform_control_flow */
 
855
      .shaderSubgroupUniformControlFlow = true,
 
856
 
 
857
      /* VK_EXT_multi_draw */
 
858
      .multiDraw = true,
 
859
 
 
860
      /* VK_EXT_color_write_enable */
 
861
      .colorWriteEnable = true,
 
862
 
 
863
      /* VK_EXT_shader_atomic_float2 */
 
864
      .shaderBufferFloat16Atomics = false,
 
865
      .shaderBufferFloat16AtomicAdd = false,
 
866
      .shaderBufferFloat16AtomicMinMax = false,
 
867
      .shaderBufferFloat32AtomicMinMax = radv_has_shader_buffer_float_minmax(pdevice, 32),
 
868
      .shaderBufferFloat64AtomicMinMax = radv_has_shader_buffer_float_minmax(pdevice, 64),
 
869
      .shaderSharedFloat16Atomics = false,
 
870
      .shaderSharedFloat16AtomicAdd = false,
 
871
      .shaderSharedFloat16AtomicMinMax = false,
 
872
      .shaderSharedFloat32AtomicMinMax = true,
 
873
      .shaderSharedFloat64AtomicMinMax = true,
 
874
      .shaderImageFloat32AtomicMinMax = has_shader_image_float_minmax,
 
875
      .sparseImageFloat32AtomicMinMax = has_shader_image_float_minmax,
 
876
 
 
877
      /* VK_KHR_present_id */
 
878
      .presentId = pdevice->vk.supported_extensions.KHR_present_id,
 
879
 
 
880
      /* VK_KHR_present_wait */
 
881
      .presentWait = pdevice->vk.supported_extensions.KHR_present_wait,
 
882
 
 
883
      /* VK_EXT_primitive_topology_list_restart */
 
884
      .primitiveTopologyListRestart = true,
 
885
      .primitiveTopologyPatchListRestart = false,
 
886
 
 
887
      /* VK_KHR_ray_query */
 
888
      .rayQuery = true,
 
889
 
 
890
      /* VK_EXT_pipeline_library_group_handles */
 
891
      .pipelineLibraryGroupHandles = true,
 
892
 
 
893
      /* VK_KHR_ray_tracing_pipeline */
 
894
      .rayTracingPipeline = true,
 
895
      .rayTracingPipelineShaderGroupHandleCaptureReplay = true,
 
896
      .rayTracingPipelineShaderGroupHandleCaptureReplayMixed = false,
 
897
      .rayTracingPipelineTraceRaysIndirect = true,
 
898
      .rayTraversalPrimitiveCulling = true,
 
899
 
 
900
      /* VK_KHR_ray_tracing_maintenance1 */
 
901
      .rayTracingMaintenance1 = true,
 
902
      .rayTracingPipelineTraceRaysIndirect2 = radv_enable_rt(pdevice, true),
 
903
 
 
904
      /* VK_EXT_vertex_input_dynamic_state */
 
905
      .vertexInputDynamicState = true,
 
906
 
 
907
      /* VK_EXT_image_view_min_lod */
 
908
      .minLod = true,
 
909
 
 
910
      /* VK_EXT_mesh_shader */
 
911
      .meshShader = taskmesh_en,
 
912
      .taskShader = taskmesh_en,
 
913
      .multiviewMeshShader = taskmesh_en,
 
914
      .primitiveFragmentShadingRateMeshShader = taskmesh_en,
 
915
      .meshShaderQueries = false,
 
916
 
 
917
      /* VK_VALVE_descriptor_set_host_mapping */
 
918
      .descriptorSetHostMapping = true,
 
919
 
 
920
      /* VK_EXT_depth_clip_control */
 
921
      .depthClipControl = true,
 
922
 
 
923
      /* VK_EXT_image_2d_view_of_3d  */
 
924
      .image2DViewOf3D = true,
 
925
      .sampler2DViewOf3D = false,
 
926
 
 
927
      /* VK_INTEL_shader_integer_functions2 */
 
928
      .shaderIntegerFunctions2 = true,
 
929
 
 
930
      /* VK_EXT_primitives_generated_query */
 
931
      .primitivesGeneratedQuery = true,
 
932
      .primitivesGeneratedQueryWithRasterizerDiscard = true,
 
933
      .primitivesGeneratedQueryWithNonZeroStreams = true,
 
934
 
 
935
      /* VK_EXT_non_seamless_cube_map */
 
936
      .nonSeamlessCubeMap = true,
 
937
 
 
938
      /* VK_EXT_border_color_swizzle */
 
939
      .borderColorSwizzle = true,
 
940
      .borderColorSwizzleFromImage = true,
 
941
 
 
942
      /* VK_EXT_shader_module_identifier */
 
943
      .shaderModuleIdentifier = true,
 
944
 
 
945
      /* VK_KHR_performance_query */
 
946
      .performanceCounterQueryPools = has_perf_query,
 
947
      .performanceCounterMultipleQueryPools = has_perf_query,
 
948
 
 
949
      /* VK_NV_device_generated_commands */
 
950
      .deviceGeneratedCommands = true,
 
951
 
 
952
      /* VK_EXT_attachment_feedback_loop_layout */
 
953
      .attachmentFeedbackLoopLayout = true,
 
954
 
 
955
      /* VK_EXT_graphics_pipeline_library */
 
956
      .graphicsPipelineLibrary = true,
 
957
 
 
958
      /* VK_EXT_extended_dynamic_state3 */
 
959
      .extendedDynamicState3TessellationDomainOrigin = true,
 
960
      .extendedDynamicState3PolygonMode = true,
 
961
      .extendedDynamicState3SampleMask = true,
 
962
      .extendedDynamicState3AlphaToCoverageEnable = pdevice->rad_info.gfx_level < GFX11,
 
963
      .extendedDynamicState3LogicOpEnable = true,
 
964
      .extendedDynamicState3LineStippleEnable = true,
 
965
      .extendedDynamicState3ColorBlendEnable = true,
 
966
      .extendedDynamicState3DepthClipEnable = true,
 
967
      .extendedDynamicState3ConservativeRasterizationMode = pdevice->rad_info.gfx_level >= GFX9,
 
968
      .extendedDynamicState3DepthClipNegativeOneToOne = true,
 
969
      .extendedDynamicState3ProvokingVertexMode = true,
 
970
      .extendedDynamicState3DepthClampEnable = true,
 
971
      .extendedDynamicState3ColorWriteMask = true,
 
972
      .extendedDynamicState3RasterizationSamples = true,
 
973
      .extendedDynamicState3ColorBlendEquation = true,
 
974
      .extendedDynamicState3SampleLocationsEnable = pdevice->rad_info.gfx_level < GFX10,
 
975
      .extendedDynamicState3LineRasterizationMode = true,
 
976
      .extendedDynamicState3ExtraPrimitiveOverestimationSize = false,
 
977
      .extendedDynamicState3AlphaToOneEnable = false,
 
978
      .extendedDynamicState3RasterizationStream = false,
 
979
      .extendedDynamicState3ColorBlendAdvanced = false,
 
980
      .extendedDynamicState3ViewportWScalingEnable = false,
 
981
      .extendedDynamicState3ViewportSwizzle = false,
 
982
      .extendedDynamicState3CoverageToColorEnable = false,
 
983
      .extendedDynamicState3CoverageToColorLocation = false,
 
984
      .extendedDynamicState3CoverageModulationMode = false,
 
985
      .extendedDynamicState3CoverageModulationTableEnable = false,
 
986
      .extendedDynamicState3CoverageModulationTable = false,
 
987
      .extendedDynamicState3CoverageReductionMode = false,
 
988
      .extendedDynamicState3RepresentativeFragmentTestEnable = false,
 
989
      .extendedDynamicState3ShadingRateImageEnable = false,
 
990
 
 
991
      /* VK_EXT_descriptor_buffer */
 
992
      .descriptorBuffer = true,
 
993
      .descriptorBufferCaptureReplay = false,
 
994
      .descriptorBufferImageLayoutIgnored = true,
 
995
      .descriptorBufferPushDescriptors = true,
 
996
 
 
997
      /* VK_AMD_shader_early_and_late_fragment_tests */
 
998
      .shaderEarlyAndLateFragmentTests = true,
 
999
 
 
1000
      /* VK_EXT_image_sliced_view_of_3d */
 
1001
      .imageSlicedViewOf3D = true,
 
1002
 
1289
1003
#ifdef RADV_USE_WSI_PLATFORM
1290
 
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT: {
1291
 
         VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT *features =
1292
 
            (VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT *)ext;
1293
 
         features->swapchainMaintenance1 = true;
1294
 
         break;
1295
 
      }
 
1004
      /* VK_EXT_swapchain_maintenance1 */
 
1005
      .swapchainMaintenance1 = true,
1296
1006
#endif
1297
 
      default:
1298
 
         break;
1299
 
      }
1300
 
   }
 
1007
 
 
1008
      /* VK_EXT_attachment_feedback_loop_dynamic_state */
 
1009
      .attachmentFeedbackLoopDynamicState = true,
 
1010
 
 
1011
      /* VK_EXT_dynamic_rendering_unused_attachments */
 
1012
      .dynamicRenderingUnusedAttachments = true,
 
1013
 
 
1014
      /* VK_KHR_fragment_shader_barycentric */
 
1015
      .fragmentShaderBarycentric = true,
 
1016
 
 
1017
      /* VK_EXT_depth_bias_control */
 
1018
      .depthBiasControl = true,
 
1019
      .leastRepresentableValueForceUnormRepresentation = true,
 
1020
      .floatRepresentation = true,
 
1021
      .depthBiasExact = true,
 
1022
 
 
1023
      /* VK_EXT_fragment_shader_interlock */
 
1024
      .fragmentShaderSampleInterlock = has_fragment_shader_interlock,
 
1025
      .fragmentShaderPixelInterlock = has_fragment_shader_interlock,
 
1026
      .fragmentShaderShadingRateInterlock = false,
 
1027
 
 
1028
      /* VK_EXT_pipeline_robustness */
 
1029
      .pipelineRobustness = true,
 
1030
   };
1301
1031
}
1302
1032
 
1303
1033
static size_t
1309
1039
    * both. This limit is for the pipeline layout, not for the set layout, but
1310
1040
    * there is no set limit, so we just set a pipeline limit. I don't think
1311
1041
    * any app is going to hit this soon. */
1312
 
   return ((1ull << 31) - 16 * MAX_DYNAMIC_BUFFERS -
1313
 
           MAX_INLINE_UNIFORM_BLOCK_SIZE * MAX_INLINE_UNIFORM_BLOCK_COUNT) /
 
1042
   return ((1ull << 31) - 16 * MAX_DYNAMIC_BUFFERS - MAX_INLINE_UNIFORM_BLOCK_SIZE * MAX_INLINE_UNIFORM_BLOCK_COUNT) /
1314
1043
          (32 /* uniform buffer, 32 due to potential space wasted on alignment */ +
1315
1044
           32 /* storage buffer, 32 due to potential space wasted on alignment */ +
1316
 
           32 /* sampler, largest when combined with image */ + 64 /* sampled image */ +
1317
 
           64 /* storage image */);
 
1045
           32 /* sampler, largest when combined with image */ + 64 /* sampled image */ + 64 /* storage image */);
1318
1046
}
1319
1047
 
1320
1048
static uint32_t
1335
1063
}
1336
1064
 
1337
1065
VKAPI_ATTR void VKAPI_CALL
1338
 
radv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
1339
 
                                 VkPhysicalDeviceProperties *pProperties)
 
1066
radv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
1340
1067
{
1341
1068
   RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
1342
1069
   VkSampleCountFlags sample_counts = 0xf;
1480
1207
}
1481
1208
 
1482
1209
static void
1483
 
radv_get_physical_device_properties_1_1(struct radv_physical_device *pdevice,
1484
 
                                        VkPhysicalDeviceVulkan11Properties *p)
 
1210
radv_get_physical_device_properties_1_1(struct radv_physical_device *pdevice, VkPhysicalDeviceVulkan11Properties *p)
1485
1211
{
1486
1212
   assert(p->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES);
1487
1213
 
1499
1225
 
1500
1226
   if (radv_enable_rt(pdevice, true))
1501
1227
      p->subgroupSupportedStages |= RADV_RT_STAGE_BITS;
1502
 
   p->subgroupSupportedOperations =
1503
 
      VK_SUBGROUP_FEATURE_BASIC_BIT | VK_SUBGROUP_FEATURE_VOTE_BIT |
1504
 
      VK_SUBGROUP_FEATURE_ARITHMETIC_BIT | VK_SUBGROUP_FEATURE_BALLOT_BIT |
1505
 
      VK_SUBGROUP_FEATURE_CLUSTERED_BIT | VK_SUBGROUP_FEATURE_QUAD_BIT |
1506
 
      VK_SUBGROUP_FEATURE_SHUFFLE_BIT | VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT;
 
1228
   p->subgroupSupportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT | VK_SUBGROUP_FEATURE_VOTE_BIT |
 
1229
                                    VK_SUBGROUP_FEATURE_ARITHMETIC_BIT | VK_SUBGROUP_FEATURE_BALLOT_BIT |
 
1230
                                    VK_SUBGROUP_FEATURE_CLUSTERED_BIT | VK_SUBGROUP_FEATURE_QUAD_BIT |
 
1231
                                    VK_SUBGROUP_FEATURE_SHUFFLE_BIT | VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT;
1507
1232
   p->subgroupQuadOperationsInAllStages = true;
1508
1233
 
1509
1234
   p->pointClippingBehavior = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES;
1537
1262
}
1538
1263
 
1539
1264
static void
1540
 
radv_get_physical_device_properties_1_2(struct radv_physical_device *pdevice,
1541
 
                                        VkPhysicalDeviceVulkan12Properties *p)
 
1265
radv_get_physical_device_properties_1_2(struct radv_physical_device *pdevice, VkPhysicalDeviceVulkan12Properties *p)
1542
1266
{
1543
1267
   assert(p->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES);
1544
1268
 
1596
1320
   p->shaderRoundingModeRTZFloat32 = !pdevice->use_llvm;
1597
1321
   p->shaderSignedZeroInfNanPreserveFloat32 = true;
1598
1322
 
1599
 
   p->shaderDenormFlushToZeroFloat16 =
1600
 
      pdevice->rad_info.has_packed_math_16bit && !pdevice->use_llvm;
 
1323
   p->shaderDenormFlushToZeroFloat16 = pdevice->rad_info.has_packed_math_16bit && !pdevice->use_llvm;
1601
1324
   p->shaderDenormPreserveFloat16 = pdevice->rad_info.has_packed_math_16bit;
1602
1325
   p->shaderRoundingModeRTEFloat16 = pdevice->rad_info.has_packed_math_16bit;
1603
1326
   p->shaderRoundingModeRTZFloat16 = pdevice->rad_info.has_packed_math_16bit && !pdevice->use_llvm;
1637
1360
   p->maxDescriptorSetUpdateAfterBindInputAttachments = max_descriptor_set_size;
1638
1361
 
1639
1362
   /* We support all of the depth resolve modes */
1640
 
   p->supportedDepthResolveModes = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT | VK_RESOLVE_MODE_AVERAGE_BIT |
1641
 
                                   VK_RESOLVE_MODE_MIN_BIT | VK_RESOLVE_MODE_MAX_BIT;
 
1363
   p->supportedDepthResolveModes =
 
1364
      VK_RESOLVE_MODE_SAMPLE_ZERO_BIT | VK_RESOLVE_MODE_AVERAGE_BIT | VK_RESOLVE_MODE_MIN_BIT | VK_RESOLVE_MODE_MAX_BIT;
1642
1365
 
1643
1366
   /* Average doesn't make sense for stencil so we don't support that */
1644
1367
   p->supportedStencilResolveModes =
1657
1380
}
1658
1381
 
1659
1382
static void
1660
 
radv_get_physical_device_properties_1_3(struct radv_physical_device *pdevice,
1661
 
                                        VkPhysicalDeviceVulkan13Properties *p)
 
1383
radv_get_physical_device_properties_1_3(struct radv_physical_device *pdevice, VkPhysicalDeviceVulkan13Properties *p)
1662
1384
{
1663
1385
   assert(p->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES);
1664
1386
 
1670
1392
      /* Only GFX10+ supports wave32. */
1671
1393
      p->minSubgroupSize = 32;
1672
1394
      p->requiredSubgroupSizeStages = VK_SHADER_STAGE_COMPUTE_BIT;
 
1395
 
 
1396
      if (radv_taskmesh_enabled(pdevice)) {
 
1397
         p->requiredSubgroupSizeStages |= VK_SHADER_STAGE_MESH_BIT_EXT | VK_SHADER_STAGE_TASK_BIT_EXT;
 
1398
      }
1673
1399
   }
1674
1400
 
1675
1401
   p->maxInlineUniformBlockSize = MAX_INLINE_UNIFORM_BLOCK_SIZE;
1676
1402
   p->maxPerStageDescriptorInlineUniformBlocks = MAX_INLINE_UNIFORM_BLOCK_SIZE * MAX_SETS;
1677
 
   p->maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks =
1678
 
      MAX_INLINE_UNIFORM_BLOCK_SIZE * MAX_SETS;
 
1403
   p->maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks = MAX_INLINE_UNIFORM_BLOCK_SIZE * MAX_SETS;
1679
1404
   p->maxDescriptorSetInlineUniformBlocks = MAX_INLINE_UNIFORM_BLOCK_COUNT;
1680
1405
   p->maxDescriptorSetUpdateAfterBindInlineUniformBlocks = MAX_INLINE_UNIFORM_BLOCK_COUNT;
1681
1406
   p->maxInlineUniformTotalSize = UINT16_MAX;
1702
1427
   p->integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated = accel && gfx11plus;
1703
1428
   p->integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated = accel;
1704
1429
   p->integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated = accel;
1705
 
   p->integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated =
1706
 
      accel && gfx11plus;
 
1430
   p->integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated = accel && gfx11plus;
1707
1431
   p->integerDotProductAccumulatingSaturating16BitUnsignedAccelerated = accel && !gfx11plus;
1708
1432
   p->integerDotProductAccumulatingSaturating16BitSignedAccelerated = accel && !gfx11plus;
1709
1433
   p->integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated = false;
1723
1447
}
1724
1448
 
1725
1449
VKAPI_ATTR void VKAPI_CALL
1726
 
radv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
1727
 
                                  VkPhysicalDeviceProperties2 *pProperties)
 
1450
radv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties)
1728
1451
{
1729
1452
   RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
1730
1453
   radv_GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
1744
1467
   };
1745
1468
   radv_get_physical_device_properties_1_3(pdevice, &core_1_3);
1746
1469
 
1747
 
   vk_foreach_struct(ext, pProperties->pNext)
1748
 
   {
 
1470
   vk_foreach_struct (ext, pProperties->pNext) {
1749
1471
      if (vk_get_physical_device_core_1_1_property_ext(ext, &core_1_1))
1750
1472
         continue;
1751
1473
      if (vk_get_physical_device_core_1_2_property_ext(ext, &core_1_2))
1755
1477
 
1756
1478
      switch (ext->sType) {
1757
1479
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR: {
1758
 
         VkPhysicalDevicePushDescriptorPropertiesKHR *properties =
1759
 
            (VkPhysicalDevicePushDescriptorPropertiesKHR *)ext;
 
1480
         VkPhysicalDevicePushDescriptorPropertiesKHR *properties = (VkPhysicalDevicePushDescriptorPropertiesKHR *)ext;
1760
1481
         properties->maxPushDescriptors = MAX_PUSH_DESCRIPTORS;
1761
1482
         break;
1762
1483
      }
1773
1494
         break;
1774
1495
      }
1775
1496
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD: {
1776
 
         VkPhysicalDeviceShaderCorePropertiesAMD *properties =
1777
 
            (VkPhysicalDeviceShaderCorePropertiesAMD *)ext;
 
1497
         VkPhysicalDeviceShaderCorePropertiesAMD *properties = (VkPhysicalDeviceShaderCorePropertiesAMD *)ext;
1778
1498
 
1779
1499
         /* Shader engines. */
1780
1500
         properties->shaderEngineCount = pdevice->rad_info.max_se;
1798
1518
         break;
1799
1519
      }
1800
1520
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD: {
1801
 
         VkPhysicalDeviceShaderCoreProperties2AMD *properties =
1802
 
            (VkPhysicalDeviceShaderCoreProperties2AMD *)ext;
 
1521
         VkPhysicalDeviceShaderCoreProperties2AMD *properties = (VkPhysicalDeviceShaderCoreProperties2AMD *)ext;
1803
1522
 
1804
1523
         properties->shaderCoreFeatures = 0;
1805
1524
         properties->activeComputeUnitCount = pdevice->rad_info.num_cu;
1827
1546
      }
1828
1547
#ifndef _WIN32
1829
1548
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: {
1830
 
         VkPhysicalDevicePCIBusInfoPropertiesEXT *properties =
1831
 
            (VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext;
 
1549
         VkPhysicalDevicePCIBusInfoPropertiesEXT *properties = (VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext;
1832
1550
         properties->pciDomain = pdevice->bus_info.domain;
1833
1551
         properties->pciBus = pdevice->bus_info.bus;
1834
1552
         properties->pciDevice = pdevice->bus_info.dev;
1852
1570
         break;
1853
1571
      }
1854
1572
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT: {
1855
 
         VkPhysicalDeviceSampleLocationsPropertiesEXT *properties =
1856
 
            (VkPhysicalDeviceSampleLocationsPropertiesEXT *)ext;
1857
 
         properties->sampleLocationSampleCounts =
1858
 
            VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT | VK_SAMPLE_COUNT_8_BIT;
 
1573
         VkPhysicalDeviceSampleLocationsPropertiesEXT *properties = (VkPhysicalDeviceSampleLocationsPropertiesEXT *)ext;
 
1574
         properties->sampleLocationSampleCounts = VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT | VK_SAMPLE_COUNT_8_BIT;
1859
1575
         properties->maxSampleLocationGridSize = (VkExtent2D){2, 2};
1860
1576
         properties->sampleLocationCoordinateRange[0] = 0.0f;
1861
1577
         properties->sampleLocationCoordinateRange[1] = 0.9375f;
1864
1580
         break;
1865
1581
      }
1866
1582
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT: {
1867
 
         VkPhysicalDeviceLineRasterizationPropertiesEXT *props =
1868
 
            (VkPhysicalDeviceLineRasterizationPropertiesEXT *)ext;
 
1583
         VkPhysicalDeviceLineRasterizationPropertiesEXT *props = (VkPhysicalDeviceLineRasterizationPropertiesEXT *)ext;
1869
1584
         props->lineSubPixelPrecisionBits = 4;
1870
1585
         break;
1871
1586
      }
1872
1587
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT: {
1873
 
         VkPhysicalDeviceRobustness2PropertiesEXT *properties =
1874
 
            (VkPhysicalDeviceRobustness2PropertiesEXT *)ext;
 
1588
         VkPhysicalDeviceRobustness2PropertiesEXT *properties = (VkPhysicalDeviceRobustness2PropertiesEXT *)ext;
1875
1589
         properties->robustStorageBufferAccessSizeAlignment = 4;
1876
1590
         properties->robustUniformBufferAccessSizeAlignment = 4;
1877
1591
         break;
1878
1592
      }
1879
1593
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT: {
1880
 
         VkPhysicalDeviceCustomBorderColorPropertiesEXT *props =
1881
 
            (VkPhysicalDeviceCustomBorderColorPropertiesEXT *)ext;
 
1594
         VkPhysicalDeviceCustomBorderColorPropertiesEXT *props = (VkPhysicalDeviceCustomBorderColorPropertiesEXT *)ext;
1882
1595
         props->maxCustomBorderColorSamplers = RADV_BORDER_COLOR_COUNT;
1883
1596
         break;
1884
1597
      }
1900
1613
         props->maxFragmentSizeAspectRatio = 2;
1901
1614
         props->maxFragmentShadingRateCoverageSamples = 32;
1902
1615
         props->maxFragmentShadingRateRasterizationSamples = VK_SAMPLE_COUNT_8_BIT;
1903
 
         props->fragmentShadingRateWithShaderDepthStencilWrites =
1904
 
            !pdevice->rad_info.has_vrs_ds_export_bug;
 
1616
         props->fragmentShadingRateWithShaderDepthStencilWrites = !pdevice->rad_info.has_vrs_ds_export_bug;
1905
1617
         props->fragmentShadingRateWithSampleMask = true;
1906
1618
         props->fragmentShadingRateWithShaderSampleMask = false;
1907
1619
         props->fragmentShadingRateWithConservativeRasterization = true;
1908
 
         props->fragmentShadingRateWithFragmentShaderInterlock = false;
 
1620
         props->fragmentShadingRateWithFragmentShaderInterlock =
 
1621
            pdevice->rad_info.gfx_level >= GFX11 && radv_has_pops(pdevice);
1909
1622
         props->fragmentShadingRateWithCustomSampleLocations = false;
1910
1623
         props->fragmentShadingRateStrictMultiplyCombiner = true;
1911
1624
         break;
1912
1625
      }
1913
1626
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT: {
1914
 
         VkPhysicalDeviceProvokingVertexPropertiesEXT *props =
1915
 
            (VkPhysicalDeviceProvokingVertexPropertiesEXT *)ext;
 
1627
         VkPhysicalDeviceProvokingVertexPropertiesEXT *props = (VkPhysicalDeviceProvokingVertexPropertiesEXT *)ext;
1916
1628
         props->provokingVertexModePerPipeline = true;
1917
1629
         props->transformFeedbackPreservesTriangleFanProvokingVertex = true;
1918
1630
         break;
1927
1639
            pProperties->properties.limits.maxPerStageDescriptorStorageBuffers;
1928
1640
         props->maxPerStageDescriptorUpdateAfterBindAccelerationStructures =
1929
1641
            pProperties->properties.limits.maxPerStageDescriptorStorageBuffers;
1930
 
         props->maxDescriptorSetAccelerationStructures =
1931
 
            pProperties->properties.limits.maxDescriptorSetStorageBuffers;
 
1642
         props->maxDescriptorSetAccelerationStructures = pProperties->properties.limits.maxDescriptorSetStorageBuffers;
1932
1643
         props->maxDescriptorSetUpdateAfterBindAccelerationStructures =
1933
1644
            pProperties->properties.limits.maxDescriptorSetStorageBuffers;
1934
1645
         props->minAccelerationStructureScratchOffsetAlignment = 128;
1955
1666
      }
1956
1667
#endif
1957
1668
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT: {
1958
 
         VkPhysicalDeviceMultiDrawPropertiesEXT *props =
1959
 
            (VkPhysicalDeviceMultiDrawPropertiesEXT *)ext;
 
1669
         VkPhysicalDeviceMultiDrawPropertiesEXT *props = (VkPhysicalDeviceMultiDrawPropertiesEXT *)ext;
1960
1670
         props->maxMultiDrawCount = 2048;
1961
1671
         break;
1962
1672
      }
1969
1679
         /* This isn't strictly necessary, but Doom Eternal breaks if the
1970
1680
          * alignment is any lower. */
1971
1681
         props->shaderGroupBaseAlignment = RADV_RT_HANDLE_SIZE;
1972
 
         props->shaderGroupHandleCaptureReplaySize = RADV_RT_HANDLE_SIZE;
 
1682
         props->shaderGroupHandleCaptureReplaySize = sizeof(struct radv_rt_capture_replay_handle);
1973
1683
         props->maxRayDispatchInvocationCount = 1024 * 1024 * 64;
1974
1684
         props->shaderGroupHandleAlignment = 16;
1975
1685
         props->maxRayHitAttributeSize = RADV_MAX_HIT_ATTRIB_SIZE;
1976
1686
         break;
1977
1687
      }
1978
1688
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES: {
1979
 
         VkPhysicalDeviceMaintenance4Properties *properties =
1980
 
            (VkPhysicalDeviceMaintenance4Properties *)ext;
 
1689
         VkPhysicalDeviceMaintenance4Properties *properties = (VkPhysicalDeviceMaintenance4Properties *)ext;
1981
1690
         properties->maxBufferSize = RADV_MAX_MEMORY_ALLOCATION_SIZE;
1982
1691
         break;
1983
1692
      }
1986
1695
            (VkPhysicalDeviceShaderModuleIdentifierPropertiesEXT *)ext;
1987
1696
         STATIC_ASSERT(sizeof(vk_shaderModuleIdentifierAlgorithmUUID) ==
1988
1697
                       sizeof(properties->shaderModuleIdentifierAlgorithmUUID));
1989
 
         memcpy(properties->shaderModuleIdentifierAlgorithmUUID,
1990
 
                vk_shaderModuleIdentifierAlgorithmUUID,
 
1698
         memcpy(properties->shaderModuleIdentifierAlgorithmUUID, vk_shaderModuleIdentifierAlgorithmUUID,
1991
1699
                sizeof(properties->shaderModuleIdentifierAlgorithmUUID));
1992
1700
         break;
1993
1701
      }
2024
1732
         break;
2025
1733
      }
2026
1734
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT: {
2027
 
         VkPhysicalDeviceMeshShaderPropertiesEXT *properties =
2028
 
            (VkPhysicalDeviceMeshShaderPropertiesEXT *)ext;
 
1735
         VkPhysicalDeviceMeshShaderPropertiesEXT *properties = (VkPhysicalDeviceMeshShaderPropertiesEXT *)ext;
2029
1736
 
2030
1737
         properties->maxTaskWorkGroupTotalCount = 4194304; /* 2^22 min required */
2031
1738
         properties->maxTaskWorkGroupCount[0] = 65535;
2050
1757
         properties->maxMeshOutputMemorySize = 32 * 1024; /* 32K min required */
2051
1758
         properties->maxMeshSharedMemorySize = 28672;     /* 28K min required */
2052
1759
         properties->maxMeshPayloadAndSharedMemorySize =
2053
 
            properties->maxTaskPayloadSize +
2054
 
            properties->maxMeshSharedMemorySize; /* 28K min required */
 
1760
            properties->maxTaskPayloadSize + properties->maxMeshSharedMemorySize; /* 28K min required */
2055
1761
         properties->maxMeshPayloadAndOutputMemorySize =
2056
 
            properties->maxTaskPayloadSize +
2057
 
            properties->maxMeshOutputMemorySize;    /* 47K min required */
2058
 
         properties->maxMeshOutputComponents = 128; /* 32x vec4 min required */
 
1762
            properties->maxTaskPayloadSize + properties->maxMeshOutputMemorySize; /* 47K min required */
 
1763
         properties->maxMeshOutputComponents = 128;                               /* 32x vec4 min required */
2059
1764
         properties->maxMeshOutputVertices = 256;
2060
1765
         properties->maxMeshOutputPrimitives = 256;
2061
1766
         properties->maxMeshOutputLayers = 8;
2116
1821
         properties->descriptorBufferAddressSpaceSize = RADV_MAX_MEMORY_ALLOCATION_SIZE;
2117
1822
         break;
2118
1823
      }
 
1824
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_PROPERTIES_KHR: {
 
1825
         VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR *properties =
 
1826
            (VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR *)ext;
 
1827
         properties->triStripVertexOrderIndependentOfProvokingVertex = false;
 
1828
         break;
 
1829
      }
 
1830
      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT: {
 
1831
         VkPhysicalDevicePipelineRobustnessPropertiesEXT *properties =
 
1832
            (VkPhysicalDevicePipelineRobustnessPropertiesEXT *)ext;
 
1833
         properties->defaultRobustnessStorageBuffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
 
1834
         properties->defaultRobustnessUniformBuffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT;
 
1835
         properties->defaultRobustnessVertexInputs = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT;
 
1836
         properties->defaultRobustnessImages = VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT;
 
1837
         break;
 
1838
      }
2119
1839
      default:
2120
1840
         break;
2121
1841
      }
2139
1859
 
2140
1860
      fd = open(path, O_RDWR | O_CLOEXEC);
2141
1861
      if (fd < 0) {
2142
 
         return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, "Could not open device %s: %m",
2143
 
                          path);
 
1862
         return vk_errorf(instance, VK_ERROR_INCOMPATIBLE_DRIVER, "Could not open device %s: %m", path);
2144
1863
      }
2145
1864
 
2146
1865
      version = drmGetVersion(fd);
2165
1884
   }
2166
1885
#endif
2167
1886
 
2168
 
   struct radv_physical_device *device = vk_zalloc2(&instance->vk.alloc, NULL, sizeof(*device), 8,
2169
 
                                                    VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
 
1887
   struct radv_physical_device *device =
 
1888
      vk_zalloc2(&instance->vk.alloc, NULL, sizeof(*device), 8, VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE);
2170
1889
   if (!device) {
2171
1890
      result = vk_error(instance, VK_ERROR_OUT_OF_HOST_MEMORY);
2172
1891
      goto fail_fd;
2173
1892
   }
2174
1893
 
2175
1894
   struct vk_physical_device_dispatch_table dispatch_table;
2176
 
   vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
2177
 
                                                      &radv_physical_device_entrypoints, true);
2178
 
   vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table,
2179
 
                                                      &wsi_physical_device_entrypoints, false);
 
1895
   vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table, &radv_physical_device_entrypoints, true);
 
1896
   vk_physical_device_dispatch_table_from_entrypoints(&dispatch_table, &wsi_physical_device_entrypoints, false);
2180
1897
 
2181
 
   result = vk_physical_device_init(&device->vk, &instance->vk, NULL, &dispatch_table);
 
1898
   result = vk_physical_device_init(&device->vk, &instance->vk, NULL, NULL, &dispatch_table);
2182
1899
   if (result != VK_SUCCESS) {
2183
1900
      goto fail_alloc;
2184
1901
   }
2189
1906
   device->ws = radv_null_winsys_create();
2190
1907
#else
2191
1908
   if (drm_device) {
2192
 
      bool reserve_vmid = radv_thread_trace_enabled();
 
1909
      bool reserve_vmid = instance->vk.trace_mode & RADV_TRACE_MODE_RGP;
2193
1910
 
2194
 
      device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags, instance->perftest_flags,
2195
 
                                             reserve_vmid);
 
1911
      device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags, instance->perftest_flags, reserve_vmid);
2196
1912
   } else {
2197
1913
      device->ws = radv_null_winsys_create();
2198
1914
   }
2214
1930
                                           .return_size = sizeof(accel_working),
2215
1931
                                           .query = AMDGPU_INFO_ACCEL_WORKING};
2216
1932
 
2217
 
         if (drmCommandWrite(master_fd, DRM_AMDGPU_INFO, &request, sizeof(struct drm_amdgpu_info)) <
2218
 
                0 ||
 
1933
         if (drmCommandWrite(master_fd, DRM_AMDGPU_INFO, &request, sizeof(struct drm_amdgpu_info)) < 0 ||
2219
1934
             !accel_working) {
2220
1935
            close(master_fd);
2221
1936
            master_fd = -1;
2240
1955
#ifdef ANDROID
2241
1956
   device->emulate_etc2 = !radv_device_supports_etc(device);
2242
1957
#else
2243
 
   device->emulate_etc2 = !radv_device_supports_etc(device) &&
2244
 
                          driQueryOptionb(&device->instance->dri_options, "radv_require_etc2");
 
1958
   device->emulate_etc2 =
 
1959
      !radv_device_supports_etc(device) && driQueryOptionb(&device->instance->dri_options, "radv_require_etc2");
2245
1960
#endif
2246
1961
 
2247
1962
   snprintf(device->name, sizeof(device->name), "AMD RADV %s%s", device->rad_info.name,
2249
1964
 
2250
1965
   const char *marketing_name = device->ws->get_chip_name(device->ws);
2251
1966
   snprintf(device->marketing_name, sizeof(device->name), "%s (RADV %s%s)",
2252
 
            marketing_name ? marketing_name : "AMD Unknown", device->rad_info.name,
2253
 
            radv_get_compiler_string(device));
 
1967
            marketing_name ? marketing_name : "AMD Unknown", device->rad_info.name, radv_get_compiler_string(device));
2254
1968
 
2255
1969
   if (radv_device_get_cache_uuid(device, device->cache_uuid)) {
2256
1970
      result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "cannot generate UUID");
2261
1975
    * when creating the cache.
2262
1976
    */
2263
1977
   char buf[VK_UUID_SIZE * 2 + 1];
2264
 
   disk_cache_format_hex_id(buf, device->cache_uuid, VK_UUID_SIZE * 2);
 
1978
   mesa_bytes_to_hex(buf, device->cache_uuid, VK_UUID_SIZE);
2265
1979
   device->vk.disk_cache = disk_cache_create(device->name, buf, 0);
2266
1980
 
2267
1981
   if (!radv_is_conformant(device))
2272
1986
 
2273
1987
   device->dcc_msaa_allowed = (device->instance->perftest_flags & RADV_PERFTEST_DCC_MSAA);
2274
1988
 
2275
 
   device->use_fmask =
2276
 
      device->rad_info.gfx_level < GFX11 && !(device->instance->debug_flags & RADV_DEBUG_NO_FMASK);
 
1989
   device->use_fmask = device->rad_info.gfx_level < GFX11 && !(device->instance->debug_flags & RADV_DEBUG_NO_FMASK);
2277
1990
 
2278
 
   device->use_ngg =
2279
 
      (device->rad_info.gfx_level >= GFX10 && device->rad_info.family != CHIP_NAVI14 &&
2280
 
       !(device->instance->debug_flags & RADV_DEBUG_NO_NGG)) ||
2281
 
      device->rad_info.gfx_level >= GFX11;
 
1991
   device->use_ngg = (device->rad_info.gfx_level >= GFX10 && device->rad_info.family != CHIP_NAVI14 &&
 
1992
                      !(device->instance->debug_flags & RADV_DEBUG_NO_NGG)) ||
 
1993
                     device->rad_info.gfx_level >= GFX11;
2282
1994
 
2283
1995
   /* TODO: Investigate if NGG culling helps on GFX11. */
2284
 
   device->use_ngg_culling = device->use_ngg && device->rad_info.max_render_backends > 1 &&
2285
 
                             (device->rad_info.gfx_level == GFX10_3 ||
2286
 
                              (device->instance->perftest_flags & RADV_PERFTEST_NGGC)) &&
2287
 
                             !(device->instance->debug_flags & RADV_DEBUG_NO_NGGC);
2288
 
 
2289
 
   device->use_ngg_streamout =
2290
 
      device->use_ngg && (device->rad_info.gfx_level >= GFX11 ||
2291
 
                          (device->instance->perftest_flags & RADV_PERFTEST_NGG_STREAMOUT));
2292
 
 
2293
 
   device->emulate_ngg_gs_query_pipeline_stat =
2294
 
      device->use_ngg && device->rad_info.gfx_level < GFX11;
 
1996
   device->use_ngg_culling =
 
1997
      device->use_ngg && device->rad_info.max_render_backends > 1 &&
 
1998
      (device->rad_info.gfx_level == GFX10_3 || (device->instance->perftest_flags & RADV_PERFTEST_NGGC)) &&
 
1999
      !(device->instance->debug_flags & RADV_DEBUG_NO_NGGC);
 
2000
 
 
2001
   device->use_ngg_streamout = device->use_ngg && (device->rad_info.gfx_level >= GFX11 ||
 
2002
                                                   (device->instance->perftest_flags & RADV_PERFTEST_NGG_STREAMOUT));
 
2003
 
 
2004
   device->emulate_ngg_gs_query_pipeline_stat = device->use_ngg && device->rad_info.gfx_level < GFX11;
2295
2005
 
2296
2006
   /* Determine the number of threads per wave for all stages. */
2297
2007
   device->cs_wave_size = 64;
2303
2013
      if (device->instance->perftest_flags & RADV_PERFTEST_CS_WAVE_32)
2304
2014
         device->cs_wave_size = 32;
2305
2015
 
2306
 
      /* For pixel shaders, wave64 is recommanded. */
 
2016
      /* For pixel shaders, wave64 is recommended. */
2307
2017
      if (device->instance->perftest_flags & RADV_PERFTEST_PS_WAVE_32)
2308
2018
         device->ps_wave_size = 32;
2309
2019
 
2315
2025
       * dependence wave32 would likely be a net-loss (as well as the SALU count becoming more
2316
2026
       * problematic)
2317
2027
       */
2318
 
      if (!(device->instance->perftest_flags & RADV_PERFTEST_RT_WAVE_64) &&
 
2028
      if (!(device->instance->perftest_flags & RADV_PERFTEST_RT_WAVE_64) && !(device->instance->force_rt_wave64) &&
2319
2029
          device->rad_info.gfx_level < GFX11)
2320
2030
         device->rt_wave_size = 32;
2321
2031
   }
2325
2035
   radv_physical_device_init_mem_types(device);
2326
2036
 
2327
2037
   radv_physical_device_get_supported_extensions(device, &device->vk.supported_extensions);
 
2038
   radv_physical_device_get_features(device, &device->vk.supported_features);
2328
2039
 
2329
2040
   radv_get_nir_options(device);
2330
2041
 
2337
2048
 
2338
2049
      if ((drm_device->available_nodes & (1 << DRM_NODE_PRIMARY)) &&
2339
2050
          stat(drm_device->nodes[DRM_NODE_PRIMARY], &primary_stat) != 0) {
2340
 
         result =
2341
 
            vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
2342
 
                      "failed to stat DRM primary node %s", drm_device->nodes[DRM_NODE_PRIMARY]);
 
2051
         result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "failed to stat DRM primary node %s",
 
2052
                            drm_device->nodes[DRM_NODE_PRIMARY]);
2343
2053
         goto fail_perfcounters;
2344
2054
      }
2345
2055
      device->primary_devid = primary_stat.st_rdev;
2346
2056
 
2347
2057
      if ((drm_device->available_nodes & (1 << DRM_NODE_RENDER)) &&
2348
2058
          stat(drm_device->nodes[DRM_NODE_RENDER], &render_stat) != 0) {
2349
 
         result =
2350
 
            vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "failed to stat DRM render node %s",
2351
 
                      drm_device->nodes[DRM_NODE_RENDER]);
 
2059
         result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "failed to stat DRM render node %s",
 
2060
                            drm_device->nodes[DRM_NODE_RENDER]);
2352
2061
         goto fail_perfcounters;
2353
2062
      }
2354
2063
      device->render_devid = render_stat.st_rdev;
2375
2084
      goto fail_perfcounters;
2376
2085
   }
2377
2086
 
2378
 
   device->gs_table_depth =
2379
 
      ac_get_gs_table_depth(device->rad_info.gfx_level, device->rad_info.family);
 
2087
   device->gs_table_depth = ac_get_gs_table_depth(device->rad_info.gfx_level, device->rad_info.family);
2380
2088
 
2381
2089
   ac_get_hs_info(&device->rad_info, &device->hs);
2382
2090
   ac_get_task_info(&device->rad_info, &device->task_info);
2418
2126
}
2419
2127
 
2420
2128
VkResult
2421
 
create_drm_physical_device(struct vk_instance *vk_instance, struct _drmDevice *device,
2422
 
                           struct vk_physical_device **out)
 
2129
create_drm_physical_device(struct vk_instance *vk_instance, struct _drmDevice *device, struct vk_physical_device **out)
2423
2130
{
2424
2131
#ifndef _WIN32
2425
2132
   if (!(device->available_nodes & (1 << DRM_NODE_RENDER)) || device->bustype != DRM_BUS_PCI ||
2451
2158
}
2452
2159
 
2453
2160
static void
2454
 
radv_get_physical_device_queue_family_properties(struct radv_physical_device *pdevice,
2455
 
                                                 uint32_t *pCount,
 
2161
radv_get_physical_device_queue_family_properties(struct radv_physical_device *pdevice, uint32_t *pCount,
2456
2162
                                                 VkQueueFamilyProperties **pQueueFamilyProperties)
2457
2163
{
2458
2164
   int num_queue_families = 1;
2462
2168
      num_queue_families++;
2463
2169
 
2464
2170
   if (pdevice->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE) {
2465
 
      if (pdevice->rad_info.ip[AMD_IP_VCN_DEC].num_queues > 0)
2466
 
         num_queue_families++;
2467
 
 
2468
 
      if (radv_has_uvd(pdevice))
 
2171
      if (pdevice->rad_info.ip[pdevice->vid_decode_ip].num_queues > 0)
2469
2172
         num_queue_families++;
2470
2173
   }
2471
2174
 
2480
2183
   idx = 0;
2481
2184
   if (*pCount >= 1) {
2482
2185
      *pQueueFamilyProperties[idx] = (VkQueueFamilyProperties){
2483
 
         .queueFlags = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT |
2484
 
                       VK_QUEUE_SPARSE_BINDING_BIT,
 
2186
         .queueFlags =
 
2187
            VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT,
2485
2188
         .queueCount = 1,
2486
2189
         .timestampValidBits = 64,
2487
2190
         .minImageTransferGranularity = (VkExtent3D){1, 1, 1},
2493
2196
       !(pdevice->instance->debug_flags & RADV_DEBUG_NO_COMPUTE_QUEUE)) {
2494
2197
      if (*pCount > idx) {
2495
2198
         *pQueueFamilyProperties[idx] = (VkQueueFamilyProperties){
2496
 
            .queueFlags =
2497
 
               VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT,
 
2199
            .queueFlags = VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT | VK_QUEUE_SPARSE_BINDING_BIT,
2498
2200
            .queueCount = pdevice->rad_info.ip[AMD_IP_COMPUTE].num_queues,
2499
2201
            .timestampValidBits = 64,
2500
2202
            .minImageTransferGranularity = (VkExtent3D){1, 1, 1},
2504
2206
   }
2505
2207
 
2506
2208
   if (pdevice->instance->perftest_flags & RADV_PERFTEST_VIDEO_DECODE) {
2507
 
      if (pdevice->rad_info.ip[AMD_IP_VCN_DEC].num_queues > 0) {
2508
 
         if (*pCount > idx) {
2509
 
            *pQueueFamilyProperties[idx] = (VkQueueFamilyProperties){
2510
 
               .queueFlags = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
2511
 
               .queueCount = pdevice->rad_info.ip[AMD_IP_VCN_DEC].num_queues,
2512
 
               .timestampValidBits = 64,
2513
 
               .minImageTransferGranularity = (VkExtent3D){1, 1, 1},
2514
 
            };
2515
 
            idx++;
2516
 
         }
2517
 
      }
2518
 
 
2519
 
      if (radv_has_uvd(pdevice)) {
2520
 
         if (*pCount > idx) {
2521
 
            *pQueueFamilyProperties[idx] = (VkQueueFamilyProperties){
2522
 
               .queueFlags = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
2523
 
               .queueCount = pdevice->rad_info.ip[AMD_IP_UVD].num_queues,
 
2209
      if (pdevice->rad_info.ip[pdevice->vid_decode_ip].num_queues > 0) {
 
2210
         if (*pCount > idx) {
 
2211
            *pQueueFamilyProperties[idx] = (VkQueueFamilyProperties){
 
2212
               .queueFlags = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
 
2213
               .queueCount = pdevice->rad_info.ip[pdevice->vid_decode_ip].num_queues,
2524
2214
               .timestampValidBits = 64,
2525
2215
               .minImageTransferGranularity = (VkExtent3D){1, 1, 1},
2526
2216
            };
2557
2247
   assert(*pCount <= 3);
2558
2248
 
2559
2249
   for (uint32_t i = 0; i < *pCount; i++) {
2560
 
      vk_foreach_struct(ext, pQueueFamilyProperties[i].pNext)
2561
 
      {
 
2250
      vk_foreach_struct (ext, pQueueFamilyProperties[i].pNext) {
2562
2251
         switch (ext->sType) {
2563
2252
         case VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR: {
2564
 
            VkQueueFamilyGlobalPriorityPropertiesKHR *prop =
2565
 
               (VkQueueFamilyGlobalPriorityPropertiesKHR *)ext;
2566
 
            STATIC_ASSERT(ARRAY_SIZE(radv_global_queue_priorities) <=
2567
 
                          VK_MAX_GLOBAL_PRIORITY_SIZE_KHR);
 
2253
            VkQueueFamilyGlobalPriorityPropertiesKHR *prop = (VkQueueFamilyGlobalPriorityPropertiesKHR *)ext;
 
2254
            STATIC_ASSERT(ARRAY_SIZE(radv_global_queue_priorities) <= VK_MAX_GLOBAL_PRIORITY_SIZE_KHR);
2568
2255
            prop->priorityCount = ARRAY_SIZE(radv_global_queue_priorities);
2569
 
            memcpy(&prop->priorities, radv_global_queue_priorities,
2570
 
                   sizeof(radv_global_queue_priorities));
 
2256
            memcpy(&prop->priorities, radv_global_queue_priorities, sizeof(radv_global_queue_priorities));
2571
2257
            break;
2572
2258
         }
2573
2259
         case VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR: {
2574
 
            VkQueueFamilyQueryResultStatusPropertiesKHR *prop =
2575
 
               (VkQueueFamilyQueryResultStatusPropertiesKHR *)ext;
 
2260
            VkQueueFamilyQueryResultStatusPropertiesKHR *prop = (VkQueueFamilyQueryResultStatusPropertiesKHR *)ext;
2576
2261
            prop->queryResultStatusSupport = VK_FALSE;
2577
2262
            break;
2578
2263
         }
2579
2264
         case VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR: {
2580
2265
            VkQueueFamilyVideoPropertiesKHR *prop = (VkQueueFamilyVideoPropertiesKHR *)ext;
2581
 
            if (pQueueFamilyProperties[i].queueFamilyProperties.queueFlags &
2582
 
                VK_QUEUE_VIDEO_DECODE_BIT_KHR)
2583
 
               prop->videoCodecOperations = VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR |
2584
 
                                            VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR;
 
2266
            if (pQueueFamilyProperties[i].queueFamilyProperties.queueFlags & VK_QUEUE_VIDEO_DECODE_BIT_KHR)
 
2267
               prop->videoCodecOperations =
 
2268
                  VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR | VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR;
2585
2269
            break;
2586
2270
         }
2587
2271
         default:
2618
2302
         uint64_t total_heap_size = device->memory_properties.memoryHeaps[vram_vis_heap_idx].size;
2619
2303
 
2620
2304
         /* Get the different memory usages. */
2621
 
         uint64_t vram_vis_internal_usage =
2622
 
            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS) +
2623
 
            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM);
 
2305
         uint64_t vram_vis_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS) +
 
2306
                                            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM);
2624
2307
         uint64_t gtt_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_GTT);
2625
2308
         uint64_t total_internal_usage = vram_vis_internal_usage + gtt_internal_usage;
2626
2309
         uint64_t total_system_usage = device->ws->query_value(device->ws, RADEON_VRAM_VIS_USAGE) +
2627
2310
                                       device->ws->query_value(device->ws, RADEON_GTT_USAGE);
2628
2311
         uint64_t total_usage = MAX2(total_internal_usage, total_system_usage);
2629
2312
 
2630
 
         /* Compute the total free space that can be allocated for this process accross all heaps. */
 
2313
         /* Compute the total free space that can be allocated for this process across all heaps. */
2631
2314
         uint64_t total_free_space = total_heap_size - MIN2(total_heap_size, total_usage);
2632
2315
 
2633
2316
         memoryBudget->heapBudget[vram_vis_heap_idx] = total_free_space + total_internal_usage;
2643
2326
 
2644
2327
         /* Get the visible VRAM/GTT heap sizes and internal usages. */
2645
2328
         uint64_t gtt_heap_size = device->memory_properties.memoryHeaps[gtt_heap_idx].size;
2646
 
         uint64_t vram_vis_heap_size =
2647
 
            device->memory_properties.memoryHeaps[vram_vis_heap_idx].size;
 
2329
         uint64_t vram_vis_heap_size = device->memory_properties.memoryHeaps[vram_vis_heap_idx].size;
2648
2330
 
2649
 
         uint64_t vram_vis_internal_usage =
2650
 
            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS) +
2651
 
            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM);
 
2331
         uint64_t vram_vis_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM_VIS) +
 
2332
                                            device->ws->query_value(device->ws, RADEON_ALLOCATED_VRAM);
2652
2333
         uint64_t gtt_internal_usage = device->ws->query_value(device->ws, RADEON_ALLOCATED_GTT);
2653
2334
 
2654
2335
         /* Compute the total heap size, internal and system usage. */
2659
2340
 
2660
2341
         uint64_t total_usage = MAX2(total_internal_usage, total_system_usage);
2661
2342
 
2662
 
         /* Compute the total free space that can be allocated for this process accross all heaps. */
 
2343
         /* Compute the total free space that can be allocated for this process across all heaps. */
2663
2344
         uint64_t total_free_space = total_heap_size - MIN2(total_heap_size, total_usage);
2664
2345
 
2665
2346
         /* Compute the remaining visible VRAM size for this process. */
2666
 
         uint64_t vram_vis_free_space =
2667
 
            vram_vis_heap_size - MIN2(vram_vis_heap_size, vram_vis_internal_usage);
 
2347
         uint64_t vram_vis_free_space = vram_vis_heap_size - MIN2(vram_vis_heap_size, vram_vis_internal_usage);
2668
2348
 
2669
2349
         /* Distribute the total free space (2/3rd as VRAM and 1/3rd as GTT) to match the heap
2670
2350
          * sizes, and align down to the page size to be conservative.
2671
2351
          */
2672
 
         vram_vis_free_space = ROUND_DOWN_TO(MIN2((total_free_space * 2) / 3, vram_vis_free_space),
2673
 
                                             device->rad_info.gart_page_size);
 
2352
         vram_vis_free_space =
 
2353
            ROUND_DOWN_TO(MIN2((total_free_space * 2) / 3, vram_vis_free_space), device->rad_info.gart_page_size);
2674
2354
         uint64_t gtt_free_space = total_free_space - vram_vis_free_space;
2675
2355
 
2676
 
         memoryBudget->heapBudget[vram_vis_heap_idx] =
2677
 
            vram_vis_free_space + vram_vis_internal_usage;
 
2356
         memoryBudget->heapBudget[vram_vis_heap_idx] = vram_vis_free_space + vram_vis_internal_usage;
2678
2357
         memoryBudget->heapUsage[vram_vis_heap_idx] = vram_vis_internal_usage;
2679
2358
         memoryBudget->heapBudget[gtt_heap_idx] = gtt_free_space + gtt_internal_usage;
2680
2359
         memoryBudget->heapUsage[gtt_heap_idx] = gtt_internal_usage;
2748
2427
};
2749
2428
 
2750
2429
VKAPI_ATTR VkResult VKAPI_CALL
2751
 
radv_GetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDevice physicalDevice,
2752
 
                                                  uint32_t *pTimeDomainCount,
 
2430
radv_GetPhysicalDeviceCalibrateableTimeDomainsEXT(VkPhysicalDevice physicalDevice, uint32_t *pTimeDomainCount,
2753
2431
                                                  VkTimeDomainEXT *pTimeDomains)
2754
2432
{
2755
2433
   int d;
2766
2444
}
2767
2445
 
2768
2446
VKAPI_ATTR void VKAPI_CALL
2769
 
radv_GetPhysicalDeviceMultisamplePropertiesEXT(VkPhysicalDevice physicalDevice,
2770
 
                                               VkSampleCountFlagBits samples,
 
2447
radv_GetPhysicalDeviceMultisamplePropertiesEXT(VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples,
2771
2448
                                               VkMultisamplePropertiesEXT *pMultisampleProperties)
2772
2449
{
2773
 
   VkSampleCountFlagBits supported_samples =
2774
 
      VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT | VK_SAMPLE_COUNT_8_BIT;
 
2450
   VkSampleCountFlagBits supported_samples = VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT | VK_SAMPLE_COUNT_8_BIT;
2775
2451
 
2776
2452
   if (samples & supported_samples) {
2777
2453
      pMultisampleProperties->maxSampleLocationGridSize = (VkExtent2D){2, 2};
2781
2457
}
2782
2458
 
2783
2459
VKAPI_ATTR VkResult VKAPI_CALL
2784
 
radv_GetPhysicalDeviceFragmentShadingRatesKHR(
2785
 
   VkPhysicalDevice physicalDevice, uint32_t *pFragmentShadingRateCount,
2786
 
   VkPhysicalDeviceFragmentShadingRateKHR *pFragmentShadingRates)
 
2460
radv_GetPhysicalDeviceFragmentShadingRatesKHR(VkPhysicalDevice physicalDevice, uint32_t *pFragmentShadingRateCount,
 
2461
                                              VkPhysicalDeviceFragmentShadingRateKHR *pFragmentShadingRates)
2787
2462
{
2788
2463
   VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceFragmentShadingRateKHR, out, pFragmentShadingRates,
2789
2464
                          pFragmentShadingRateCount);
2790
2465
 
2791
 
#define append_rate(w, h, s)                                                                       \
2792
 
   {                                                                                               \
2793
 
      VkPhysicalDeviceFragmentShadingRateKHR rate = {                                              \
2794
 
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR,          \
2795
 
         .sampleCounts = s,                                                                        \
2796
 
         .fragmentSize = {.width = w, .height = h},                                                \
2797
 
      };                                                                                           \
2798
 
      vk_outarray_append_typed(VkPhysicalDeviceFragmentShadingRateKHR, &out, r) *r = rate;         \
 
2466
#define append_rate(w, h, s)                                                                                           \
 
2467
   {                                                                                                                   \
 
2468
      VkPhysicalDeviceFragmentShadingRateKHR rate = {                                                                  \
 
2469
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR,                              \
 
2470
         .sampleCounts = s,                                                                                            \
 
2471
         .fragmentSize = {.width = w, .height = h},                                                                    \
 
2472
      };                                                                                                               \
 
2473
      vk_outarray_append_typed(VkPhysicalDeviceFragmentShadingRateKHR, &out, r) *r = rate;                             \
2799
2474
   }
2800
2475
 
2801
2476
   for (uint32_t x = 2; x >= 1; x--) {
2805
2480
         if (x == 1 && y == 1) {
2806
2481
            samples = ~0;
2807
2482
         } else {
2808
 
            samples = VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT |
2809
 
                      VK_SAMPLE_COUNT_8_BIT;
 
2483
            samples = VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_2_BIT | VK_SAMPLE_COUNT_4_BIT | VK_SAMPLE_COUNT_8_BIT;
2810
2484
         }
2811
2485
 
2812
2486
         append_rate(x, y, samples);
2816
2490
 
2817
2491
   return vk_outarray_status(&out);
2818
2492
}
 
2493
 
 
2494
/* VK_EXT_tooling_info */
 
2495
VKAPI_ATTR VkResult VKAPI_CALL
 
2496
radv_GetPhysicalDeviceToolProperties(VkPhysicalDevice physicalDevice, uint32_t *pToolCount,
 
2497
                                     VkPhysicalDeviceToolProperties *pToolProperties)
 
2498
{
 
2499
   VK_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
 
2500
 
 
2501
   VK_OUTARRAY_MAKE_TYPED(VkPhysicalDeviceToolProperties, out, pToolProperties, pToolCount);
 
2502
   bool rgp_enabled, rmv_enabled, rra_enabled;
 
2503
   uint32_t tool_count = 0;
 
2504
 
 
2505
   /* RGP */
 
2506
   rgp_enabled = pdevice->instance->vk.trace_mode & RADV_TRACE_MODE_RGP;
 
2507
   if (rgp_enabled)
 
2508
      tool_count++;
 
2509
 
 
2510
   /* RMV */
 
2511
   rmv_enabled = pdevice->instance->vk.trace_mode & VK_TRACE_MODE_RMV;
 
2512
   if (rmv_enabled)
 
2513
      tool_count++;
 
2514
 
 
2515
   /* RRA */
 
2516
   rra_enabled = pdevice->instance->vk.trace_mode & RADV_TRACE_MODE_RRA;
 
2517
   if (rra_enabled)
 
2518
      tool_count++;
 
2519
 
 
2520
   if (!pToolProperties) {
 
2521
      *pToolCount = tool_count;
 
2522
      return VK_SUCCESS;
 
2523
   }
 
2524
 
 
2525
   if (rgp_enabled) {
 
2526
      VkPhysicalDeviceToolProperties tool = {
 
2527
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES,
 
2528
         .name = "Radeon GPU Profiler",
 
2529
         .version = "1.15",
 
2530
         .description = "A ground-breaking low-level optimization tool that provides detailed "
 
2531
                        "information on Radeon GPUs.",
 
2532
         .purposes = VK_TOOL_PURPOSE_PROFILING_BIT | VK_TOOL_PURPOSE_TRACING_BIT |
 
2533
                     /* VK_EXT_debug_marker is only exposed if SQTT is enabled. */
 
2534
                     VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT | VK_TOOL_PURPOSE_DEBUG_MARKERS_BIT_EXT,
 
2535
      };
 
2536
      vk_outarray_append_typed(VkPhysicalDeviceToolProperties, &out, t) *t = tool;
 
2537
   }
 
2538
 
 
2539
   if (rmv_enabled) {
 
2540
      VkPhysicalDeviceToolProperties tool = {
 
2541
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES,
 
2542
         .name = "Radeon Memory Visualizer",
 
2543
         .version = "1.6",
 
2544
         .description = "A tool to allow you to gain a deep understanding of how your application "
 
2545
                        "uses memory for graphics resources.",
 
2546
         .purposes = VK_TOOL_PURPOSE_PROFILING_BIT | VK_TOOL_PURPOSE_TRACING_BIT,
 
2547
      };
 
2548
      vk_outarray_append_typed(VkPhysicalDeviceToolProperties, &out, t) *t = tool;
 
2549
   }
 
2550
 
 
2551
   if (rra_enabled) {
 
2552
      VkPhysicalDeviceToolProperties tool = {
 
2553
         .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES,
 
2554
         .name = "Radeon Raytracing Analyzer",
 
2555
         .version = "1.2",
 
2556
         .description = "A tool to investigate the performance of your ray tracing applications and "
 
2557
                        "highlight potential bottlenecks.",
 
2558
         .purposes = VK_TOOL_PURPOSE_PROFILING_BIT | VK_TOOL_PURPOSE_TRACING_BIT,
 
2559
      };
 
2560
      vk_outarray_append_typed(VkPhysicalDeviceToolProperties, &out, t) *t = tool;
 
2561
   }
 
2562
 
 
2563
   return vk_outarray_status(&out);
 
2564
}