[dawn] Add WebGPUEnableRangeAnalysisForRobustness feature
Set the default value of the corresponding device toggle based on the
feature status.
Bug: 422494601
Change-Id: I1b3347e36c9fe7e74814c8a5b190173b666c90f2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/246275
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/include/dawn/platform/DawnPlatform.h b/include/dawn/platform/DawnPlatform.h
index bfc4778..016de1a 100644
--- a/include/dawn/platform/DawnPlatform.h
+++ b/include/dawn/platform/DawnPlatform.h
@@ -101,6 +101,7 @@
kWebGPUUseDXC,
kWebGPUUseTintIR,
kWebGPUUseVulkanMemoryModel,
+ kWebGPUEnableRangeAnalysisForRobustness,
};
class DAWN_PLATFORM_EXPORT Platform {
diff --git a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
index 20b2b37..3f1b4c1 100644
--- a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
+++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp
@@ -341,6 +341,12 @@
// Use the Tint IR backend by default if the corresponding platform feature is enabled.
deviceToggles->Default(Toggle::UseTintIR,
platform->IsFeatureEnabled(platform::Features::kWebGPUUseTintIR));
+
+ // Enable the integer range analysis for shader robustness by default if the corresponding
+ // platform feature is enabled.
+ deviceToggles->Default(
+ Toggle::EnableIntegerRangeAnalysisInRobustness,
+ platform->IsFeatureEnabled(platform::Features::kWebGPUEnableRangeAnalysisForRobustness));
}
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(
diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
index 2d9fc8e..77a1668 100644
--- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
+++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp
@@ -834,6 +834,12 @@
// Use the Tint IR backend by default if the corresponding platform feature is enabled.
deviceToggles->Default(Toggle::UseTintIR,
platform->IsFeatureEnabled(platform::Features::kWebGPUUseTintIR));
+
+ // Enable the integer range analysis for shader robustness by default if the corresponding
+ // platform feature is enabled.
+ deviceToggles->Default(
+ Toggle::EnableIntegerRangeAnalysisInRobustness,
+ platform->IsFeatureEnabled(platform::Features::kWebGPUEnableRangeAnalysisForRobustness));
}
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(
diff --git a/src/dawn/native/metal/PhysicalDeviceMTL.mm b/src/dawn/native/metal/PhysicalDeviceMTL.mm
index 14fa671..4366dd5 100644
--- a/src/dawn/native/metal/PhysicalDeviceMTL.mm
+++ b/src/dawn/native/metal/PhysicalDeviceMTL.mm
@@ -542,6 +542,12 @@
Toggle::MetalUseBothDepthAndStencilAttachmentsForCombinedDepthStencilFormats, true);
}
#endif
+
+ // Enable the integer range analysis for shader robustness by default if the corresponding
+ // platform feature is enabled.
+ deviceToggles->Default(
+ Toggle::EnableIntegerRangeAnalysisInRobustness,
+ platform->IsFeatureEnabled(platform::Features::kWebGPUEnableRangeAnalysisForRobustness));
}
MaybeError PhysicalDevice::InitializeImpl() {
diff --git a/src/dawn/native/opengl/PhysicalDeviceGL.cpp b/src/dawn/native/opengl/PhysicalDeviceGL.cpp
index d1e0e6e..1110457 100644
--- a/src/dawn/native/opengl/PhysicalDeviceGL.cpp
+++ b/src/dawn/native/opengl/PhysicalDeviceGL.cpp
@@ -41,6 +41,7 @@
#include "dawn/native/opengl/DisplayEGL.h"
#include "dawn/native/opengl/SwapChainEGL.h"
#include "dawn/native/opengl/UtilsGL.h"
+#include "dawn/platform/DawnPlatform.h"
namespace dawn::native::opengl {
@@ -494,6 +495,12 @@
deviceToggles->Default(
Toggle::GLUseArrayLengthFromUniform,
mVendorId == gpu_info::kVendorID_ImgTec || mVendorId == gpu_info::kVendorID_Nvidia);
+
+ // Enable the integer range analysis for shader robustness by default if the corresponding
+ // platform feature is enabled.
+ deviceToggles->Default(
+ Toggle::EnableIntegerRangeAnalysisInRobustness,
+ platform->IsFeatureEnabled(platform::Features::kWebGPUEnableRangeAnalysisForRobustness));
}
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(
diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
index ae85b38..5e28bc7 100644
--- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
+++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp
@@ -964,6 +964,12 @@
GetDeviceInfo().shaderIntegerDotProductFeatures.shaderIntegerDotProduct == VK_FALSE) {
deviceToggles->ForceSet(Toggle::PolyFillPacked4x8DotProduct, true);
}
+
+ // Enable the integer range analysis for shader robustness by default if the corresponding
+ // platform feature is enabled.
+ deviceToggles->Default(
+ Toggle::EnableIntegerRangeAnalysisInRobustness,
+ platform->IsFeatureEnabled(platform::Features::kWebGPUEnableRangeAnalysisForRobustness));
}
ResultOrError<Ref<DeviceBase>> PhysicalDevice::CreateDeviceImpl(
diff --git a/src/dawn/platform/DawnPlatform.cpp b/src/dawn/platform/DawnPlatform.cpp
index cab1a11..fa30f88 100644
--- a/src/dawn/platform/DawnPlatform.cpp
+++ b/src/dawn/platform/DawnPlatform.cpp
@@ -107,6 +107,8 @@
#endif
case Features::kWebGPUUseVulkanMemoryModel:
return false;
+ case Features::kWebGPUEnableRangeAnalysisForRobustness:
+ return true;
}
return false;
}