diff options
author | Ilkka Saarelainen <ilkka.saarelainen@siru.fi> | 2021-06-17 13:03:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-17 11:03:44 +0100 |
commit | aaac58d5009e8f6b33e2723258dc1542854d09a4 (patch) | |
tree | bd4b1b59f92bded3c18118a5bff3c11af9f69b96 | |
parent | 8797ee109e7a6ea4d1f58f387f757545fa35325b (diff) | |
download | amber-aaac58d5009e8f6b33e2723258dc1542854d09a4.tar.gz |
Improve device feature check (#954)
Some of the device features were not checked if they are
supported on the device being used. This caused vkCreateDevice
to fail without any error message.
This commit adds the support check for the remaining device features
listed in the amber_script.md. Also adds missing required
extensions to tests/cases/float16.amber.
Fixes #953
-rw-r--r-- | samples/config_helper_vulkan.cc | 62 | ||||
-rw-r--r-- | tests/cases/float16.amber | 4 |
2 files changed, 52 insertions, 14 deletions
diff --git a/samples/config_helper_vulkan.cc b/samples/config_helper_vulkan.cc index 68114ab..964926e 100644 --- a/samples/config_helper_vulkan.cc +++ b/samples/config_helper_vulkan.cc @@ -762,21 +762,36 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements( VkPhysicalDeviceFeatures(); if (supports_get_physical_device_properties2_) { - VkPhysicalDeviceSubgroupSizeControlFeaturesEXT size_control = - VkPhysicalDeviceSubgroupSizeControlFeaturesEXT(); - size_control.sType = + VkPhysicalDeviceSubgroupSizeControlFeaturesEXT + subgroup_size_control_features; + VkPhysicalDeviceVariablePointerFeaturesKHR variable_pointers_features = {}; + VkPhysicalDeviceFloat16Int8FeaturesKHR float16_int8_features = {}; + VkPhysicalDevice8BitStorageFeaturesKHR storage_8bit_features = {}; + VkPhysicalDevice16BitStorageFeaturesKHR storage_16bit_features = {}; + + subgroup_size_control_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT; - size_control.pNext = nullptr; + subgroup_size_control_features.pNext = nullptr; - VkPhysicalDeviceVariablePointerFeaturesKHR var_ptrs = - VkPhysicalDeviceVariablePointerFeaturesKHR(); - var_ptrs.sType = + variable_pointers_features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR; - var_ptrs.pNext = &size_control; + variable_pointers_features.pNext = &subgroup_size_control_features; + + float16_int8_features.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR; + float16_int8_features.pNext = &variable_pointers_features; + + storage_8bit_features.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR; + storage_8bit_features.pNext = &float16_int8_features; + + storage_16bit_features.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR; + storage_16bit_features.pNext = &storage_8bit_features; VkPhysicalDeviceFeatures2KHR features2 = VkPhysicalDeviceFeatures2KHR(); features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR; - features2.pNext = &var_ptrs; + features2.pNext = &storage_16bit_features; auto vkGetPhysicalDeviceFeatures2KHR = reinterpret_cast<PFN_vkGetPhysicalDeviceFeatures2KHR>( @@ -794,13 +809,34 @@ amber::Result ConfigHelperVulkan::CheckVulkanPhysicalDeviceRequirements( } if ((feature == kVariablePointers && - var_ptrs.variablePointers == VK_FALSE) || + variable_pointers_features.variablePointers == VK_FALSE) || (feature == kVariablePointersStorageBuffer && - var_ptrs.variablePointersStorageBuffer == VK_FALSE) || + variable_pointers_features.variablePointersStorageBuffer == + VK_FALSE) || (feature == kSubgroupSizeControl && - size_control.subgroupSizeControl == VK_FALSE) || + subgroup_size_control_features.subgroupSizeControl == VK_FALSE) || (feature == kComputeFullSubgroups && - size_control.computeFullSubgroups == VK_FALSE)) { + subgroup_size_control_features.computeFullSubgroups == VK_FALSE) || + (feature == kFloat16Int8_Float16 && + float16_int8_features.shaderFloat16 == VK_FALSE) || + (feature == kFloat16Int8_Int8 && + float16_int8_features.shaderInt8 == VK_FALSE) || + (feature == k8BitStorage_Storage && + storage_8bit_features.storageBuffer8BitAccess == VK_FALSE) || + (feature == k8BitStorage_UniformAndStorage && + storage_8bit_features.uniformAndStorageBuffer8BitAccess == + VK_FALSE) || + (feature == k8BitStorage_PushConstant && + storage_8bit_features.storagePushConstant8 == VK_FALSE) || + (feature == k16BitStorage_Storage && + storage_16bit_features.storageBuffer16BitAccess == VK_FALSE) || + (feature == k16BitStorage_InputOutput && + storage_16bit_features.storageInputOutput16 == VK_FALSE) || + (feature == k16BitStorage_PushConstant && + storage_16bit_features.storagePushConstant16 == VK_FALSE) || + (feature == k16BitStorage_UniformAndStorage && + storage_16bit_features.uniformAndStorageBuffer16BitAccess == + VK_FALSE)) { return amber::Result("Device does not support all required features"); } } diff --git a/tests/cases/float16.amber b/tests/cases/float16.amber index 88baf13..0a8fd04 100644 --- a/tests/cases/float16.amber +++ b/tests/cases/float16.amber @@ -13,9 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -INSTANCE_EXTENSION VK_KHR_get_physical_device_properties2 DEVICE_EXTENSION VK_KHR_shader_float16_int8 +DEVICE_EXTENSION VK_KHR_16bit_storage +DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class DEVICE_FEATURE Float16Int8Features.shaderFloat16 +DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess SHADER compute f16 GLSL #version 450 |