diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index 9862bf52aa..94cd63abe1 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp @@ -1311,13 +1311,16 @@ bool DeviceBase::HasFeature(Feature feature) const { void DeviceBase::SetWGSLExtensionAllowList() { // Set the WGSL extensions allow list based on device's enabled features and other - // propority. + // properties. if (mEnabledFeatures.IsEnabled(Feature::ChromiumExperimentalDp4a)) { mWGSLExtensionAllowList.insert("chromium_experimental_dp4a"); } if (mEnabledFeatures.IsEnabled(Feature::ShaderF16)) { mWGSLExtensionAllowList.insert("f16"); } + if (!IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) { + mWGSLExtensionAllowList.insert("chromium_disable_uniformity_analysis"); + } } WGSLExtensionSet DeviceBase::GetWGSLExtensionAllowList() const { diff --git a/src/dawn/tests/end2end/ShaderTests.cpp b/src/dawn/tests/end2end/ShaderTests.cpp index 3ce2759a20..dd88e562d3 100644 --- a/src/dawn/tests/end2end/ShaderTests.cpp +++ b/src/dawn/tests/end2end/ShaderTests.cpp @@ -870,6 +870,31 @@ TEST_P(ShaderTests, ConflictingBindingsDueToTransformOrder) { device.CreateRenderPipeline(&desc); } +// Check that chromium_disable_uniformity_analysis can be used. It is normally disallowed as unsafe +// but DawnTests allow all unsafe APIs by default. +TEST_P(ShaderTests, CheckUsageOf_chromium_disable_uniformity_analysis) { + wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( + enable chromium_disable_uniformity_analysis; + + @compute @workgroup_size(8) fn uniformity_error( + @builtin(local_invocation_id) local_invocation_id : vec3 + ) { + if (local_invocation_id.x == 0u) { + workgroupBarrier(); + } + } + )"); + ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( + @compute @workgroup_size(8) fn uniformity_error( + @builtin(local_invocation_id) local_invocation_id : vec3 + ) { + if (local_invocation_id.x == 0u) { + workgroupBarrier(); + } + } + )")); +} + DAWN_INSTANTIATE_TEST(ShaderTests, D3D12Backend(), MetalBackend(), diff --git a/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp index 171e037bee..0cfa397c92 100644 --- a/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/UnsafeAPIValidationTests.cpp @@ -95,3 +95,18 @@ TEST_F(UnsafeQueryAPIValidationTest, TimestampQueryDisallowed) { ASSERT_DEVICE_ERROR(device.CreateQuerySet(&descriptor)); } } + +// Check chromium_disable_uniformity_analysis is an unsafe API. +TEST_F(UnsafeAPIValidationTest, chromium_disable_uniformity_analysis) { + ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( + enable chromium_disable_uniformity_analysis; + + @compute @workgroup_size(8) fn uniformity_error( + @builtin(local_invocation_id) local_invocation_id : vec3 + ) { + if (local_invocation_id.x == 0u) { + workgroupBarrier(); + } + } + )")); +}