Fix GatherDeviceInfo on Vulkan 1.0 devices
A bad assert was causing devices that only supported Vulkan 1.0, such as
the Nexus 5X, to crash when querying information about adapter
properties and features. This change removes the need for the ASSERT.
(Note that this does not guarantee WebGPU support on Vulkan 1.0 devices.
For example, the Nexus 5X does not have the fragmentStoresAndAtomics
feature, which is required for WebGPU.)
Bug: dawn:286
Change-Id: I7f884290f29ae7e9607933f6186feac2ce8af540
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117840
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/vulkan/VulkanInfo.cpp b/src/dawn/native/vulkan/VulkanInfo.cpp
index 97b3b73..9f4f796 100644
--- a/src/dawn/native/vulkan/VulkanInfo.cpp
+++ b/src/dawn/native/vulkan/VulkanInfo.cpp
@@ -213,67 +213,67 @@
// Gather general and extension features and properties
//
- // Use vkGetPhysicalDevice{Features,Properties}2 if required to gather information about
- // the extensions. DeviceExt::GetPhysicalDeviceProperties2 is guaranteed to be available
- // because these extensions (transitively) depend on it in `EnsureDependencies`
- VkPhysicalDeviceFeatures2 features2 = {};
- features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
- features2.pNext = nullptr;
- PNextChainBuilder featuresChain(&features2);
-
- VkPhysicalDeviceProperties2 properties2 = {};
- properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
-
- PNextChainBuilder propertiesChain(&properties2);
-
- propertiesChain.Add(&info.propertiesMaintenance3,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES);
-
- if (info.extensions[DeviceExt::ShaderFloat16Int8]) {
- featuresChain.Add(&info.shaderFloat16Int8Features,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR);
- }
-
- if (info.extensions[DeviceExt::_16BitStorage]) {
- featuresChain.Add(&info._16BitStorageFeatures,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES);
- }
-
- if (info.extensions[DeviceExt::SubgroupSizeControl]) {
- featuresChain.Add(&info.subgroupSizeControlFeatures,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT);
- propertiesChain.Add(&info.subgroupSizeControlProperties,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT);
- }
-
- if (info.extensions[DeviceExt::DriverProperties]) {
- propertiesChain.Add(&info.driverProperties,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES);
- }
-
- if (info.extensions[DeviceExt::ShaderIntegerDotProduct]) {
- propertiesChain.Add(
- &info.shaderIntegerDotProductProperties,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR);
- }
-
- if (info.extensions[DeviceExt::DepthClipEnable]) {
- featuresChain.Add(&info.depthClipEnableFeatures,
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT);
- }
-
// If we have DeviceExt::GetPhysicalDeviceProperties2, use features2 and properties2 so
- // that features no covered by VkPhysicalDevice{Features,Properties} can be queried.
+ // that features not covered by VkPhysicalDevice{Features,Properties} can be queried.
//
// Note that info.properties has already been filled at the start of this function to get
// `apiVersion`.
ASSERT(info.properties.apiVersion != 0);
if (info.extensions[DeviceExt::GetPhysicalDeviceProperties2]) {
+ VkPhysicalDeviceFeatures2 features2 = {};
+ features2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+ features2.pNext = nullptr;
+ PNextChainBuilder featuresChain(&features2);
+
+ VkPhysicalDeviceProperties2 properties2 = {};
+ properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
+
+ PNextChainBuilder propertiesChain(&properties2);
+
+ propertiesChain.Add(&info.propertiesMaintenance3,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES);
+
+ if (info.extensions[DeviceExt::ShaderFloat16Int8]) {
+ featuresChain.Add(&info.shaderFloat16Int8Features,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR);
+ }
+
+ if (info.extensions[DeviceExt::_16BitStorage]) {
+ featuresChain.Add(&info._16BitStorageFeatures,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES);
+ }
+
+ if (info.extensions[DeviceExt::SubgroupSizeControl]) {
+ featuresChain.Add(&info.subgroupSizeControlFeatures,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT);
+ propertiesChain.Add(
+ &info.subgroupSizeControlProperties,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT);
+ }
+
+ if (info.extensions[DeviceExt::DriverProperties]) {
+ propertiesChain.Add(&info.driverProperties,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES);
+ }
+
+ if (info.extensions[DeviceExt::ShaderIntegerDotProduct]) {
+ propertiesChain.Add(
+ &info.shaderIntegerDotProductProperties,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR);
+ }
+
+ if (info.extensions[DeviceExt::DepthClipEnable]) {
+ featuresChain.Add(&info.depthClipEnableFeatures,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT);
+ }
+
+ // Use vkGetPhysicalDevice{Features,Properties}2 if required to gather information about
+ // the extensions. DeviceExt::GetPhysicalDeviceProperties2 is guaranteed to be available
+ // because these extensions (transitively) depend on it in `EnsureDependencies`
vkFunctions.GetPhysicalDeviceProperties2(physicalDevice, &properties2);
vkFunctions.GetPhysicalDeviceFeatures2(physicalDevice, &features2);
info.features = features2.features;
} else {
- ASSERT(features2.pNext == nullptr && properties2.pNext == nullptr);
vkFunctions.GetPhysicalDeviceFeatures(physicalDevice, &info.features);
}