From ba242e53cc06deab042781afc21ba46a318308c6 Mon Sep 17 00:00:00 2001 From: Loko Kung Date: Tue, 2 May 2023 00:38:56 +0000 Subject: [PATCH] Removes remaining V1 deprecation utilities. - Note: Any future deprecations should directly use device->EmitDeprecationWarning and switch to a ValidationError after the deprecation period if applicable. Bug: dawn:1685 Change-Id: Ia2e51eca32a9645ce362718200c50240d51d6ea0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130840 Kokoro: Kokoro Commit-Queue: Loko Kung Reviewed-by: Austin Eng --- src/dawn/native/Error.h | 16 ----- src/dawn/native/Toggles.cpp | 6 -- src/dawn/native/Toggles.h | 1 - src/dawn/tests/BUILD.gn | 2 - .../validation/DeprecatedAPITests.cpp | 26 -------- .../unittests/validation/DeprecatedAPITests.h | 63 ------------------- .../RenderBundleValidationTests.cpp | 5 +- .../RenderPassDescriptorValidationTests.cpp | 5 +- .../RenderPipelineValidationTests.cpp | 1 - 9 files changed, 2 insertions(+), 123 deletions(-) delete mode 100644 src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp delete mode 100644 src/dawn/tests/unittests/validation/DeprecatedAPITests.h diff --git a/src/dawn/native/Error.h b/src/dawn/native/Error.h index 5e79d9b9b8..84caa77f61 100644 --- a/src/dawn/native/Error.h +++ b/src/dawn/native/Error.h @@ -87,22 +87,6 @@ using ResultOrError = Result; for (;;) \ break -// DAWN_MAKE_DEPRECATION_ERROR is used at deprecation paths. It returns a MaybeError. -// When the allow_deprecated_apis toggle is disabled, it creates an internal validation error. -// Otherwise it returns {}, emits a deprecation warning, and moves on. -#define DAWN_MAKE_DEPRECATION_ERROR(device, ...) \ - device->IsToggleEnabled(Toggle::AllowDeprecatedAPIs) \ - ? (device->EmitDeprecationWarning(absl::StrFormat(__VA_ARGS__)), MaybeError{}) \ - : MaybeError(DAWN_VALIDATION_ERROR(__VA_ARGS__)) - -// DAWN_DEPRECATED_IF is used analogous to DAWN_INVALID_IF at deprecation paths. -#define DAWN_DEPRECATED_IF(device, EXPR, ...) \ - if (DAWN_UNLIKELY(EXPR)) { \ - return DAWN_MAKE_DEPRECATION_ERROR(device, __VA_ARGS__); \ - } \ - for (;;) \ - break - // DAWN_DEVICE_LOST_ERROR means that there was a real unrecoverable native device lost error. // We can't even do a graceful shutdown because the Device is gone. #define DAWN_DEVICE_LOST_ERROR(MESSAGE) DAWN_MAKE_ERROR(InternalErrorType::DeviceLost, MESSAGE) diff --git a/src/dawn/native/Toggles.cpp b/src/dawn/native/Toggles.cpp index 120be2da82..50d7f4fd02 100644 --- a/src/dawn/native/Toggles.cpp +++ b/src/dawn/native/Toggles.cpp @@ -387,12 +387,6 @@ static constexpr ToggleEnumAndInfoList kToggleNameAndInfoList = {{ "srcBlendFactor is 'DstAlpha'. Works around an Intel D3D12 driver issue about alpha " "blending.", "https://crbug.com/dawn/1579", ToggleStage::Device}}, - {Toggle::AllowDeprecatedAPIs, - {"allow_deprecated_apis", - "Allows deprecated paths by changing the validation errors to deprecation warnings. This " - "toggle is off by default and is expected to get removed when WebGPU V1 ships and stays " - "stable.", - "https://crbug.com/dawn/1563", ToggleStage::Device}}, {Toggle::D3D12PolyfillReflectVec2F32, {"d3d12_polyfill_reflect_vec2_f32", "Polyfill the reflect builtin for vec2 for D3D12. This toggle is enabled by default on " diff --git a/src/dawn/native/Toggles.h b/src/dawn/native/Toggles.h index c77a08d60b..e5e348338a 100644 --- a/src/dawn/native/Toggles.h +++ b/src/dawn/native/Toggles.h @@ -92,7 +92,6 @@ enum class Toggle { UseBlitForBufferToStencilTextureCopy, UseBlitForDepthTextureToTextureCopyToNonzeroSubresource, D3D12ReplaceAddWithMinusWhenDstFactorIsZeroAndSrcFactorIsDstAlpha, - AllowDeprecatedAPIs, D3D12PolyfillReflectVec2F32, VulkanClearGen12TextureWithCCSAmbiguateOnCreation, diff --git a/src/dawn/tests/BUILD.gn b/src/dawn/tests/BUILD.gn index da84560261..0079c295f7 100644 --- a/src/dawn/tests/BUILD.gn +++ b/src/dawn/tests/BUILD.gn @@ -332,8 +332,6 @@ dawn_test("dawn_unittests") { "unittests/validation/CopyCommandsValidationTests.cpp", "unittests/validation/CopyTextureForBrowserTests.cpp", "unittests/validation/DebugMarkerValidationTests.cpp", - "unittests/validation/DeprecatedAPITests.cpp", - "unittests/validation/DeprecatedAPITests.h", "unittests/validation/DeviceValidationTests.cpp", "unittests/validation/DrawIndirectValidationTests.cpp", "unittests/validation/DrawVertexAndIndexBufferOOBValidationTests.cpp", diff --git a/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp b/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp deleted file mode 100644 index 1c5d46b6a1..0000000000 --- a/src/dawn/tests/unittests/validation/DeprecatedAPITests.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2020 The Dawn Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "dawn/tests/unittests/validation/DeprecatedAPITests.h" - -#include "dawn/common/Constants.h" -#include "dawn/utils/ComboRenderPipelineDescriptor.h" -#include "dawn/utils/WGPUHelpers.h" - -WGPUDevice DeprecationTests::CreateTestDevice(dawn::native::Adapter dawnAdapter) { - wgpu::DeviceDescriptor descriptor = {}; - return dawnAdapter.CreateDevice(&descriptor); -} diff --git a/src/dawn/tests/unittests/validation/DeprecatedAPITests.h b/src/dawn/tests/unittests/validation/DeprecatedAPITests.h deleted file mode 100644 index 00437c1eba..0000000000 --- a/src/dawn/tests/unittests/validation/DeprecatedAPITests.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2022 The Dawn Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_DAWN_TESTS_UNITTESTS_VALIDATION_DEPRECATEDAPITESTS_H_ -#define SRC_DAWN_TESTS_UNITTESTS_VALIDATION_DEPRECATEDAPITESTS_H_ - -#include "dawn/tests/unittests/validation/ValidationTest.h" - -// This test header should be included when testing for deprecated parts of Dawn's API while -// following WebGPU's evolution. Tests in this suite test that a deprecation warning is emitted when -// the "old" behavior is used, and tests that an error is emitted when both the old and the new -// behavior are used (when applicable). Note that implementations of tests in this suite may be -// scattered in other files as well for organizational purposes so that similar tests can live -// together. - -static constexpr char kAllowDeprecatedAPIsToggleName[] = "allow_deprecated_apis"; - -#define EXPECT_DEPRECATION_ERROR_OR_WARNING(statement) \ - if (!HasToggleEnabled(kAllowDeprecatedAPIsToggleName)) { \ - ASSERT_DEVICE_ERROR(statement); \ - } else { \ - EXPECT_DEPRECATION_WARNING(statement); \ - } \ - for (;;) \ - break - -#define EXPECT_DEPRECATION_WARNING_ONLY(statement) \ - if (HasToggleEnabled(kAllowDeprecatedAPIsToggleName)) { \ - EXPECT_DEPRECATION_WARNING(statement); \ - } else { \ - statement; \ - } \ - for (;;) \ - break - -#define EXPECT_DEPRECATION_ERROR_ONLY(statement) \ - if (!HasToggleEnabled(kAllowDeprecatedAPIsToggleName)) { \ - ASSERT_DEVICE_ERROR(statement); \ - } else { \ - statement; \ - } \ - for (;;) \ - break - -// Parameter is a single bool. When true, deprecated APIs are strictly disallowed (i.e. generate -// errors). Otherwise, deprecated APIs only generate a warning message. -class DeprecationTests : public ValidationTest, public testing::WithParamInterface { - protected: - WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override; -}; - -#endif // SRC_DAWN_TESTS_UNITTESTS_VALIDATION_DEPRECATEDAPITESTS_H_ diff --git a/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp index 0b054b3682..1db904e5df 100644 --- a/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderBundleValidationTests.cpp @@ -14,11 +14,8 @@ #include -#include "dawn/tests/unittests/validation/DeprecatedAPITests.h" -#include "dawn/tests/unittests/validation/ValidationTest.h" - #include "dawn/common/Constants.h" - +#include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/ComboRenderBundleEncoderDescriptor.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" diff --git a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp index 9910232769..006f6aa651 100644 --- a/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp @@ -15,11 +15,8 @@ #include #include -#include "dawn/tests/unittests/validation/DeprecatedAPITests.h" -#include "dawn/tests/unittests/validation/ValidationTest.h" - #include "dawn/common/Constants.h" - +#include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/ComboRenderBundleEncoderDescriptor.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h" diff --git a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp index 77e0b5917d..ef238963a6 100644 --- a/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -18,7 +18,6 @@ #include #include "dawn/common/Constants.h" -#include "dawn/tests/unittests/validation/DeprecatedAPITests.h" #include "dawn/tests/unittests/validation/ValidationTest.h" #include "dawn/utils/ComboRenderPipelineDescriptor.h" #include "dawn/utils/WGPUHelpers.h"