Allow usage chromium_disable_uniformity_analysis

Only when unsafe APIs are allowed.

Bug: None
Change-Id: Idbe0494bec29bb623c0af39d3fb65d4995bb1a9b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/104100
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Corentin Wallez 2022-09-28 17:55:27 +00:00 committed by Dawn LUCI CQ
parent 9b31b02cdf
commit 00aced1bbf
3 changed files with 44 additions and 1 deletions

View File

@ -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 {

View File

@ -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<u32>
) {
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<u32>
) {
if (local_invocation_id.x == 0u) {
workgroupBarrier();
}
}
)"));
}
DAWN_INSTANTIATE_TEST(ShaderTests,
D3D12Backend(),
MetalBackend(),

View File

@ -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<u32>
) {
if (local_invocation_id.x == 0u) {
workgroupBarrier();
}
}
)"));
}