dawn-cmake/src/dawn/tests/unittests/validation/DeprecatedAPITests.h
shrekshao 49a08b7668 Refix validation for command encoder pass encoding
According to latest spec, beginRenderPass/beginComputePass
don't throw validation error. Error still defers to
CommandEncoder::Finish()

Bug: dawn:1602
Change-Id: I5fd76f2c8951273a8dd82b02e20f076079354b60
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115120
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
2022-12-20 21:03:16 +00:00

64 lines
3.1 KiB
C++

// 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 kDisallowDeprecatedAPIsToggleName[] = "disallow_deprecated_apis";
#define EXPECT_DEPRECATION_ERROR_OR_WARNING(statement) \
if (HasToggleEnabled(kDisallowDeprecatedAPIsToggleName)) { \
ASSERT_DEVICE_ERROR(statement); \
} else { \
EXPECT_DEPRECATION_WARNING(statement); \
} \
for (;;) \
break
#define EXPECT_DEPRECATION_WARNING_ONLY(statement) \
if (!HasToggleEnabled(kDisallowDeprecatedAPIsToggleName)) { \
EXPECT_DEPRECATION_WARNING(statement); \
} else { \
statement; \
} \
for (;;) \
break
#define EXPECT_DEPRECATION_ERROR_ONLY(statement) \
if (HasToggleEnabled(kDisallowDeprecatedAPIsToggleName)) { \
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<bool> {
protected:
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter) override;
};
#endif // SRC_DAWN_TESTS_UNITTESTS_VALIDATION_DEPRECATEDAPITESTS_H_