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 <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
Loko Kung 2022-01-13 23:47:20 +00:00 committed by Dawn LUCI CQ
parent 4abe2a0b53
commit 15e3592fd5
2 changed files with 16 additions and 0 deletions

View File

@ -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();
}

View File

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