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:
parent
c68683c306
commit
1eb6d2dd02
|
@ -40,26 +40,25 @@ MaybeError ValidateSTypes(const ChainedStruct* chain,
|
|||
std::vector<std::vector<{{namespace}}::SType>> oneOfConstraints) {
|
||||
std::unordered_set<{{namespace}}::SType> allSTypes;
|
||||
for (; chain; chain = chain->nextInChain) {
|
||||
if (allSTypes.find(chain->sType) != allSTypes.end()) {
|
||||
return DAWN_VALIDATION_ERROR("Chain cannot have duplicate sTypes");
|
||||
}
|
||||
DAWN_INVALID_IF(allSTypes.find(chain->sType) != allSTypes.end(),
|
||||
"Extension chain has duplicate sType %s.", chain->sType);
|
||||
allSTypes.insert(chain->sType);
|
||||
}
|
||||
|
||||
for (const auto& oneOfConstraint : oneOfConstraints) {
|
||||
bool satisfied = false;
|
||||
for ({{namespace}}::SType oneOfSType : oneOfConstraint) {
|
||||
if (allSTypes.find(oneOfSType) != allSTypes.end()) {
|
||||
if (satisfied) {
|
||||
return DAWN_VALIDATION_ERROR("Unsupported sType combination");
|
||||
}
|
||||
DAWN_INVALID_IF(satisfied,
|
||||
"sType %s is part of a group of exclusive sTypes that is already present.",
|
||||
oneOfSType);
|
||||
satisfied = true;
|
||||
allSTypes.erase(oneOfSType);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!allSTypes.empty()) {
|
||||
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
||||
}
|
||||
|
||||
DAWN_INVALID_IF(!allSTypes.empty(), "Unsupported sType %s.", *allSTypes.begin());
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace {{native_namespace}} {
|
|||
return {};
|
||||
{% endfor %}
|
||||
default:
|
||||
return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
|
||||
return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace {{native_namespace}} {
|
|||
if ((value & static_cast<{{namespace}}::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
|
||||
return {};
|
||||
}
|
||||
return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
|
||||
return DAWN_FORMAT_VALIDATION_ERROR("Value %i is invalid for {{as_cType(type.name)}}.", static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue