diff options
author | Ricardo Garcia <47594367+rg3igalia@users.noreply.github.com> | 2020-02-28 18:07:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 12:07:22 -0500 |
commit | 4ec2f9afbc972e56f41e42e29cfd9707052b8242 (patch) | |
tree | 102b3d5633d22da8725dc3f17aa3742818dc63f0 /samples | |
parent | cab3a3159c067976a36f32ae98644c1b838dcaca (diff) | |
download | amber-4ec2f9afbc972e56f41e42e29cfd9707052b8242.tar.gz |
Add support for 16-bit storage features (#799)
This commits adds support for requesting 16-bit storage features as
specified in VkPhysicalDevice16BitStorageFeaturesKHR by using the
following feature names:
* Storage16BitFeatures.storageBuffer16BitAccess
* Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
* Storage16BitFeatures.storagePushConstant16
* Storage16BitFeatures.storageInputOutput16
Diffstat (limited to 'samples')
-rw-r--r-- | samples/config_helper_vulkan.cc | 48 | ||||
-rw-r--r-- | samples/config_helper_vulkan.h | 6 |
2 files changed, 42 insertions, 12 deletions
diff --git a/samples/config_helper_vulkan.cc b/samples/config_helper_vulkan.cc index 13d7f89..27504b5 100644 --- a/samples/config_helper_vulkan.cc +++ b/samples/config_helper_vulkan.cc @@ -54,6 +54,14 @@ const char k8BitStorage_UniformAndStorage[] = "Storage8BitFeatures.uniformAndStorageBuffer8BitAccess"; const char k8BitStorage_PushConstant[] = "Storage8BitFeatures.storagePushConstant8"; +const char k16BitStorage_Storage[] = + "Storage16BitFeatures.storageBuffer16BitAccess"; +const char k16BitStorage_UniformAndStorage[] = + "Storage16BitFeatures.uniformAndStorageBuffer16BitAccess"; +const char k16BitStorage_PushConstant[] = + "Storage16BitFeatures.storagePushConstant16"; +const char k16BitStorage_InputOutput[] = + "Storage16BitFeatures.storageInputOutput16"; const char kExtensionForValidationLayer[] = "VK_EXT_debug_report"; @@ -608,7 +616,8 @@ ConfigHelperVulkan::ConfigHelperVulkan() available_features2_(VkPhysicalDeviceFeatures2KHR()), variable_pointers_feature_(VkPhysicalDeviceVariablePointerFeaturesKHR()), float16_int8_feature_(VkPhysicalDeviceFloat16Int8FeaturesKHR()), - int8_storage_feature_(VkPhysicalDevice8BitStorageFeaturesKHR()) {} + storage_8bit_feature_(VkPhysicalDevice8BitStorageFeaturesKHR()), + storage_16bit_feature_(VkPhysicalDevice16BitStorageFeaturesKHR()) {} ConfigHelperVulkan::~ConfigHelperVulkan() { if (vulkan_device_) @@ -787,7 +796,9 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements( if (ext == "VK_KHR_shader_float16_int8") supports_shader_float16_int8_ = true; else if (ext == "VK_KHR_8bit_storage") - supports_shader_int8_storage_ = true; + supports_shader_8bit_storage_ = true; + else if (ext == "VK_KHR_16bit_storage") + supports_shader_16bit_storage_ = true; } vulkan_queue_family_index_ = ChooseQueueFamilyIndex(physical_device); @@ -904,9 +915,13 @@ amber::Result ConfigHelperVulkan::CreateDeviceWithFeatures2( VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR; float16_int8_feature_.pNext = nullptr; - int8_storage_feature_.sType = + storage_8bit_feature_.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR; - int8_storage_feature_.pNext = nullptr; + storage_8bit_feature_.pNext = nullptr; + + storage_16bit_feature_.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR; + storage_16bit_feature_.pNext = nullptr; void** next_ptr = &variable_pointers_feature_.pNext; @@ -915,9 +930,14 @@ amber::Result ConfigHelperVulkan::CreateDeviceWithFeatures2( next_ptr = &float16_int8_feature_.pNext; } - if (supports_shader_int8_storage_) { - *next_ptr = &int8_storage_feature_; - next_ptr = &int8_storage_feature_.pNext; + if (supports_shader_8bit_storage_) { + *next_ptr = &storage_8bit_feature_; + next_ptr = &storage_8bit_feature_.pNext; + } + + if (supports_shader_16bit_storage_) { + *next_ptr = &storage_16bit_feature_; + next_ptr = &storage_16bit_feature_.pNext; } available_features2_.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; @@ -940,11 +960,19 @@ amber::Result ConfigHelperVulkan::CreateDeviceWithFeatures2( else if (feature == kFloat16Int8_Int8) float16_int8_feature_.shaderInt8 = VK_TRUE; else if (feature == k8BitStorage_Storage) - int8_storage_feature_.storageBuffer8BitAccess = VK_TRUE; + storage_8bit_feature_.storageBuffer8BitAccess = VK_TRUE; else if (feature == k8BitStorage_UniformAndStorage) - int8_storage_feature_.uniformAndStorageBuffer8BitAccess = VK_TRUE; + storage_8bit_feature_.uniformAndStorageBuffer8BitAccess = VK_TRUE; else if (feature == k8BitStorage_PushConstant) - int8_storage_feature_.storagePushConstant8 = VK_TRUE; + storage_8bit_feature_.storagePushConstant8 = VK_TRUE; + else if (feature == k16BitStorage_Storage) + storage_16bit_feature_.storageBuffer16BitAccess = VK_TRUE; + else if (feature == k16BitStorage_UniformAndStorage) + storage_16bit_feature_.uniformAndStorageBuffer16BitAccess = VK_TRUE; + else if (feature == k16BitStorage_PushConstant) + storage_16bit_feature_.storagePushConstant16 = VK_TRUE; + else if (feature == k16BitStorage_InputOutput) + storage_16bit_feature_.storageInputOutput16 = VK_TRUE; } VkPhysicalDeviceFeatures required_vulkan_features = diff --git a/samples/config_helper_vulkan.h b/samples/config_helper_vulkan.h index b5344a9..11986b3 100644 --- a/samples/config_helper_vulkan.h +++ b/samples/config_helper_vulkan.h @@ -111,12 +111,14 @@ class ConfigHelperVulkan : public ConfigHelperImpl { bool supports_get_physical_device_properties2_ = false; bool supports_shader_float16_int8_ = false; - bool supports_shader_int8_storage_ = false; + bool supports_shader_8bit_storage_ = false; + bool supports_shader_16bit_storage_ = false; VkPhysicalDeviceFeatures available_features_; VkPhysicalDeviceFeatures2KHR available_features2_; VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointers_feature_; VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_feature_; - VkPhysicalDevice8BitStorageFeaturesKHR int8_storage_feature_; + VkPhysicalDevice8BitStorageFeaturesKHR storage_8bit_feature_; + VkPhysicalDevice16BitStorageFeaturesKHR storage_16bit_feature_; }; } // namespace sample |