From 15e3592fd5079fd70c55104bc8ed9b2c180fa56e Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Thu, 13 Jan 2022 23:47:20 +0000 Subject: [PATCH] Guards explicit device.destroy() until tested. Bug: dawn:628 Change-Id: Ib6a6be0e5467d3cdd6432834d6f9d5c2000b18be Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76340 Reviewed-by: Austin Eng Commit-Queue: Loko Kung --- src/dawn_native/Device.cpp | 6 ++++++ .../unittests/validation/UnsafeAPIValidationTests.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/dawn_native/Device.cpp b/src/dawn_native/Device.cpp index 559fa9364d..1775574553 100644 --- a/src/dawn_native/Device.cpp +++ b/src/dawn_native/Device.cpp @@ -405,6 +405,12 @@ namespace dawn::native { } void DeviceBase::APIDestroy() { + // TODO(crbug.com/dawn/628) Re-enable once CTS testing is in place and passing. + if (IsToggleEnabled(Toggle::DisallowUnsafeAPIs)) { + ConsumedError(DAWN_VALIDATION_ERROR( + "Explicit device.destroy() is disallowed because it is not fully implemented")); + return; + } Destroy(); } diff --git a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp index b115a5d7b8..cba13c12c3 100644 --- a/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp +++ b/src/tests/unittests/validation/UnsafeAPIValidationTests.cpp @@ -19,6 +19,10 @@ #include "utils/ComboRenderPipelineDescriptor.h" #include "utils/WGPUHelpers.h" +namespace { + using testing::HasSubstr; +} // anonymous namespace + class UnsafeAPIValidationTest : public ValidationTest { protected: WGPUDevice CreateTestDevice() override { @@ -49,6 +53,12 @@ TEST_F(UnsafeAPIValidationTest, 1DTextures) { ASSERT_DEVICE_ERROR(device.CreateTexture(&desc)); } +// Check that explicit user device.destroy() is disallowed as part of unsafe APIs. +// TODO(crbug.com/dawn/628) Remove when CTS testing is in place and passing. +TEST_F(UnsafeAPIValidationTest, ExplicitDeviceDestroy) { + ASSERT_DEVICE_ERROR(device.Destroy(), HasSubstr("Explicit device.destroy() is disallowed")); +} + // Check that pipeline overridable constants are disallowed as part of unsafe APIs. // TODO(dawn:1041) Remove when implementation for all backend is added TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {