mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Flips the default deprecated code path to error instead of logging.
Bug: dawn:1677 Change-Id: I833b024fa89ee2eeed1dda80ad6e39f52bbcf8ba Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117535 Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -88,12 +88,12 @@ using ResultOrError = Result<T, ErrorData>;
|
||||
break
|
||||
|
||||
// DAWN_MAKE_DEPRECATION_ERROR is used at deprecation paths. It returns a MaybeError.
|
||||
// When the disallow_deprecated_path toggle is on, it creates an internal validation error.
|
||||
// Otherwise it returns {} and emits a deprecation warning, and moves on.
|
||||
#define DAWN_MAKE_DEPRECATION_ERROR(device, ...) \
|
||||
device->IsToggleEnabled(Toggle::DisallowDeprecatedAPIs) \
|
||||
? MaybeError(DAWN_VALIDATION_ERROR(__VA_ARGS__)) \
|
||||
: (device->EmitDeprecationWarning(absl::StrFormat(__VA_ARGS__)), 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, ...) \
|
||||
|
||||
@@ -381,12 +381,11 @@ 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::DisallowDeprecatedAPIs,
|
||||
{"disallow_deprecated_apis",
|
||||
"Disallow all deprecated paths by changing the deprecation warnings to validation error for "
|
||||
"these paths."
|
||||
"This toggle is off by default. It is expected to turn on or get removed when WebGPU V1 "
|
||||
"ships and stays stable.",
|
||||
{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",
|
||||
|
||||
@@ -91,7 +91,7 @@ enum class Toggle {
|
||||
UseBlitForBufferToStencilTextureCopy,
|
||||
UseBlitForDepthTextureToTextureCopyToNonzeroSubresource,
|
||||
D3D12ReplaceAddWithMinusWhenDstFactorIsZeroAndSrcFactorIsDstAlpha,
|
||||
DisallowDeprecatedAPIs,
|
||||
AllowDeprecatedAPIs,
|
||||
D3D12PolyfillReflectVec2F32,
|
||||
|
||||
// Unresolved issues.
|
||||
|
||||
@@ -989,13 +989,11 @@ TEST_P(BufferTests, CreateBufferOOM) {
|
||||
descriptor.usage = wgpu::BufferUsage::CopyDst;
|
||||
|
||||
descriptor.size = std::numeric_limits<uint64_t>::max();
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(device.CreateBuffer(&descriptor)));
|
||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||
|
||||
// UINT64_MAX may be special cased. Test a smaller, but really large buffer also fails
|
||||
descriptor.size = 1ull << 50;
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(device.CreateBuffer(&descriptor)));
|
||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||
|
||||
// Validation errors should always be prior to OOM.
|
||||
descriptor.usage = wgpu::BufferUsage::MapRead | wgpu::BufferUsage::Uniform;
|
||||
@@ -1038,8 +1036,7 @@ TEST_P(BufferTests, BufferMappedAtCreationOOM) {
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||
ASSERT_EQ(nullptr, buffer.Get());
|
||||
} else {
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(device.CreateBuffer(&descriptor)));
|
||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1068,8 +1065,7 @@ TEST_P(BufferTests, BufferMappedAtCreationOOM) {
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
|
||||
ASSERT_EQ(nullptr, buffer.Get());
|
||||
} else {
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(device.CreateBuffer(&descriptor)));
|
||||
ASSERT_DEVICE_ERROR(device.CreateBuffer(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1083,8 +1079,7 @@ TEST_P(BufferTests, CreateBufferOOMMapAsync) {
|
||||
|
||||
auto RunTest = [this](const wgpu::BufferDescriptor& descriptor) {
|
||||
wgpu::Buffer buffer;
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(buffer = device.CreateBuffer(&descriptor)));
|
||||
ASSERT_DEVICE_ERROR(buffer = device.CreateBuffer(&descriptor));
|
||||
|
||||
bool done = false;
|
||||
ASSERT_DEVICE_ERROR(buffer.MapAsync(
|
||||
|
||||
@@ -1651,7 +1651,7 @@ TEST_F(BindGroupLayoutValidationTest, MultisampledTextureViewDimension) {
|
||||
// Test that multisampled texture bindings are valid
|
||||
TEST_F(BindGroupLayoutValidationTest, MultisampledTextureSampleType) {
|
||||
// Multisampled float sample type deprecated.
|
||||
EXPECT_DEPRECATION_WARNING(utils::MakeBindGroupLayout(
|
||||
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
|
||||
device, {
|
||||
{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
|
||||
wgpu::TextureViewDimension::e2D, true},
|
||||
|
||||
@@ -1163,9 +1163,8 @@ TEST_F(BufferValidationTest, CreationParameterReflectionForOOMBuffer) {
|
||||
desc.size = kAmazinglyLargeSize;
|
||||
|
||||
// OOM!
|
||||
// TODO(dawn:1525): remove warning expectation after the deprecation period.
|
||||
wgpu::Buffer buf;
|
||||
ASSERT_DEVICE_ERROR(EXPECT_DEPRECATION_WARNING(buf = device.CreateBuffer(&desc)));
|
||||
ASSERT_DEVICE_ERROR(buf = device.CreateBuffer(&desc));
|
||||
|
||||
// Reflection data is still exactly what was in the descriptor.
|
||||
EXPECT_EQ(wgpu::BufferUsage::Storage, buf.GetUsage());
|
||||
|
||||
@@ -22,15 +22,6 @@
|
||||
|
||||
WGPUDevice DeprecationTests::CreateTestDevice(dawn::native::Adapter dawnAdapter) {
|
||||
wgpu::DeviceDescriptor descriptor = {};
|
||||
|
||||
wgpu::DawnTogglesDescriptor deviceTogglesDesc = {};
|
||||
const char* enabledToggles[1] = {kDisallowDeprecatedAPIsToggleName};
|
||||
deviceTogglesDesc.enabledToggles = enabledToggles;
|
||||
deviceTogglesDesc.enabledTogglesCount = 1;
|
||||
|
||||
if (GetParam()) {
|
||||
descriptor.nextInChain = &deviceTogglesDesc;
|
||||
}
|
||||
return dawnAdapter.CreateDevice(&descriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,33 +24,33 @@
|
||||
// scattered in other files as well for organizational purposes so that similar tests can live
|
||||
// together.
|
||||
|
||||
static constexpr char kDisallowDeprecatedAPIsToggleName[] = "disallow_deprecated_apis";
|
||||
static constexpr char kAllowDeprecatedAPIsToggleName[] = "allow_deprecated_apis";
|
||||
|
||||
#define EXPECT_DEPRECATION_ERROR_OR_WARNING(statement) \
|
||||
if (HasToggleEnabled(kDisallowDeprecatedAPIsToggleName)) { \
|
||||
ASSERT_DEVICE_ERROR(statement); \
|
||||
} else { \
|
||||
EXPECT_DEPRECATION_WARNING(statement); \
|
||||
} \
|
||||
for (;;) \
|
||||
#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(kDisallowDeprecatedAPIsToggleName)) { \
|
||||
EXPECT_DEPRECATION_WARNING(statement); \
|
||||
} else { \
|
||||
statement; \
|
||||
} \
|
||||
for (;;) \
|
||||
#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(kDisallowDeprecatedAPIsToggleName)) { \
|
||||
ASSERT_DEVICE_ERROR(statement); \
|
||||
} else { \
|
||||
statement; \
|
||||
} \
|
||||
for (;;) \
|
||||
#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
|
||||
|
||||
@@ -1196,7 +1196,7 @@ TEST_F(RenderPassDescriptorValidationTest, ValidateDepthStencilReadOnly) {
|
||||
renderPass.cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Load;
|
||||
renderPass.cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Store;
|
||||
renderPass.cDepthStencilAttachmentInfo.stencilReadOnly = false;
|
||||
EXPECT_DEPRECATION_WARNING(AssertBeginRenderPassSuccess(&renderPass));
|
||||
AssertBeginRenderPassError(&renderPass);
|
||||
}
|
||||
|
||||
// Tests that a pass with mismatched depthReadOnly and stencilReadOnly values fails when
|
||||
|
||||
Reference in New Issue
Block a user