-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathCVulkanPhysicalDevice.cpp
More file actions
1966 lines (1639 loc) · 141 KB
/
Copy pathCVulkanPhysicalDevice.cpp
File metadata and controls
1966 lines (1639 loc) · 141 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "nbl/video/CVulkanPhysicalDevice.h"
#include "nbl/video/CVulkanLogicalDevice.h"
namespace nbl::video
{
#define RETURN_NULL_PHYSICAL_DEVICE \
do { \
logger.log("CVulkanPhysicalDevice::create returned nullptr at. [at %s:%d]", system::ILogger::ELL_INFO, __func__, __LINE__); \
return nullptr; \
} while(0)
std::unique_ptr<CVulkanPhysicalDevice> CVulkanPhysicalDevice::create(core::smart_refctd_ptr<system::ISystem>&& sys, IAPIConnection* const api, renderdoc_api_t* const rdoc, const VkPhysicalDevice vk_physicalDevice)
{
system::logger_opt_ptr logger = api->getDebugCallback()->getLogger();
IPhysicalDevice::SInitData initData = {std::move(sys),api};
bool success = false;
auto onExit = core::makeRAIIExiter([&]() {
if (!success)
{
logger.log("Physical Device Doesn't Support Nabla Core Profile", system::ILogger::ELL_INFO);
// TODO: Print full gpu limits and features
}
});
auto& properties = initData.properties;
auto& features = initData.features;
// First call just with Vulkan 1.0 API because:
// "The value of apiVersion may be different than the version returned by vkEnumerateInstanceVersion; either higher or lower.
// In such cases, the application must not use functionality that exceeds the version of Vulkan associated with a given object.
// The pApiVersion parameter returned by vkEnumerateInstanceVersion is the version associated with a VkInstance and its children,
// except for a VkPhysicalDevice and its children. VkPhysicalDeviceProperties::apiVersion is the version associated with a VkPhysicalDevice and its children."
VkPhysicalDeviceProperties vk_deviceProperties;
{
vkGetPhysicalDeviceProperties(vk_physicalDevice, &vk_deviceProperties);
if (vk_deviceProperties.apiVersion < MinimumVulkanApiVersion)
{
logger.log(
"Not enumerating VkPhysicalDevice %p because it does not support minimum required version %d, supports %d instead!, Make sure to Update your drivers.",
system::ILogger::ELL_INFO, vk_physicalDevice, MinimumVulkanApiVersion, vk_deviceProperties.apiVersion
);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.apiVersion.major = VK_API_VERSION_MAJOR(vk_deviceProperties.apiVersion);
properties.apiVersion.minor = VK_API_VERSION_MINOR(vk_deviceProperties.apiVersion);
properties.apiVersion.subminor = 0;
properties.apiVersion.patch = VK_API_VERSION_PATCH(vk_deviceProperties.apiVersion);
properties.driverVersion = vk_deviceProperties.driverVersion;
properties.vendorID = vk_deviceProperties.vendorID;
properties.deviceID = vk_deviceProperties.deviceID;
switch (vk_deviceProperties.deviceType)
{
case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
properties.deviceType = E_TYPE::ET_INTEGRATED_GPU;
break;
case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
properties.deviceType = E_TYPE::ET_DISCRETE_GPU;
break;
case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
properties.deviceType = E_TYPE::ET_VIRTUAL_GPU;
break;
case VK_PHYSICAL_DEVICE_TYPE_CPU:
properties.deviceType = E_TYPE::ET_CPU;
break;
default:
properties.deviceType = E_TYPE::ET_UNKNOWN;
}
memcpy(properties.deviceName, vk_deviceProperties.deviceName, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE);
memcpy(properties.pipelineCacheUUID, vk_deviceProperties.pipelineCacheUUID, VK_UUID_SIZE);
logger.log("Enumerating Physical Device: { Name = %s }, { Driver Version = %u }, { api Version = %d }", system::ILogger::ELL_INFO, initData.properties.deviceName, initData.properties.driverVersion, initData.properties.apiVersion);
// grab all limits we expose
properties.limits.maxImageDimension1D = vk_deviceProperties.limits.maxImageDimension1D;
properties.limits.maxImageDimension2D = vk_deviceProperties.limits.maxImageDimension2D;
properties.limits.maxImageDimension3D = vk_deviceProperties.limits.maxImageDimension3D;
properties.limits.maxImageDimensionCube = vk_deviceProperties.limits.maxImageDimensionCube;
properties.limits.maxImageArrayLayers = vk_deviceProperties.limits.maxImageArrayLayers;
properties.limits.maxBufferViewTexels = vk_deviceProperties.limits.maxTexelBufferElements;
properties.limits.maxUBOSize = vk_deviceProperties.limits.maxUniformBufferRange;
properties.limits.maxSSBOSize = vk_deviceProperties.limits.maxStorageBufferRange;
if (vk_deviceProperties.limits.maxPushConstantsSize > SLimits::MaxMaxPushConstantsSize)
{
logger.log(
"Encountered VkPhysicalDevice %p which has higher Push Constant Size (%d) limit than we anticipated (%d), clamping the reported value!",
system::ILogger::ELL_WARNING, vk_physicalDevice, vk_deviceProperties.limits.maxPushConstantsSize, SLimits::MaxMaxPushConstantsSize
);
properties.limits.maxPushConstantsSize = SLimits::MaxMaxPushConstantsSize;
}
else
properties.limits.maxPushConstantsSize = vk_deviceProperties.limits.maxPushConstantsSize;
properties.limits.maxMemoryAllocationCount = vk_deviceProperties.limits.maxMemoryAllocationCount;
properties.limits.maxSamplerAllocationCount = vk_deviceProperties.limits.maxSamplerAllocationCount;
properties.limits.bufferImageGranularity = vk_deviceProperties.limits.bufferImageGranularity;
//vk_deviceProperties.limits.sparseAddressSpaceSize;
// we hardcoded this in the engine to 4
if (vk_deviceProperties.limits.maxBoundDescriptorSets<4u)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports limits below Vulkan specification requirements!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.maxPerStageDescriptorSamplers = vk_deviceProperties.limits.maxPerStageDescriptorSamplers;
properties.limits.maxPerStageDescriptorUBOs = vk_deviceProperties.limits.maxPerStageDescriptorUniformBuffers;
properties.limits.maxPerStageDescriptorSSBOs = vk_deviceProperties.limits.maxPerStageDescriptorStorageBuffers;
properties.limits.maxPerStageDescriptorImages = vk_deviceProperties.limits.maxPerStageDescriptorSampledImages;
properties.limits.maxPerStageDescriptorStorageImages = vk_deviceProperties.limits.maxPerStageDescriptorStorageImages;
properties.limits.maxPerStageDescriptorInputAttachments = vk_deviceProperties.limits.maxPerStageDescriptorInputAttachments;
properties.limits.maxPerStageResources = vk_deviceProperties.limits.maxPerStageResources;
// Max Descriptors (too lazy to check GPU info what the values for these are, they depend on the number of supported stages)
// TODO: derive and implement checks according to https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#_required_limits
properties.limits.maxDescriptorSetSamplers = vk_deviceProperties.limits.maxDescriptorSetSamplers;
properties.limits.maxDescriptorSetUBOs = vk_deviceProperties.limits.maxDescriptorSetUniformBuffers;
properties.limits.maxDescriptorSetDynamicOffsetUBOs = vk_deviceProperties.limits.maxDescriptorSetUniformBuffersDynamic;
properties.limits.maxDescriptorSetSSBOs = vk_deviceProperties.limits.maxDescriptorSetStorageBuffers;
properties.limits.maxDescriptorSetDynamicOffsetSSBOs = vk_deviceProperties.limits.maxDescriptorSetStorageBuffersDynamic;
properties.limits.maxDescriptorSetImages = vk_deviceProperties.limits.maxDescriptorSetSampledImages;
properties.limits.maxDescriptorSetStorageImages = vk_deviceProperties.limits.maxDescriptorSetStorageImages;
properties.limits.maxDescriptorSetInputAttachments = vk_deviceProperties.limits.maxDescriptorSetInputAttachments;
// we don't even store this as everyone does these limits and we've hardcoded that
if (vk_deviceProperties.limits.maxVertexInputAttributes<16u || vk_deviceProperties.limits.maxVertexInputAttributeOffset<2047u)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports limits below Vulkan specification requirements!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
if (vk_deviceProperties.limits.maxVertexInputBindings<16u || vk_deviceProperties.limits.maxVertexInputBindingStride<2048u)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports limits below Vulkan specification requirements!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.maxVertexOutputComponents = vk_deviceProperties.limits.maxVertexOutputComponents;
properties.limits.maxTessellationGenerationLevel = vk_deviceProperties.limits.maxTessellationGenerationLevel;
properties.limits.maxTessellationPatchSize = vk_deviceProperties.limits.maxTessellationPatchSize;
properties.limits.maxTessellationControlPerVertexInputComponents = vk_deviceProperties.limits.maxTessellationControlPerVertexInputComponents;
properties.limits.maxTessellationControlPerVertexOutputComponents = vk_deviceProperties.limits.maxTessellationControlPerVertexOutputComponents;
properties.limits.maxTessellationControlPerPatchOutputComponents = vk_deviceProperties.limits.maxTessellationControlPerPatchOutputComponents;
properties.limits.maxTessellationControlTotalOutputComponents = vk_deviceProperties.limits.maxTessellationControlTotalOutputComponents;
properties.limits.maxTessellationEvaluationInputComponents = vk_deviceProperties.limits.maxTessellationEvaluationInputComponents;
properties.limits.maxTessellationEvaluationOutputComponents = vk_deviceProperties.limits.maxTessellationEvaluationOutputComponents;
properties.limits.maxGeometryShaderInvocations = vk_deviceProperties.limits.maxGeometryShaderInvocations;
properties.limits.maxGeometryInputComponents = vk_deviceProperties.limits.maxGeometryInputComponents;
properties.limits.maxGeometryOutputComponents = vk_deviceProperties.limits.maxGeometryOutputComponents;
properties.limits.maxGeometryOutputVertices = vk_deviceProperties.limits.maxGeometryOutputVertices;
properties.limits.maxGeometryTotalOutputComponents = vk_deviceProperties.limits.maxGeometryTotalOutputComponents;
properties.limits.maxFragmentInputComponents = vk_deviceProperties.limits.maxFragmentInputComponents;
properties.limits.maxFragmentOutputAttachments = vk_deviceProperties.limits.maxFragmentOutputAttachments;
properties.limits.maxFragmentDualSrcAttachments = vk_deviceProperties.limits.maxFragmentDualSrcAttachments;
properties.limits.maxFragmentCombinedOutputResources = vk_deviceProperties.limits.maxFragmentCombinedOutputResources;
properties.limits.maxComputeSharedMemorySize = vk_deviceProperties.limits.maxComputeSharedMemorySize;
properties.limits.maxComputeWorkGroupCount[0] = vk_deviceProperties.limits.maxComputeWorkGroupCount[0];
properties.limits.maxComputeWorkGroupCount[1] = vk_deviceProperties.limits.maxComputeWorkGroupCount[1];
properties.limits.maxComputeWorkGroupCount[2] = vk_deviceProperties.limits.maxComputeWorkGroupCount[2];
properties.limits.maxComputeWorkGroupInvocations = vk_deviceProperties.limits.maxComputeWorkGroupInvocations;
properties.limits.maxWorkgroupSize[0] = vk_deviceProperties.limits.maxComputeWorkGroupSize[0];
properties.limits.maxWorkgroupSize[1] = vk_deviceProperties.limits.maxComputeWorkGroupSize[1];
properties.limits.maxWorkgroupSize[2] = vk_deviceProperties.limits.maxComputeWorkGroupSize[2];
properties.limits.subPixelPrecisionBits = vk_deviceProperties.limits.subPixelPrecisionBits;
properties.limits.subTexelPrecisionBits = vk_deviceProperties.limits.subTexelPrecisionBits;
properties.limits.mipmapPrecisionBits = vk_deviceProperties.limits.mipmapPrecisionBits;
if (vk_deviceProperties.limits.maxDrawIndexedIndexValue!=0xffFFffFFu)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports a limit below ROADMAP2022 spec which is ubiquitously supported already!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.maxDrawIndirectCount = vk_deviceProperties.limits.maxDrawIndirectCount;
properties.limits.maxSamplerLodBias = vk_deviceProperties.limits.maxSamplerLodBias;
properties.limits.maxSamplerAnisotropyLog2 = static_cast<uint8_t>(std::log2(vk_deviceProperties.limits.maxSamplerAnisotropy));
properties.limits.maxViewports = vk_deviceProperties.limits.maxViewports;
properties.limits.maxViewportDims[0] = vk_deviceProperties.limits.maxViewportDimensions[0];
properties.limits.maxViewportDims[1] = vk_deviceProperties.limits.maxViewportDimensions[1];
properties.limits.viewportBoundsRange[0] = vk_deviceProperties.limits.viewportBoundsRange[0];
properties.limits.viewportBoundsRange[1] = vk_deviceProperties.limits.viewportBoundsRange[1];
properties.limits.viewportSubPixelBits = vk_deviceProperties.limits.viewportSubPixelBits;
properties.limits.minMemoryMapAlignment = vk_deviceProperties.limits.minMemoryMapAlignment;
properties.limits.bufferViewAlignment = vk_deviceProperties.limits.minTexelBufferOffsetAlignment;
properties.limits.minUBOAlignment = vk_deviceProperties.limits.minUniformBufferOffsetAlignment;
properties.limits.minSSBOAlignment = vk_deviceProperties.limits.minStorageBufferOffsetAlignment;
properties.limits.minTexelOffset = vk_deviceProperties.limits.minTexelOffset;
properties.limits.maxTexelOffset = vk_deviceProperties.limits.maxTexelOffset;
properties.limits.minTexelGatherOffset = vk_deviceProperties.limits.minTexelGatherOffset;
properties.limits.maxTexelGatherOffset = vk_deviceProperties.limits.maxTexelGatherOffset;
properties.limits.minInterpolationOffset = vk_deviceProperties.limits.minInterpolationOffset;
properties.limits.maxInterpolationOffset = vk_deviceProperties.limits.maxInterpolationOffset;
properties.limits.subPixelInterpolationOffsetBits = vk_deviceProperties.limits.subPixelInterpolationOffsetBits;
properties.limits.maxFramebufferWidth = vk_deviceProperties.limits.maxFramebufferWidth;
properties.limits.maxFramebufferHeight = vk_deviceProperties.limits.maxFramebufferHeight;
properties.limits.maxFramebufferLayers = vk_deviceProperties.limits.maxFramebufferLayers;
// not checking framebuffer sample count limits, will check in format reporting instead (TODO)
properties.limits.maxColorAttachments = vk_deviceProperties.limits.maxColorAttachments;
// not checking sampled image sample count limits, will check in format reporting instead (TODO)
properties.limits.maxSampleMaskWords = vk_deviceProperties.limits.maxSampleMaskWords;
if (!vk_deviceProperties.limits.timestampComputeAndGraphics)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports a limit below ROADMAP2022 spec which is ubiquitously supported already!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.timestampPeriodInNanoSeconds = vk_deviceProperties.limits.timestampPeriod;
properties.limits.maxClipDistances = vk_deviceProperties.limits.maxClipDistances;
properties.limits.maxCullDistances = vk_deviceProperties.limits.maxCullDistances;
properties.limits.maxCombinedClipAndCullDistances = vk_deviceProperties.limits.maxCombinedClipAndCullDistances;
properties.limits.discreteQueuePriorities = vk_deviceProperties.limits.discreteQueuePriorities;
properties.limits.pointSizeRange[0] = vk_deviceProperties.limits.pointSizeRange[0];
properties.limits.pointSizeRange[1] = vk_deviceProperties.limits.pointSizeRange[1];
properties.limits.lineWidthRange[0] = vk_deviceProperties.limits.lineWidthRange[0];
properties.limits.lineWidthRange[1] = vk_deviceProperties.limits.lineWidthRange[1];
properties.limits.pointSizeGranularity = vk_deviceProperties.limits.pointSizeGranularity;
properties.limits.lineWidthGranularity = vk_deviceProperties.limits.lineWidthGranularity;
properties.limits.strictLines = vk_deviceProperties.limits.strictLines;
properties.limits.standardSampleLocations = vk_deviceProperties.limits.standardSampleLocations;
properties.limits.optimalBufferCopyOffsetAlignment = vk_deviceProperties.limits.optimalBufferCopyOffsetAlignment;
properties.limits.optimalBufferCopyRowPitchAlignment = vk_deviceProperties.limits.optimalBufferCopyRowPitchAlignment;
properties.limits.nonCoherentAtomSize = vk_deviceProperties.limits.nonCoherentAtomSize;
/* TODO Verify
constexpr uint32_t MaxRoadmap2022PerStageResources = 200u;
const uint32_t MaxResources = core::min(MaxRoadmap2022PerStageResources,
properties.limits.maxPerStageDescriptorUBOs+properties.limits.maxPerStageDescriptorSSBOs+
properties.limits.maxPerStageDescriptorImages+properties.limits.maxPerStageDescriptorStorageImages+
properties.limits.maxPerStageDescriptorInputAttachments+properties.limits.maxColorAttachments
);
if (vk_deviceProperties.limits.maxPerStageResources<MaxResources)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports limits below Vulkan specification requirements!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
*/
}
// Get Supported Extensions
core::unordered_set<std::string> availableFeatureSet;
{
uint32_t count;
VkResult res = vkEnumerateDeviceExtensionProperties(vk_physicalDevice,nullptr,&count,nullptr);
assert(VK_SUCCESS==res);
core::vector<VkExtensionProperties> vk_extensions(count);
res = vkEnumerateDeviceExtensionProperties(vk_physicalDevice,nullptr,&count,vk_extensions.data());
assert(VK_SUCCESS==res);
for (const auto& vk_extension : vk_extensions)
availableFeatureSet.insert(vk_extension.extensionName);
}
auto isExtensionSupported = [&availableFeatureSet](const char* name)->bool
{
return availableFeatureSet.find(name)!=availableFeatureSet.end();
};
//! Required by Nabla Core Profile
if (!rdoc && !isExtensionSupported(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME))
RETURN_NULL_PHYSICAL_DEVICE;
if (!isExtensionSupported(VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME))
RETURN_NULL_PHYSICAL_DEVICE;
if (!isExtensionSupported(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME))
RETURN_NULL_PHYSICAL_DEVICE;
// At least one of these two must be available
if (!isExtensionSupported(VK_KHR_MAINTENANCE_5_EXTENSION_NAME) && !isExtensionSupported(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME))
RETURN_NULL_PHYSICAL_DEVICE;
// Basic stuff for constructing pNext chains
VkBaseInStructure* pNextTail;
auto setPNextChainTail = [&pNextTail](void* structure) -> void {pNextTail = reinterpret_cast<VkBaseInStructure*>(structure);};
auto addToPNextChain = [&pNextTail](void* structure) -> void
{
auto toAdd = reinterpret_cast<VkBaseInStructure*>(structure);
pNextTail->pNext = toAdd;
pNextTail = toAdd;
};
auto finalizePNextChain = [&pNextTail]() -> void
{
pNextTail->pNext = nullptr;
};
// Get physical device's limits/properties
VkPhysicalDeviceProperties2 deviceProperties2 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 };
setPNextChainTail(&deviceProperties2);
// !! Our minimum supported Vulkan version is 1.1, no need to check anything before using `vulkan11Properties`
VkPhysicalDeviceVulkan11Properties vulkan11Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES };
addToPNextChain(&vulkan11Properties);
//! Declare all the property structs before so they don't go out of scope
//! Provided by Vk 1.2
VkPhysicalDeviceVulkan12Properties vulkan12Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES };
addToPNextChain(&vulkan12Properties);
//! Provided by Vk 1.3
VkPhysicalDeviceVulkan13Properties vulkan13Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES };
addToPNextChain(&vulkan13Properties);
//! Required by Nabla Core Profile
VkPhysicalDeviceExternalMemoryHostPropertiesEXT externalMemoryHostProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT };
VkPhysicalDeviceRobustness2PropertiesEXT robustness2Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT };
addToPNextChain(&robustness2Properties);
//! Extensions (ordered by spec extension number)
VkPhysicalDeviceConservativeRasterizationPropertiesEXT conservativeRasterizationProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT };
VkPhysicalDeviceDiscardRectanglePropertiesEXT discardRectangleProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT };
VkPhysicalDeviceSampleLocationsPropertiesEXT sampleLocationsProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT };
VkPhysicalDeviceAccelerationStructurePropertiesKHR accelerationStructureProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR };
VkPhysicalDevicePCIBusInfoPropertiesEXT PCIBusInfoProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT };
VkPhysicalDeviceFragmentDensityMapPropertiesEXT fragmentDensityMapProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT };
VkPhysicalDeviceLineRasterizationPropertiesEXT lineRasterizationProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT };
//VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT graphicsPipelineLibraryProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT };
VkPhysicalDeviceFragmentDensityMap2PropertiesEXT fragmentDensityMap2Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT };
VkPhysicalDeviceRayTracingPipelinePropertiesKHR rayTracingPipelineProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR };
VkPhysicalDeviceCooperativeMatrixPropertiesKHR cooperativeMatrixProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR };
VkPhysicalDeviceShaderSMBuiltinsPropertiesNV shaderSMBuiltinsPropertiesNV = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV };
VkPhysicalDeviceShaderCoreProperties2AMD shaderCoreProperties2AMD = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD };
VkPhysicalDeviceHostImageCopyPropertiesEXT hostImageCopyProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT };
VkPhysicalDeviceMaintenance5PropertiesKHR maintenance5Properties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR };
VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT graphicsPipelineLibraryProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT };
VkPhysicalDeviceRayTracingInvocationReorderPropertiesEXT rayTracingInvocationReorderProperties = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_PROPERTIES_EXT };
{
//! Because Renderdoc is special and instead of ignoring extensions it whitelists them
if (isExtensionSupported(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME))
addToPNextChain(&externalMemoryHostProperties);
//! This is only written for convenience to avoid getting validation errors otherwise vulkan will just skip any strutctures it doesn't recognize
if (isExtensionSupported(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME))
addToPNextChain(&conservativeRasterizationProperties);
if (isExtensionSupported(VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME))
addToPNextChain(&discardRectangleProperties);
if (isExtensionSupported(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME))
addToPNextChain(&sampleLocationsProperties);
if (isExtensionSupported(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME))
addToPNextChain(&accelerationStructureProperties);
if (isExtensionSupported(VK_EXT_PCI_BUS_INFO_EXTENSION_NAME))
addToPNextChain(&PCIBusInfoProperties);
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME))
addToPNextChain(&fragmentDensityMapProperties);
if (isExtensionSupported(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME))
addToPNextChain(&lineRasterizationProperties);
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME))
addToPNextChain(&fragmentDensityMap2Properties);
if (isExtensionSupported(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME))
addToPNextChain(&rayTracingPipelineProperties);
if (isExtensionSupported(VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME))
addToPNextChain(&cooperativeMatrixProperties);
if (isExtensionSupported(VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME))
addToPNextChain(&shaderSMBuiltinsPropertiesNV);
if (isExtensionSupported(VK_AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME))
addToPNextChain(&shaderCoreProperties2AMD);
if (isExtensionSupported(VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME))
addToPNextChain(&hostImageCopyProperties);
if (isExtensionSupported(VK_KHR_MAINTENANCE_5_EXTENSION_NAME))
addToPNextChain(&maintenance5Properties);
if (isExtensionSupported(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME))
addToPNextChain(&graphicsPipelineLibraryProperties);
if (isExtensionSupported(VK_EXT_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME))
addToPNextChain(&rayTracingInvocationReorderProperties);
// call
finalizePNextChain();
vkGetPhysicalDeviceProperties2(vk_physicalDevice,&deviceProperties2);
/* Vulkan 1.1 Core */
memcpy(properties.deviceUUID, vulkan11Properties.deviceUUID, VK_UUID_SIZE);
memcpy(properties.driverUUID, vulkan11Properties.driverUUID, VK_UUID_SIZE);
memcpy(properties.deviceLUID, vulkan11Properties.deviceLUID, VK_LUID_SIZE);
properties.deviceNodeMask = vulkan11Properties.deviceNodeMask;
properties.deviceLUIDValid = vulkan11Properties.deviceLUIDValid;
properties.limits.subgroupSize = vulkan11Properties.subgroupSize;
properties.limits.subgroupOpsShaderStages = static_cast<hlsl::ShaderStage>(vulkan11Properties.subgroupSupportedStages);
// ROADMAP 2022 would also like ARITHMETIC and QUAD
constexpr uint32_t NablaSubgroupOperationMask = VK_SUBGROUP_FEATURE_BASIC_BIT|VK_SUBGROUP_FEATURE_VOTE_BIT|VK_SUBGROUP_FEATURE_BALLOT_BIT|VK_SUBGROUP_FEATURE_SHUFFLE_BIT|VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT;
if ((vulkan11Properties.subgroupSupportedOperations&NablaSubgroupOperationMask)!=NablaSubgroupOperationMask)
{
logger.log(
"Not enumerating VkPhysicalDevice %p because its supported subgroup op bitmask is %d and we require at least %d!",
system::ILogger::ELL_INFO, vk_physicalDevice, vulkan11Properties.subgroupSupportedOperations, NablaSubgroupOperationMask
);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.shaderSubgroupArithmetic = vulkan11Properties.subgroupSupportedOperations & VK_SUBGROUP_FEATURE_ARITHMETIC_BIT;
properties.limits.shaderSubgroupClustered = vulkan11Properties.subgroupSupportedOperations & VK_SUBGROUP_FEATURE_CLUSTERED_BIT;
properties.limits.shaderSubgroupQuad = vulkan11Properties.subgroupSupportedOperations & VK_SUBGROUP_FEATURE_QUAD_BIT;
properties.limits.shaderSubgroupQuadAllStages = vulkan11Properties.subgroupQuadOperationsInAllStages;
properties.limits.pointClippingBehavior = static_cast<SLimits::E_POINT_CLIPPING_BEHAVIOR>(vulkan11Properties.pointClippingBehavior);
properties.limits.maxMultiviewViewCount = vulkan11Properties.maxMultiviewViewCount;
properties.limits.maxMultiviewInstanceIndex = vulkan11Properties.maxMultiviewInstanceIndex;
//vulkan11Properties.protectedNoFault;
properties.limits.maxPerSetDescriptors = vulkan11Properties.maxPerSetDescriptors;
properties.limits.maxMemoryAllocationSize = vulkan11Properties.maxMemoryAllocationSize;
/* Vulkan 1.2 Core */
properties.driverID = getDriverIdFromVkDriverId(vulkan12Properties.driverID);
memcpy(properties.driverName, vulkan12Properties.driverName, VK_MAX_DRIVER_NAME_SIZE);
memcpy(properties.driverInfo, vulkan12Properties.driverInfo, VK_MAX_DRIVER_INFO_SIZE);
properties.conformanceVersion.major = vulkan12Properties.conformanceVersion.major;
properties.conformanceVersion.minor = vulkan12Properties.conformanceVersion.minor;
properties.conformanceVersion.subminor = vulkan12Properties.conformanceVersion.subminor;
properties.conformanceVersion.patch = vulkan12Properties.conformanceVersion.patch;
// Helper bools :D
const bool isIntelGPU = (properties.driverID == E_DRIVER_ID::EDI_INTEL_OPEN_SOURCE_MESA || properties.driverID == E_DRIVER_ID::EDI_INTEL_PROPRIETARY_WINDOWS);
const bool isAMDGPU = (properties.driverID == E_DRIVER_ID::EDI_AMD_OPEN_SOURCE || properties.driverID == E_DRIVER_ID::EDI_AMD_PROPRIETARY);
const bool isNVIDIAGPU = (properties.driverID == E_DRIVER_ID::EDI_NVIDIA_PROPRIETARY);
//vulkan12Properties.denormBehaviorIndependence;
//vulkan12Properties.denormBehaviorIndependence;
//! preserve of 16bit float checked later when features are known
if (!vulkan12Properties.shaderSignedZeroInfNanPreserveFloat32)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.shaderSignedZeroInfNanPreserveFloat64 = vulkan12Properties.shaderSignedZeroInfNanPreserveFloat64;
properties.limits.shaderDenormPreserveFloat16 = vulkan12Properties.shaderDenormPreserveFloat16;
properties.limits.shaderDenormPreserveFloat32 = vulkan12Properties.shaderDenormPreserveFloat32;
properties.limits.shaderDenormPreserveFloat64 = vulkan12Properties.shaderDenormPreserveFloat64;
properties.limits.shaderDenormFlushToZeroFloat16 = vulkan12Properties.shaderDenormFlushToZeroFloat16;
properties.limits.shaderDenormFlushToZeroFloat32 = vulkan12Properties.shaderDenormFlushToZeroFloat32;
properties.limits.shaderDenormFlushToZeroFloat64 = vulkan12Properties.shaderDenormFlushToZeroFloat64;
properties.limits.shaderRoundingModeRTEFloat16 = vulkan12Properties.shaderRoundingModeRTEFloat16;
properties.limits.shaderRoundingModeRTEFloat32 = vulkan12Properties.shaderRoundingModeRTEFloat32;
properties.limits.shaderRoundingModeRTEFloat64 = vulkan12Properties.shaderRoundingModeRTEFloat64;
properties.limits.shaderRoundingModeRTZFloat16 = vulkan12Properties.shaderRoundingModeRTZFloat16;
properties.limits.shaderRoundingModeRTZFloat32 = vulkan12Properties.shaderRoundingModeRTZFloat32;
properties.limits.shaderRoundingModeRTZFloat64 = vulkan12Properties.shaderRoundingModeRTZFloat64;
// descriptor indexing
properties.limits.maxUpdateAfterBindDescriptorsInAllPools = vulkan12Properties.maxUpdateAfterBindDescriptorsInAllPools;
properties.limits.shaderUniformBufferArrayNonUniformIndexingNative = vulkan12Properties.shaderUniformBufferArrayNonUniformIndexingNative;
properties.limits.shaderSampledImageArrayNonUniformIndexingNative = vulkan12Properties.shaderSampledImageArrayNonUniformIndexingNative;
properties.limits.shaderStorageBufferArrayNonUniformIndexingNative = vulkan12Properties.shaderStorageBufferArrayNonUniformIndexingNative;
properties.limits.shaderStorageImageArrayNonUniformIndexingNative = vulkan12Properties.shaderStorageImageArrayNonUniformIndexingNative;
properties.limits.shaderInputAttachmentArrayNonUniformIndexingNative = vulkan12Properties.shaderInputAttachmentArrayNonUniformIndexingNative;
properties.limits.robustBufferAccessUpdateAfterBind = vulkan12Properties.robustBufferAccessUpdateAfterBind;
properties.limits.quadDivergentImplicitLod = vulkan12Properties.quadDivergentImplicitLod;
properties.limits.maxPerStageDescriptorUpdateAfterBindSamplers = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSamplers;
properties.limits.maxPerStageDescriptorUpdateAfterBindUBOs = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindUniformBuffers;
properties.limits.maxPerStageDescriptorUpdateAfterBindSSBOs = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageBuffers;
properties.limits.maxPerStageDescriptorUpdateAfterBindImages = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindSampledImages;
properties.limits.maxPerStageDescriptorUpdateAfterBindStorageImages = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindStorageImages;
properties.limits.maxPerStageDescriptorUpdateAfterBindInputAttachments = vulkan12Properties.maxPerStageDescriptorUpdateAfterBindInputAttachments;
properties.limits.maxPerStageUpdateAfterBindResources = vulkan12Properties.maxPerStageUpdateAfterBindResources;
properties.limits.maxDescriptorSetUpdateAfterBindSamplers = vulkan12Properties.maxDescriptorSetUpdateAfterBindSamplers;
properties.limits.maxDescriptorSetUpdateAfterBindUBOs = vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffers;
properties.limits.maxDescriptorSetUpdateAfterBindDynamicOffsetUBOs = vulkan12Properties.maxDescriptorSetUpdateAfterBindUniformBuffersDynamic;
properties.limits.maxDescriptorSetUpdateAfterBindSSBOs = vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffers;
properties.limits.maxDescriptorSetUpdateAfterBindDynamicOffsetSSBOs = vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageBuffersDynamic;
properties.limits.maxDescriptorSetUpdateAfterBindImages = vulkan12Properties.maxDescriptorSetUpdateAfterBindSampledImages;
properties.limits.maxDescriptorSetUpdateAfterBindStorageImages = vulkan12Properties.maxDescriptorSetUpdateAfterBindStorageImages;
properties.limits.maxDescriptorSetUpdateAfterBindInputAttachments = vulkan12Properties.maxDescriptorSetUpdateAfterBindInputAttachments;
properties.limits.supportedDepthResolveModes = static_cast<nbl::hlsl::ResolveModeFlags>(vulkan12Properties.supportedDepthResolveModes);
properties.limits.supportedStencilResolveModes = static_cast<nbl::hlsl::ResolveModeFlags>(vulkan12Properties.supportedStencilResolveModes);
if (!vulkan12Properties.independentResolve || !vulkan12Properties.independentResolveNone)
RETURN_NULL_PHYSICAL_DEVICE;
// not dealing with vulkan12Properties.filterMinmaxSingleComponentFormats, TODO report in usage
properties.limits.filterMinmaxImageComponentMapping = vulkan12Properties.filterMinmaxImageComponentMapping;
constexpr uint64_t ROADMAP2022TimelineSemahoreValueDifference = (0x1ull<<31u)-1ull;
if (vulkan12Properties.maxTimelineSemaphoreValueDifference<ROADMAP2022TimelineSemahoreValueDifference)
RETURN_NULL_PHYSICAL_DEVICE;
// don't deal with vulkan12PRoperties.framebufferIntegerColorSampleCounts, TODO report in usage
/* Vulkan 1.3 Core */
properties.limits.minSubgroupSize = vulkan13Properties.minSubgroupSize;
properties.limits.maxSubgroupSize = vulkan13Properties.maxSubgroupSize;
properties.limits.maxComputeWorkgroupSubgroups = vulkan13Properties.maxComputeWorkgroupSubgroups;
properties.limits.requiredSubgroupSizeStages = static_cast<asset::IShader::E_SHADER_STAGE>(vulkan13Properties.requiredSubgroupSizeStages&VK_SHADER_STAGE_ALL);
// don't deal with inline uniform blocks yet
properties.limits.integerDotProduct8BitUnsignedAccelerated = vulkan13Properties.integerDotProduct8BitUnsignedAccelerated;
properties.limits.integerDotProduct8BitSignedAccelerated = vulkan13Properties.integerDotProduct8BitSignedAccelerated;
properties.limits.integerDotProduct8BitMixedSignednessAccelerated = vulkan13Properties.integerDotProduct8BitMixedSignednessAccelerated;
properties.limits.integerDotProduct4x8BitPackedUnsignedAccelerated = vulkan13Properties.integerDotProduct4x8BitPackedUnsignedAccelerated;
properties.limits.integerDotProduct4x8BitPackedSignedAccelerated = vulkan13Properties.integerDotProduct4x8BitPackedSignedAccelerated;
properties.limits.integerDotProduct4x8BitPackedMixedSignednessAccelerated = vulkan13Properties.integerDotProduct4x8BitPackedMixedSignednessAccelerated;
properties.limits.integerDotProduct16BitUnsignedAccelerated = vulkan13Properties.integerDotProduct16BitUnsignedAccelerated;
properties.limits.integerDotProduct16BitSignedAccelerated = vulkan13Properties.integerDotProduct16BitSignedAccelerated;
properties.limits.integerDotProduct16BitMixedSignednessAccelerated = vulkan13Properties.integerDotProduct16BitMixedSignednessAccelerated;
properties.limits.integerDotProduct32BitUnsignedAccelerated = vulkan13Properties.integerDotProduct32BitUnsignedAccelerated;
properties.limits.integerDotProduct32BitSignedAccelerated = vulkan13Properties.integerDotProduct32BitSignedAccelerated;
properties.limits.integerDotProduct32BitMixedSignednessAccelerated = vulkan13Properties.integerDotProduct32BitMixedSignednessAccelerated;
properties.limits.integerDotProduct64BitUnsignedAccelerated = vulkan13Properties.integerDotProduct64BitUnsignedAccelerated;
properties.limits.integerDotProduct64BitSignedAccelerated = vulkan13Properties.integerDotProduct64BitSignedAccelerated;
properties.limits.integerDotProduct64BitMixedSignednessAccelerated = vulkan13Properties.integerDotProduct64BitMixedSignednessAccelerated;
properties.limits.integerDotProductAccumulatingSaturating8BitUnsignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating8BitUnsignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating8BitSignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating8BitSignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated;
properties.limits.integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated;
properties.limits.integerDotProductAccumulatingSaturating16BitUnsignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating16BitUnsignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating16BitSignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating16BitSignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated;
properties.limits.integerDotProductAccumulatingSaturating32BitUnsignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating32BitUnsignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating32BitSignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating32BitSignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated;
properties.limits.integerDotProductAccumulatingSaturating64BitUnsignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating64BitUnsignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating64BitSignedAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating64BitSignedAccelerated;
properties.limits.integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated = vulkan13Properties.integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated;
properties.limits.storageTexelBufferOffsetAlignmentBytes = vulkan13Properties.storageTexelBufferOffsetAlignmentBytes;
// vulkan13Properties.storageTexelBufferOffsetSingleTexelAlignment;
properties.limits.uniformTexelBufferOffsetAlignmentBytes = vulkan13Properties.uniformTexelBufferOffsetAlignmentBytes;
// vulkan13Properties.uniformTexelBufferOffsetSingleTexelAlignment;
properties.limits.maxBufferSize = vulkan13Properties.maxBufferSize;
//! Nabla Core Extensions
if (isExtensionSupported(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME)) // renderdoc special
properties.limits.minImportedHostPointerAlignment = externalMemoryHostProperties.minImportedHostPointerAlignment;
// there's no ShaderAtomicFloatPropertiesEXT
properties.limits.robustStorageBufferAccessSizeAlignment = robustness2Properties.robustStorageBufferAccessSizeAlignment;
properties.limits.robustUniformBufferAccessSizeAlignment = robustness2Properties.robustUniformBufferAccessSizeAlignment;
//! Extensions
properties.limits.shaderTrinaryMinmax = isExtensionSupported(VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME);
properties.limits.shaderExplicitVertexParameter = isExtensionSupported(VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME);
properties.limits.gpuShaderHalfFloatAMD = isExtensionSupported(VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME);
properties.limits.shaderImageLoadStoreLod = isExtensionSupported(VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME);
properties.limits.displayTiming = isExtensionSupported(VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME);
if (isExtensionSupported(VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME))
properties.limits.maxDiscardRectangles = discardRectangleProperties.maxDiscardRectangles;
if (isExtensionSupported(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME))
{
properties.limits.primitiveOverestimationSize = conservativeRasterizationProperties.primitiveOverestimationSize;
properties.limits.maxExtraPrimitiveOverestimationSize = conservativeRasterizationProperties.maxExtraPrimitiveOverestimationSize;
properties.limits.extraPrimitiveOverestimationSizeGranularity = conservativeRasterizationProperties.extraPrimitiveOverestimationSizeGranularity;
properties.limits.primitiveUnderestimation = conservativeRasterizationProperties.primitiveUnderestimation;
properties.limits.conservativePointAndLineRasterization = conservativeRasterizationProperties.conservativePointAndLineRasterization;
properties.limits.degenerateTrianglesRasterized = conservativeRasterizationProperties.degenerateTrianglesRasterized;
properties.limits.degenerateLinesRasterized = conservativeRasterizationProperties.degenerateLinesRasterized;
properties.limits.fullyCoveredFragmentShaderInputVariable = conservativeRasterizationProperties.fullyCoveredFragmentShaderInputVariable;
properties.limits.conservativeRasterizationPostDepthCoverage = conservativeRasterizationProperties.conservativeRasterizationPostDepthCoverage;
}
properties.limits.queueFamilyForeign = isExtensionSupported(VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
properties.limits.shaderStencilExport = isExtensionSupported(VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME);
if (isExtensionSupported(VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME))
{
properties.limits.variableSampleLocations = sampleLocationsProperties.variableSampleLocations;
properties.limits.sampleLocationSubPixelBits = sampleLocationsProperties.sampleLocationSubPixelBits;
properties.limits.sampleLocationSampleCounts = static_cast<asset::IImage::E_SAMPLE_COUNT_FLAGS>(sampleLocationsProperties.sampleLocationSampleCounts);
properties.limits.maxSampleLocationGridSize = {sampleLocationsProperties.maxSampleLocationGridSize.width,sampleLocationsProperties.maxSampleLocationGridSize.height};
properties.limits.sampleLocationCoordinateRange[0] = sampleLocationsProperties.sampleLocationCoordinateRange[0];
properties.limits.sampleLocationCoordinateRange[1] = sampleLocationsProperties.sampleLocationCoordinateRange[1];
}
if (isExtensionSupported(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME))
{
properties.limits.maxAccelerationStructureGeometryCount = accelerationStructureProperties.maxGeometryCount;
properties.limits.maxAccelerationStructureInstanceCount = accelerationStructureProperties.maxInstanceCount;
properties.limits.maxAccelerationStructurePrimitiveCount = accelerationStructureProperties.maxPrimitiveCount;
properties.limits.maxPerStageDescriptorAccelerationStructures = accelerationStructureProperties.maxPerStageDescriptorAccelerationStructures;
properties.limits.maxPerStageDescriptorUpdateAfterBindAccelerationStructures = accelerationStructureProperties.maxPerStageDescriptorUpdateAfterBindAccelerationStructures;
properties.limits.maxDescriptorSetAccelerationStructures = accelerationStructureProperties.maxDescriptorSetAccelerationStructures;
properties.limits.maxDescriptorSetUpdateAfterBindAccelerationStructures = accelerationStructureProperties.maxDescriptorSetUpdateAfterBindAccelerationStructures;
properties.limits.minAccelerationStructureScratchOffsetAlignment = accelerationStructureProperties.minAccelerationStructureScratchOffsetAlignment;
}
properties.limits.postDepthCoverage = isExtensionSupported(VK_EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME);
if (isExtensionSupported(VK_EXT_PCI_BUS_INFO_EXTENSION_NAME))
{
properties.limits.pciDomain = PCIBusInfoProperties.pciDomain;
properties.limits.pciBus = PCIBusInfoProperties.pciBus;
properties.limits.pciDevice = PCIBusInfoProperties.pciDevice;
properties.limits.pciFunction = PCIBusInfoProperties.pciFunction;
}
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME))
{
properties.limits.minFragmentDensityTexelSize = {fragmentDensityMapProperties.minFragmentDensityTexelSize.width,fragmentDensityMapProperties.minFragmentDensityTexelSize.height};
properties.limits.maxFragmentDensityTexelSize = {fragmentDensityMapProperties.maxFragmentDensityTexelSize.width,fragmentDensityMapProperties.maxFragmentDensityTexelSize.height};
properties.limits.fragmentDensityInvocations = fragmentDensityMapProperties.fragmentDensityInvocations;
}
properties.limits.decorateString = isExtensionSupported(VK_GOOGLE_DECORATE_STRING_EXTENSION_NAME);
if (isExtensionSupported(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME))
properties.limits.lineSubPixelPrecisionBits = lineRasterizationProperties.lineSubPixelPrecisionBits;
properties.limits.shaderNonSemanticInfo = isExtensionSupported(VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME);
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME))
{
properties.limits.subsampledLoads = fragmentDensityMap2Properties.subsampledLoads;
properties.limits.subsampledCoarseReconstructionEarlyAccess = fragmentDensityMap2Properties.subsampledCoarseReconstructionEarlyAccess;
properties.limits.maxSubsampledArrayLayers = fragmentDensityMap2Properties.maxSubsampledArrayLayers;
properties.limits.maxDescriptorSetSubsampledSamplers = fragmentDensityMap2Properties.maxDescriptorSetSubsampledSamplers;
}
if (isExtensionSupported(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME))
{
if (rayTracingPipelineProperties.shaderGroupHandleSize!=32)
{
logger.log("Not enumerating VkPhysicalDevice %p because it reports limits of exact-type contrary to Vulkan specification!", system::ILogger::ELL_INFO, vk_physicalDevice);
RETURN_NULL_PHYSICAL_DEVICE;
}
properties.limits.maxRayRecursionDepth = rayTracingPipelineProperties.maxRayRecursionDepth;
properties.limits.maxShaderGroupStride = rayTracingPipelineProperties.maxShaderGroupStride;
properties.limits.shaderGroupBaseAlignment = rayTracingPipelineProperties.shaderGroupBaseAlignment;
properties.limits.maxRayDispatchInvocationCount = rayTracingPipelineProperties.maxRayDispatchInvocationCount;
properties.limits.shaderGroupHandleAlignment = rayTracingPipelineProperties.shaderGroupHandleAlignment;
properties.limits.maxRayHitAttributeSize = rayTracingPipelineProperties.maxRayHitAttributeSize;
}
if (isExtensionSupported(VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME))
properties.limits.cooperativeMatrixSupportedStages = static_cast<asset::IShader::E_SHADER_STAGE>(cooperativeMatrixProperties.cooperativeMatrixSupportedStages);
if (isExtensionSupported(VK_EXT_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME))
{
properties.limits.maxHitObjectReplacementSBTIndex = rayTracingInvocationReorderProperties.maxShaderBindingTableRecordIndex;
properties.limits.actuallyReordersRayTracingInvocations = rayTracingInvocationReorderProperties.rayTracingInvocationReorderReorderingHint==VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_EXT;
}
//! Nabla
if (isExtensionSupported(VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME))
properties.limits.computeUnits = shaderSMBuiltinsPropertiesNV.shaderSMCount;
else if(isExtensionSupported(VK_AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME))
properties.limits.computeUnits = shaderCoreProperties2AMD.activeComputeUnitCount;
//else if (isExtensionSupported(VK_ARM_..._EXTENSION_NAME)) TODO implement the ARM equivalent
else
properties.limits.computeUnits = getMaxComputeUnitsFromDriverID(properties.driverID);
properties.limits.dispatchBase = true;
properties.limits.allowCommandBufferQueryCopies = true; // TODO: REDO WE NOW SUPPORT PERF QUERIES always true in vk for all query types instead of PerformanceQuery which we don't support at the moment (have VkPhysicalDevicePerformanceQueryPropertiesKHR::allowCommandBufferQueryCopies in mind)
properties.limits.maxOptimallyResidentWorkgroupInvocations = core::min(core::roundDownToPoT(properties.limits.maxComputeWorkGroupInvocations),512u);
auto invocationsPerComputeUnit = getMaxInvocationsPerComputeUnitsFromDriverID(properties.driverID);
if(isExtensionSupported(VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME))
{
constexpr auto invocationsPerWarp = 32u; // unless Nvidia changed something recently
invocationsPerComputeUnit = shaderSMBuiltinsPropertiesNV.shaderWarpsPerSM*invocationsPerWarp;
}
properties.limits.maxResidentInvocations = properties.limits.computeUnits*invocationsPerComputeUnit;
/*
[NO NABLA SUPPORT] Vulkan 1.0 implementation must support the 1.0 version of SPIR-V and the 1.0 version of the SPIR-V Extended Instructions for GLSL. If the VK_KHR_spirv_1_4 extension is enabled, the implementation must additionally support the 1.4 version of SPIR-V.
[NO NABLA SUPPORT] A Vulkan 1.1 implementation must support the 1.0, 1.1, 1.2, and 1.3 versions of SPIR-V and the 1.0 version of the SPIR-V Extended Instructions for GLSL.
[NO NABLA SUPPORT] A Vulkan 1.2 implementation must support the 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 versions of SPIR-V and the 1.0 version of the SPIR-V Extended Instructions for GLSL.
A Vulkan 1.3 implementation must support the 1.0, 1.1, 1.2, 1.3, 1.4, and 1.5 versions of SPIR-V and the 1.0 version of the SPIR-V Extended Instructions for GLSL.
*/
properties.limits.spirvVersion = asset::IShaderCompiler::E_SPIRV_VERSION::ESV_1_6;
}
// ! In Vulkan: These will be reported based on availability of an extension and will be enabled by enabling an extension
// Table 51. Extension Feature Aliases (vkspec 1.3.211)
// Extension Feature(s)
// VK_KHR_shader_draw_parameters shaderDrawParameters
// VK_KHR_draw_indirect_count drawIndirectCount
// VK_KHR_sampler_mirror_clamp_to_edge samplerMirrorClampToEdge
// VK_EXT_descriptor_indexing descriptorIndexing
// VK_EXT_sampler_filter_minmax samplerFilterMinmax
// VK_EXT_shader_viewport_index_layer shaderOutputViewportIndex, shaderOutputLayer
// but we enable them all from Vulkan1XFeatures anyway!
// Get Device Features
{
VkPhysicalDeviceFeatures2 deviceFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 };
setPNextChainTail(&deviceFeatures);
// !! Our minimum supported Vulkan version is 1.1, no need to check anything before using `vulkan11Features`
VkPhysicalDeviceVulkan11Features vulkan11Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES };
addToPNextChain(&vulkan11Features);
//! Declare all the property structs before so they don't go out of scope
//! Provided by Vk 1.2
VkPhysicalDeviceVulkan12Features vulkan12Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES };
addToPNextChain(&vulkan12Features);
//! Provided by Vk 1.3
VkPhysicalDeviceVulkan13Features vulkan13Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES };
addToPNextChain(&vulkan13Features);
//! Nabla Core Profile Features
VkPhysicalDeviceShaderAtomicFloatFeaturesEXT shaderAtomicFloatFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT };
addToPNextChain(&shaderAtomicFloatFeatures);
VkPhysicalDeviceRobustness2FeaturesEXT robustness2Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT };
addToPNextChain(&robustness2Features);
//! Extensions (ordered by spec extension number)
VkPhysicalDeviceConditionalRenderingFeaturesEXT conditionalRenderingFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT };
VkPhysicalDevicePerformanceQueryFeaturesKHR performanceQueryFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR };
VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationStructureFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR };
VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR };
VkPhysicalDeviceShaderSMBuiltinsFeaturesNV shaderSMBuiltinsFeaturesNV = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV };
VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV representativeFragmentTestFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV };
VkPhysicalDeviceShaderClockFeaturesKHR shaderClockFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR };
VkPhysicalDeviceComputeShaderDerivativesFeaturesNV computeShaderDerivativesFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV };
VkPhysicalDeviceShaderImageFootprintFeaturesNV shaderImageFootprintFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV };
VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL intelShaderIntegerFunctions2 = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL };
VkPhysicalDeviceFragmentDensityMapFeaturesEXT fragmentDensityMapFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT };
VkPhysicalDeviceFragmentDensityMap2FeaturesEXT fragmentDensityMap2Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT };
VkPhysicalDeviceCoherentMemoryFeaturesAMD coherentMemoryFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD };
VkPhysicalDeviceMemoryPriorityFeaturesEXT memoryPriorityFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT };
VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT fragmentShaderInterlockFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT };
VkPhysicalDeviceLineRasterizationFeaturesEXT lineRasterizationFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT };
VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT shaderAtomicFloat2Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT };
VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT shaderImageAtomicInt64Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT };
VkPhysicalDeviceIndexTypeUint8FeaturesEXT indexTypeUint8Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT };
VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR pipelineExecutablePropertiesFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR };
VkPhysicalDeviceHostImageCopyFeaturesEXT hostImageCopyFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT };
VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV deviceGeneratedCommandsFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV };
VkPhysicalDeviceDeviceMemoryReportFeaturesEXT deviceMemoryReportFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT };
VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD shaderEarlyAndLateFragmentTestsFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD };
VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR fragmentShaderBarycentricFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR };
VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR subgroupUniformControlFlowFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR };
VkPhysicalDeviceRayTracingMotionBlurFeaturesNV rayTracingMotionBlurFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV };
VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR workgroupMemoryExplicitLayout = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR };
VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR raytracingMaintenance1Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR };
VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM rasterizationOrderAttachmentAccessFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM };
VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR rayTracingPositionFetchFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR };
VkPhysicalDeviceColorWriteEnableFeaturesEXT colorWriteEnableFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT };
VkPhysicalDeviceCooperativeMatrixFeaturesKHR cooperativeMatrixFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR };
VkPhysicalDeviceMaintenance5FeaturesKHR maintenance5Features = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR };
VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT graphicsPipelineLibraryFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT };
VkPhysicalDeviceRayTracingInvocationReorderFeaturesEXT rayTracingInvocationReorderFeatures = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_EXT };
if (isExtensionSupported(VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME))
addToPNextChain(&conditionalRenderingFeatures);
if (isExtensionSupported(VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME))
addToPNextChain(&performanceQueryFeatures);
if (isExtensionSupported(VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME) && isExtensionSupported(VK_KHR_RAY_TRACING_MAINTENANCE_1_EXTENSION_NAME))
{
addToPNextChain(&accelerationStructureFeatures);
addToPNextChain(&raytracingMaintenance1Features);
}
if (isExtensionSupported(VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME))
addToPNextChain(&rayTracingPipelineFeatures);
if (isExtensionSupported(VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME))
addToPNextChain(&shaderSMBuiltinsFeaturesNV);
if (isExtensionSupported(VK_NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME))
addToPNextChain(&representativeFragmentTestFeatures);
if (isExtensionSupported(VK_KHR_SHADER_CLOCK_EXTENSION_NAME))
addToPNextChain(&shaderClockFeatures);
if (isExtensionSupported(VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME))
addToPNextChain(&computeShaderDerivativesFeatures);
if (isExtensionSupported(VK_NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME))
addToPNextChain(&shaderImageFootprintFeatures);
if (isExtensionSupported(VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_EXTENSION_NAME))
addToPNextChain(&intelShaderIntegerFunctions2);
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME))
addToPNextChain(&fragmentDensityMapFeatures);
if (isExtensionSupported(VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME))
addToPNextChain(&fragmentDensityMap2Features);
if (isExtensionSupported(VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME))
addToPNextChain(&coherentMemoryFeatures);
if (isExtensionSupported(VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME))
addToPNextChain(&memoryPriorityFeatures);
if (isExtensionSupported(VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME))
addToPNextChain(&fragmentShaderInterlockFeatures);
if (isExtensionSupported(VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME))
addToPNextChain(&lineRasterizationFeatures);
if (isExtensionSupported(VK_EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME))
addToPNextChain(&shaderAtomicFloat2Features);
if (isExtensionSupported(VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME))
addToPNextChain(&shaderImageAtomicInt64Features);
if (isExtensionSupported(VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME))
addToPNextChain(&indexTypeUint8Features);
if (isExtensionSupported(VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME))
addToPNextChain(&pipelineExecutablePropertiesFeatures);
if (isExtensionSupported(VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME))
addToPNextChain(&hostImageCopyFeatures);
if (isExtensionSupported(VK_NV_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME))
addToPNextChain(&deviceGeneratedCommandsFeatures);
if (isExtensionSupported(VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME))
addToPNextChain(&deviceMemoryReportFeatures);
if (isExtensionSupported(VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME))
addToPNextChain(&shaderEarlyAndLateFragmentTestsFeatures);
if (isExtensionSupported(VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME))
addToPNextChain(&fragmentShaderBarycentricFeatures);
if (isExtensionSupported(VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME))
addToPNextChain(&subgroupUniformControlFlowFeatures);
if (isExtensionSupported(VK_NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME))
addToPNextChain(&rayTracingMotionBlurFeatures);
if (isExtensionSupported(VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME))
addToPNextChain(&workgroupMemoryExplicitLayout);
if (isExtensionSupported(VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME))
addToPNextChain(&rasterizationOrderAttachmentAccessFeatures);
if (isExtensionSupported(VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME))
addToPNextChain(&rayTracingPositionFetchFeatures);
if (isExtensionSupported(VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME))
addToPNextChain(&colorWriteEnableFeatures);
if (isExtensionSupported(VK_KHR_MAINTENANCE_5_EXTENSION_NAME))
addToPNextChain(&maintenance5Features);
if (isExtensionSupported(VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME))
addToPNextChain(&graphicsPipelineLibraryFeatures);
if (isExtensionSupported(VK_EXT_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME))
addToPNextChain(&rayTracingInvocationReorderFeatures);
// call
finalizePNextChain();
vkGetPhysicalDeviceFeatures2(vk_physicalDevice,&deviceFeatures);
/* Vulkan 1.0 Core */
features.robustBufferAccess = deviceFeatures.features.robustBufferAccess;
if (!deviceFeatures.features.fullDrawIndexUint32)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.imageCubeArray)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.independentBlend)
RETURN_NULL_PHYSICAL_DEVICE;
features.geometryShader = deviceFeatures.features.geometryShader;
features.tessellationShader = deviceFeatures.features.tessellationShader;
if (!deviceFeatures.features.sampleRateShading || !deviceFeatures.features.dualSrcBlend)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.logicOp = deviceFeatures.features.logicOp;
if (!deviceFeatures.features.multiDrawIndirect || !deviceFeatures.features.drawIndirectFirstInstance)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.depthClamp || !deviceFeatures.features.depthBiasClamp)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.fillModeNonSolid)
RETURN_NULL_PHYSICAL_DEVICE;
features.depthBounds = deviceFeatures.features.depthBounds;
features.wideLines = deviceFeatures.features.wideLines;
features.largePoints = deviceFeatures.features.largePoints;
features.alphaToOne = deviceFeatures.features.alphaToOne;
if (!deviceFeatures.features.multiViewport)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.samplerAnisotropy)
RETURN_NULL_PHYSICAL_DEVICE;
// no checking of deviceFeatures.features.textureCompression...
if (!deviceFeatures.features.occlusionQueryPrecise)
RETURN_NULL_PHYSICAL_DEVICE;
features.pipelineStatisticsQuery = deviceFeatures.features.pipelineStatisticsQuery;
properties.limits.vertexPipelineStoresAndAtomics = deviceFeatures.features.vertexPipelineStoresAndAtomics;
properties.limits.fragmentStoresAndAtomics = deviceFeatures.features.fragmentStoresAndAtomics;
properties.limits.shaderTessellationAndGeometryPointSize = deviceFeatures.features.shaderTessellationAndGeometryPointSize;
if (!deviceFeatures.features.shaderImageGatherExtended)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.shaderStorageImageExtendedFormats)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.shaderStorageImageMultisample = deviceFeatures.features.shaderStorageImageMultisample;
properties.limits.shaderStorageImageReadWithoutFormat = deviceFeatures.features.shaderStorageImageReadWithoutFormat;
if (!deviceFeatures.features.shaderStorageImageWriteWithoutFormat)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.shaderUniformBufferArrayDynamicIndexing || !deviceFeatures.features.shaderSampledImageArrayDynamicIndexing || !deviceFeatures.features.shaderStorageBufferArrayDynamicIndexing)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.shaderStorageImageArrayDynamicIndexing = deviceFeatures.features.shaderStorageImageArrayDynamicIndexing;
if (!deviceFeatures.features.shaderClipDistance)
RETURN_NULL_PHYSICAL_DEVICE;
features.shaderCullDistance = deviceFeatures.features.shaderCullDistance;
properties.limits.shaderFloat64 = deviceFeatures.features.shaderFloat64;
if (!deviceFeatures.features.shaderInt16)
RETURN_NULL_PHYSICAL_DEVICE;
if (!deviceFeatures.features.shaderInt64)
RETURN_NULL_PHYSICAL_DEVICE;
features.shaderResourceResidency = deviceFeatures.features.shaderResourceResidency;
features.shaderResourceMinLod = deviceFeatures.features.shaderResourceMinLod;
// TODO sparse stuff
properties.limits.variableMultisampleRate = deviceFeatures.features.variableMultisampleRate;
if (!deviceFeatures.features.inheritedQueries)
RETURN_NULL_PHYSICAL_DEVICE;
/* Vulkan 1.1 Core */
if (!vulkan11Features.storageBuffer16BitAccess || !vulkan11Features.uniformAndStorageBuffer16BitAccess)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.storagePushConstant16 = vulkan11Features.storagePushConstant16;
properties.limits.storageInputOutput16 = vulkan11Features.storageInputOutput16;
if (!vulkan11Features.multiview)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.multiviewGeometryShader = vulkan11Features.multiviewGeometryShader;
properties.limits.multiviewTessellationShader = vulkan11Features.multiviewTessellationShader;
if (!vulkan11Features.variablePointers || !vulkan11Features.variablePointersStorageBuffer)
RETURN_NULL_PHYSICAL_DEVICE;
// could check protectedMemory and YcbcrConversion but no point in doing so yet
if (!vulkan11Features.shaderDrawParameters)
RETURN_NULL_PHYSICAL_DEVICE;
/* Vulkan 1.2 Core */
if (!vulkan12Features.samplerMirrorClampToEdge)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.drawIndirectCount = vulkan12Features.drawIndirectCount;
if (!vulkan12Features.storageBuffer8BitAccess || !vulkan12Features.uniformAndStorageBuffer8BitAccess)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.storagePushConstant8 = vulkan12Features.storagePushConstant8;
properties.limits.shaderBufferInt64Atomics = vulkan12Features.shaderBufferInt64Atomics;
properties.limits.shaderSharedInt64Atomics = vulkan12Features.shaderSharedInt64Atomics;
properties.limits.shaderFloat16 = vulkan12Features.shaderFloat16;
if (!vulkan12Features.shaderFloat16)
{
// only fail if 16bit floats can be used
if (!vulkan12Properties.shaderSignedZeroInfNanPreserveFloat16)
RETURN_NULL_PHYSICAL_DEVICE;
}
if (!vulkan12Features.shaderInt8)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.descriptorIndexing)
RETURN_NULL_PHYSICAL_DEVICE;
// dynamically uniform
properties.limits.shaderInputAttachmentArrayDynamicIndexing = vulkan12Features.shaderInputAttachmentArrayDynamicIndexing;
if (!vulkan12Features.shaderUniformTexelBufferArrayDynamicIndexing || !vulkan12Features.shaderStorageTexelBufferArrayDynamicIndexing)
RETURN_NULL_PHYSICAL_DEVICE;
// not uniform at all
properties.limits.shaderUniformBufferArrayNonUniformIndexing = vulkan12Features.shaderUniformBufferArrayNonUniformIndexing;
if (!vulkan12Features.shaderSampledImageArrayNonUniformIndexing || !vulkan12Features.shaderStorageBufferArrayNonUniformIndexing || !vulkan12Features.shaderStorageImageArrayNonUniformIndexing)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.shaderInputAttachmentArrayNonUniformIndexing = vulkan12Features.shaderInputAttachmentArrayNonUniformIndexing;
if (!vulkan12Features.shaderUniformTexelBufferArrayNonUniformIndexing || !vulkan12Features.shaderStorageTexelBufferArrayNonUniformIndexing)
RETURN_NULL_PHYSICAL_DEVICE;
// update after bind
properties.limits.descriptorBindingUniformBufferUpdateAfterBind = vulkan12Features.descriptorBindingUniformBufferUpdateAfterBind;
if (!vulkan12Features.descriptorBindingSampledImageUpdateAfterBind || !vulkan12Features.descriptorBindingStorageImageUpdateAfterBind ||
!vulkan12Features.descriptorBindingStorageBufferUpdateAfterBind || !vulkan12Features.descriptorBindingUniformTexelBufferUpdateAfterBind ||
!vulkan12Features.descriptorBindingStorageTexelBufferUpdateAfterBind || !vulkan12Features.descriptorBindingUpdateUnusedWhilePending)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.descriptorBindingPartiallyBound || !vulkan12Features.descriptorBindingVariableDescriptorCount)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.runtimeDescriptorArray)
RETURN_NULL_PHYSICAL_DEVICE;
properties.limits.samplerFilterMinmax = vulkan12Features.samplerFilterMinmax;
if (!vulkan12Features.scalarBlockLayout)
RETURN_NULL_PHYSICAL_DEVICE;
// not checking imageless Framebuffer
if (!vulkan12Features.uniformBufferStandardLayout)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.shaderSubgroupExtendedTypes)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.separateDepthStencilLayouts)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.hostQueryReset)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.timelineSemaphore)
RETURN_NULL_PHYSICAL_DEVICE;
if (!vulkan12Features.bufferDeviceAddress)
RETURN_NULL_PHYSICAL_DEVICE;
features.bufferDeviceAddressMultiDevice = vulkan12Features.bufferDeviceAddressMultiDevice;
if (!vulkan12Features.vulkanMemoryModel || !vulkan12Features.vulkanMemoryModelDeviceScope)