Convert a few remaining DAWN_VALIDATION_ERROR.

There are still DAWN_VALIDATION_ERROR occurences left but they don't use
any format string so it is fine to merge DAWN_FORMAT_VALIDATION_ERROR
into DAWN_VALIDATION_ERROR in follow-up CLs.

Bug: dawn:563
Change-Id: Ic1ba1de44216b36ef6a972712b957685e0ee193e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100467
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2022-08-30 13:33:37 +00:00
committed by Dawn LUCI CQ
parent c68683c306
commit 1eb6d2dd02
7 changed files with 31 additions and 34 deletions

View File

@@ -32,23 +32,20 @@ namespace dawn::native {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase* device,
const PipelineLayoutDescriptor* descriptor,
PipelineCompatibilityToken pipelineCompatibilityToken) {
if (descriptor->nextInChain != nullptr) {
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
}
if (descriptor->bindGroupLayoutCount > kMaxBindGroups) {
return DAWN_VALIDATION_ERROR("too many bind group layouts");
}
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain is not nullptr.");
DAWN_INVALID_IF(descriptor->bindGroupLayoutCount > kMaxBindGroups,
"bindGroupLayoutCount (%i) is larger than the maximum allowed (%i).",
descriptor->bindGroupLayoutCount, kMaxBindGroups);
BindingCounts bindingCounts = {};
for (uint32_t i = 0; i < descriptor->bindGroupLayoutCount; ++i) {
DAWN_TRY(device->ValidateObject(descriptor->bindGroupLayouts[i]));
if (descriptor->bindGroupLayouts[i]->GetPipelineCompatibilityToken() !=
pipelineCompatibilityToken) {
return DAWN_VALIDATION_ERROR(
"cannot create a pipeline layout using a bind group layout that was created as "
"part of a pipeline's default layout");
}
DAWN_INVALID_IF(descriptor->bindGroupLayouts[i]->GetPipelineCompatibilityToken() !=
pipelineCompatibilityToken,
"bindGroupLayouts[%i] (%s) is used to create a pipeline layout but it was "
"created as part of a pipeline's default layout.",
i, descriptor->bindGroupLayouts[i]);
AccumulateBindingCounts(&bindingCounts,
descriptor->bindGroupLayouts[i]->GetBindingCountInfo());
}
@@ -151,6 +148,8 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
// Check if any properties are incompatible with existing entry
// If compatible, we will merge some properties
// TODO(dawn:563): Improve the error message by doing early-outs when bindings aren't
// compatible instead of a single check at the end.
if (!compatible) {
return DAWN_VALIDATION_ERROR(
"Duplicate binding in default pipeline layout initialization "
@@ -281,7 +280,9 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
const auto& [existingEntry, inserted] =
entryData[group].insert({bindingNumber, entry});
if (!inserted) {
DAWN_TRY(MergeEntries(&existingEntry->second, entry));
DAWN_TRY_CONTEXT(MergeEntries(&existingEntry->second, entry),
"merging implicit bindings for @group(%u) @binding(%u).",
uint32_t(group), uint32_t(bindingNumber));
}
}
}

View File

@@ -177,9 +177,7 @@ MaybeError ValidatePrimitiveState(const DeviceBase* device, const PrimitiveState
MaybeError ValidateDepthStencilState(const DeviceBase* device,
const DepthStencilState* descriptor) {
if (descriptor->nextInChain != nullptr) {
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
}
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain is not nullptr.");
DAWN_TRY(ValidateCompareFunction(descriptor->depthCompare));
DAWN_TRY(ValidateCompareFunction(descriptor->stencilFront.compare));

View File

@@ -335,8 +335,8 @@ MaybeError ShaderModule::CreateFunction(const char* entryPointName,
error:&error]);
if (error != nullptr) {
if (error.code != MTLLibraryErrorCompileWarning) {
return DAWN_VALIDATION_ERROR(std::string("Function compile error: ") +
[error.localizedDescription UTF8String]);
return DAWN_FORMAT_VALIDATION_ERROR(
"Function compile error: %s", [error.localizedDescription UTF8String]);
}
}
ASSERT(out->function != nil);

View File

@@ -398,9 +398,8 @@ MaybeError SwapChain::Initialize(NewSwapChainBase* previousSwapChain) {
// TODO(crbug.com/dawn/269): figure out what should happen when surfaces are used by
// multiple backends one after the other. It probably needs to block until the backend
// and GPU are completely finished with the previous swapchain.
if (previousSwapChain->GetBackendType() != wgpu::BackendType::Null) {
return DAWN_VALIDATION_ERROR("null::SwapChain cannot switch between APIs");
}
DAWN_INVALID_IF(previousSwapChain->GetBackendType() != wgpu::BackendType::Null,
"null::SwapChain cannot switch between APIs");
}
return {};

View File

@@ -604,7 +604,7 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsInvalidAspect) {
// Validation should catch the invalid aspect.
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc),
testing::HasSubstr("Invalid value for WGPUTextureAspect"));
testing::HasSubstr("is invalid for WGPUTextureAspect"));
}
// Test creating cube map texture view