Vulkan: Add missing physical device feature queries
This patch adds below physical device feature queries and only
enables the corresponding features when the queries on the support
of these features are VK_TRUE:
- VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR
- VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeaturesKHR
Bug: dawn:1302, tint:1497
Change-Id: If8b58874e0db09557abf720ceed71f255c83b8c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/136923
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/vulkan/DeviceVk.cpp b/src/dawn/native/vulkan/DeviceVk.cpp
index 0dae3fa..f490973 100644
--- a/src/dawn/native/vulkan/DeviceVk.cpp
+++ b/src/dawn/native/vulkan/DeviceVk.cpp
@@ -450,24 +450,18 @@
if (mDeviceInfo.HasExt(DeviceExt::ZeroInitializeWorkgroupMemory)) {
ASSERT(usedKnobs.HasExt(DeviceExt::ZeroInitializeWorkgroupMemory));
- usedKnobs.zeroInitializeWorkgroupMemoryFeatures.sType =
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES_KHR;
-
// Always allow initializing workgroup memory with OpConstantNull when available.
// Note that the driver still won't initialize workgroup memory unless the workgroup
// variable is explicitly initialized with OpConstantNull.
- usedKnobs.zeroInitializeWorkgroupMemoryFeatures.shaderZeroInitializeWorkgroupMemory =
- VK_TRUE;
+ usedKnobs.zeroInitializeWorkgroupMemoryFeatures =
+ mDeviceInfo.zeroInitializeWorkgroupMemoryFeatures;
featuresChain.Add(&usedKnobs.zeroInitializeWorkgroupMemoryFeatures);
}
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct)) {
ASSERT(usedKnobs.HasExt(DeviceExt::ShaderIntegerDotProduct));
- usedKnobs.shaderIntegerDotProductFeatures.sType =
- VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES;
-
- usedKnobs.shaderIntegerDotProductFeatures.shaderIntegerDotProduct = VK_TRUE;
+ usedKnobs.shaderIntegerDotProductFeatures = mDeviceInfo.shaderIntegerDotProductFeatures;
featuresChain.Add(&usedKnobs.shaderIntegerDotProductFeatures);
}
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
index 633d16d..2d7c448 100644
--- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
+++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -226,6 +226,7 @@
}
if (mDeviceInfo.HasExt(DeviceExt::ShaderIntegerDotProduct) &&
+ mDeviceInfo.shaderIntegerDotProductFeatures.shaderIntegerDotProduct == VK_TRUE &&
mDeviceInfo.shaderIntegerDotProductProperties
.integerDotProduct4x8BitPackedSignedAccelerated == VK_TRUE &&
mDeviceInfo.shaderIntegerDotProductProperties
@@ -534,8 +535,11 @@
deviceToggles->Default(Toggle::VulkanUseS8, true);
// The environment can only request to use VK_KHR_zero_initialize_workgroup_memory when the
- // extension is available. Override the decision if it is no applicable.
- if (!GetDeviceInfo().HasExt(DeviceExt::ZeroInitializeWorkgroupMemory)) {
+ // extension is available. Override the decision if it is no applicable or
+ // zeroInitializeWorkgroupMemoryFeatures.shaderZeroInitializeWorkgroupMemory == VK_FALSE.
+ if (!GetDeviceInfo().HasExt(DeviceExt::ZeroInitializeWorkgroupMemory) ||
+ GetDeviceInfo().zeroInitializeWorkgroupMemoryFeatures.shaderZeroInitializeWorkgroupMemory ==
+ VK_FALSE) {
deviceToggles->ForceSet(Toggle::VulkanUseZeroInitializeWorkgroupMemoryExtension, false);
}
// By default try to initialize workgroup memory with OpConstantNull according to the Vulkan
diff --git a/src/dawn/native/vulkan/VulkanInfo.cpp b/src/dawn/native/vulkan/VulkanInfo.cpp
index e653755..fb72784 100644
--- a/src/dawn/native/vulkan/VulkanInfo.cpp
+++ b/src/dawn/native/vulkan/VulkanInfo.cpp
@@ -257,6 +257,10 @@
}
if (info.extensions[DeviceExt::ShaderIntegerDotProduct]) {
+ featuresChain.Add(
+ &info.shaderIntegerDotProductFeatures,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES_KHR);
+
propertiesChain.Add(
&info.shaderIntegerDotProductProperties,
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR);
@@ -272,6 +276,12 @@
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES);
}
+ if (info.extensions[DeviceExt::ZeroInitializeWorkgroupMemory]) {
+ featuresChain.Add(
+ &info.zeroInitializeWorkgroupMemoryFeatures,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES);
+ }
+
// 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`