@@ -21,15 +21,33 @@ PhysicalDevice::PhysicalDevice(VkPhysicalDevice physical_device_handle)
21
21
: handle(physical_device_handle),
22
22
properties{},
23
23
memory_properties{},
24
+ shader_16bit_storage{
25
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES},
26
+ shader_8bit_storage{
27
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES},
28
+ shader_float16_int8_types{
29
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR},
24
30
queue_families{},
25
31
num_compute_queues (0 ),
26
32
has_unified_memory (false ),
27
33
has_timestamps (properties.limits.timestampComputeAndGraphics),
28
- timestamp_period (properties.limits.timestampPeriod) {
34
+ timestamp_period (properties.limits.timestampPeriod),
35
+ extension_features (&shader_16bit_storage) {
29
36
// Extract physical device properties
30
37
vkGetPhysicalDeviceProperties (handle, &properties);
31
38
vkGetPhysicalDeviceMemoryProperties (handle, &memory_properties);
32
39
40
+ VkPhysicalDeviceFeatures2 features2{
41
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
42
+
43
+ // Create linked list to query availability of extensions
44
+ features2.pNext = &shader_16bit_storage;
45
+ shader_16bit_storage.pNext = &shader_8bit_storage;
46
+ shader_8bit_storage.pNext = &shader_float16_int8_types;
47
+ shader_float16_int8_types.pNext = nullptr ;
48
+
49
+ vkGetPhysicalDeviceFeatures2 (handle, &features2);
50
+
33
51
// Check if there are any memory types have both the HOST_VISIBLE and the
34
52
// DEVICE_LOCAL property flags
35
53
const VkMemoryPropertyFlags unified_memory_flags =
@@ -140,6 +158,9 @@ VkDevice create_logical_device(
140
158
#ifdef VK_KHR_portability_subset
141
159
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
142
160
#endif /* VK_KHR_portability_subset */
161
+ VK_KHR_16BIT_STORAGE_EXTENSION_NAME,
162
+ VK_KHR_8BIT_STORAGE_EXTENSION_NAME,
163
+ VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME,
143
164
};
144
165
145
166
std::vector<const char *> enabled_device_extensions;
@@ -148,7 +169,7 @@ VkDevice create_logical_device(
148
169
enabled_device_extensions,
149
170
requested_device_extensions);
150
171
151
- const VkDeviceCreateInfo device_create_info{
172
+ VkDeviceCreateInfo device_create_info{
152
173
VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, // sType
153
174
nullptr , // pNext
154
175
0u , // flags
@@ -162,6 +183,8 @@ VkDevice create_logical_device(
162
183
nullptr , // pEnabledFeatures
163
184
};
164
185
186
+ device_create_info.pNext = physical_device.extension_features ;
187
+
165
188
VkDevice handle = nullptr ;
166
189
VK_CHECK (vkCreateDevice (
167
190
physical_device.handle , &device_create_info, nullptr , &handle));
@@ -371,33 +394,53 @@ std::string Adapter::stringize() const {
371
394
ss << " deviceType: " << device_type << std::endl;
372
395
ss << " deviceName: " << properties.deviceName << std::endl;
373
396
374
- #define PRINT_LIMIT_PROP ( name ) \
375
- ss << " " << std::left << std::setw (36 ) << #name << limits .name \
397
+ #define PRINT_PROP ( struct, name ) \
398
+ ss << " " << std::left << std::setw (36 ) << #name << struct .name \
376
399
<< std::endl;
377
400
378
- #define PRINT_LIMIT_PROP_VEC3 ( name ) \
379
- ss << " " << std::left << std::setw (36 ) << #name << limits .name [0 ] \
380
- << " ," << limits .name [1 ] << " ," << limits .name [2 ] << std::endl;
401
+ #define PRINT_PROP_VEC3 ( struct, name ) \
402
+ ss << " " << std::left << std::setw(36 ) << #name << struct .name[0 ] \
403
+ << " ," << struct .name[1 ] << " ," << struct .name[2 ] << std::endl;
381
404
382
405
ss << " Physical Device Limits {" << std::endl;
383
- PRINT_LIMIT_PROP (maxImageDimension1D);
384
- PRINT_LIMIT_PROP (maxImageDimension2D);
385
- PRINT_LIMIT_PROP (maxImageDimension3D);
386
- PRINT_LIMIT_PROP (maxTexelBufferElements);
387
- PRINT_LIMIT_PROP (maxPushConstantsSize);
388
- PRINT_LIMIT_PROP (maxMemoryAllocationCount);
389
- PRINT_LIMIT_PROP (maxSamplerAllocationCount);
390
- PRINT_LIMIT_PROP (maxComputeSharedMemorySize);
391
- PRINT_LIMIT_PROP_VEC3 (maxComputeWorkGroupCount);
392
- PRINT_LIMIT_PROP (maxComputeWorkGroupInvocations);
393
- PRINT_LIMIT_PROP_VEC3 (maxComputeWorkGroupSize);
406
+ PRINT_PROP (limits, maxImageDimension1D);
407
+ PRINT_PROP (limits, maxImageDimension2D);
408
+ PRINT_PROP (limits, maxImageDimension3D);
409
+ PRINT_PROP (limits, maxTexelBufferElements);
410
+ PRINT_PROP (limits, maxPushConstantsSize);
411
+ PRINT_PROP (limits, maxMemoryAllocationCount);
412
+ PRINT_PROP (limits, maxSamplerAllocationCount);
413
+ PRINT_PROP (limits, maxComputeSharedMemorySize);
414
+ PRINT_PROP_VEC3 (limits, maxComputeWorkGroupCount);
415
+ PRINT_PROP (limits, maxComputeWorkGroupInvocations);
416
+ PRINT_PROP_VEC3 (limits, maxComputeWorkGroupSize);
417
+ ss << " }" << std::endl;
418
+
419
+ ss << " 16bit Storage Features {" << std::endl;
420
+ PRINT_PROP (physical_device_.shader_16bit_storage, storageBuffer16BitAccess);
421
+ PRINT_PROP (
422
+ physical_device_.shader_16bit_storage,
423
+ uniformAndStorageBuffer16BitAccess);
424
+ PRINT_PROP (physical_device_.shader_16bit_storage, storagePushConstant16);
425
+ PRINT_PROP (physical_device_.shader_16bit_storage, storageInputOutput16);
426
+ ss << " }" << std::endl;
427
+
428
+ ss << " 8bit Storage Features {" << std::endl;
429
+ PRINT_PROP (physical_device_.shader_8bit_storage, storageBuffer8BitAccess);
430
+ PRINT_PROP (
431
+ physical_device_.shader_8bit_storage, uniformAndStorageBuffer8BitAccess);
432
+ PRINT_PROP (physical_device_.shader_8bit_storage, storagePushConstant8);
433
+ ss << " }" << std::endl;
434
+
435
+ ss << " Shader 16bit and 8bit Features {" << std::endl;
436
+ PRINT_PROP (physical_device_.shader_float16_int8_types, shaderFloat16);
437
+ PRINT_PROP (physical_device_.shader_float16_int8_types, shaderInt8);
394
438
ss << " }" << std::endl;
395
- ss << " }" << std::endl;
396
- ;
397
439
398
440
const VkPhysicalDeviceMemoryProperties& mem_props =
399
441
physical_device_.memory_properties;
400
442
443
+ ss << " }" << std::endl;
401
444
ss << " Memory Info {" << std::endl;
402
445
ss << " Memory Types [" << std::endl;
403
446
for (size_t i = 0 ; i < mem_props.memoryTypeCount; ++i) {
@@ -432,6 +475,9 @@ std::string Adapter::stringize() const {
432
475
ss << " ]" << std::endl;
433
476
ss << " }" ;
434
477
478
+ #undef PRINT_PROP
479
+ #undef PRINT_PROP_VEC3
480
+
435
481
return ss.str();
436
482
}
437
483
0 commit comments