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::vector<std::vector<{{namespace}}::SType>> oneOfConstraints) {
|
||||||
std::unordered_set<{{namespace}}::SType> allSTypes;
|
std::unordered_set<{{namespace}}::SType> allSTypes;
|
||||||
for (; chain; chain = chain->nextInChain) {
|
for (; chain; chain = chain->nextInChain) {
|
||||||
if (allSTypes.find(chain->sType) != allSTypes.end()) {
|
DAWN_INVALID_IF(allSTypes.find(chain->sType) != allSTypes.end(),
|
||||||
return DAWN_VALIDATION_ERROR("Chain cannot have duplicate sTypes");
|
"Extension chain has duplicate sType %s.", chain->sType);
|
||||||
}
|
|
||||||
allSTypes.insert(chain->sType);
|
allSTypes.insert(chain->sType);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& oneOfConstraint : oneOfConstraints) {
|
for (const auto& oneOfConstraint : oneOfConstraints) {
|
||||||
bool satisfied = false;
|
bool satisfied = false;
|
||||||
for ({{namespace}}::SType oneOfSType : oneOfConstraint) {
|
for ({{namespace}}::SType oneOfSType : oneOfConstraint) {
|
||||||
if (allSTypes.find(oneOfSType) != allSTypes.end()) {
|
if (allSTypes.find(oneOfSType) != allSTypes.end()) {
|
||||||
if (satisfied) {
|
DAWN_INVALID_IF(satisfied,
|
||||||
return DAWN_VALIDATION_ERROR("Unsupported sType combination");
|
"sType %s is part of a group of exclusive sTypes that is already present.",
|
||||||
}
|
oneOfSType);
|
||||||
satisfied = true;
|
satisfied = true;
|
||||||
allSTypes.erase(oneOfSType);
|
allSTypes.erase(oneOfSType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!allSTypes.empty()) {
|
|
||||||
return DAWN_VALIDATION_ERROR("Unsupported sType");
|
DAWN_INVALID_IF(!allSTypes.empty(), "Unsupported sType %s.", *allSTypes.begin());
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace {{native_namespace}} {
|
||||||
return {};
|
return {};
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
default:
|
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) {
|
if ((value & static_cast<{{namespace}}::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
|
||||||
return {};
|
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 %}
|
{% endfor %}
|
||||||
|
|
|
@ -32,23 +32,20 @@ namespace dawn::native {
|
||||||
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase* device,
|
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase* device,
|
||||||
const PipelineLayoutDescriptor* descriptor,
|
const PipelineLayoutDescriptor* descriptor,
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) {
|
PipelineCompatibilityToken pipelineCompatibilityToken) {
|
||||||
if (descriptor->nextInChain != nullptr) {
|
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain is not nullptr.");
|
||||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
DAWN_INVALID_IF(descriptor->bindGroupLayoutCount > kMaxBindGroups,
|
||||||
}
|
"bindGroupLayoutCount (%i) is larger than the maximum allowed (%i).",
|
||||||
|
descriptor->bindGroupLayoutCount, kMaxBindGroups);
|
||||||
if (descriptor->bindGroupLayoutCount > kMaxBindGroups) {
|
|
||||||
return DAWN_VALIDATION_ERROR("too many bind group layouts");
|
|
||||||
}
|
|
||||||
|
|
||||||
BindingCounts bindingCounts = {};
|
BindingCounts bindingCounts = {};
|
||||||
for (uint32_t i = 0; i < descriptor->bindGroupLayoutCount; ++i) {
|
for (uint32_t i = 0; i < descriptor->bindGroupLayoutCount; ++i) {
|
||||||
DAWN_TRY(device->ValidateObject(descriptor->bindGroupLayouts[i]));
|
DAWN_TRY(device->ValidateObject(descriptor->bindGroupLayouts[i]));
|
||||||
if (descriptor->bindGroupLayouts[i]->GetPipelineCompatibilityToken() !=
|
DAWN_INVALID_IF(descriptor->bindGroupLayouts[i]->GetPipelineCompatibilityToken() !=
|
||||||
pipelineCompatibilityToken) {
|
pipelineCompatibilityToken,
|
||||||
return DAWN_VALIDATION_ERROR(
|
"bindGroupLayouts[%i] (%s) is used to create a pipeline layout but it was "
|
||||||
"cannot create a pipeline layout using a bind group layout that was created as "
|
"created as part of a pipeline's default layout.",
|
||||||
"part of a pipeline's default layout");
|
i, descriptor->bindGroupLayouts[i]);
|
||||||
}
|
|
||||||
AccumulateBindingCounts(&bindingCounts,
|
AccumulateBindingCounts(&bindingCounts,
|
||||||
descriptor->bindGroupLayouts[i]->GetBindingCountInfo());
|
descriptor->bindGroupLayouts[i]->GetBindingCountInfo());
|
||||||
}
|
}
|
||||||
|
@ -151,6 +148,8 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
|
||||||
|
|
||||||
// Check if any properties are incompatible with existing entry
|
// Check if any properties are incompatible with existing entry
|
||||||
// If compatible, we will merge some properties
|
// 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) {
|
if (!compatible) {
|
||||||
return DAWN_VALIDATION_ERROR(
|
return DAWN_VALIDATION_ERROR(
|
||||||
"Duplicate binding in default pipeline layout initialization "
|
"Duplicate binding in default pipeline layout initialization "
|
||||||
|
@ -281,7 +280,9 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
|
||||||
const auto& [existingEntry, inserted] =
|
const auto& [existingEntry, inserted] =
|
||||||
entryData[group].insert({bindingNumber, entry});
|
entryData[group].insert({bindingNumber, entry});
|
||||||
if (!inserted) {
|
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,
|
MaybeError ValidateDepthStencilState(const DeviceBase* device,
|
||||||
const DepthStencilState* descriptor) {
|
const DepthStencilState* descriptor) {
|
||||||
if (descriptor->nextInChain != nullptr) {
|
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain is not nullptr.");
|
||||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
|
||||||
}
|
|
||||||
|
|
||||||
DAWN_TRY(ValidateCompareFunction(descriptor->depthCompare));
|
DAWN_TRY(ValidateCompareFunction(descriptor->depthCompare));
|
||||||
DAWN_TRY(ValidateCompareFunction(descriptor->stencilFront.compare));
|
DAWN_TRY(ValidateCompareFunction(descriptor->stencilFront.compare));
|
||||||
|
|
|
@ -335,8 +335,8 @@ MaybeError ShaderModule::CreateFunction(const char* entryPointName,
|
||||||
error:&error]);
|
error:&error]);
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
if (error.code != MTLLibraryErrorCompileWarning) {
|
if (error.code != MTLLibraryErrorCompileWarning) {
|
||||||
return DAWN_VALIDATION_ERROR(std::string("Function compile error: ") +
|
return DAWN_FORMAT_VALIDATION_ERROR(
|
||||||
[error.localizedDescription UTF8String]);
|
"Function compile error: %s", [error.localizedDescription UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ASSERT(out->function != nil);
|
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
|
// 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
|
// multiple backends one after the other. It probably needs to block until the backend
|
||||||
// and GPU are completely finished with the previous swapchain.
|
// and GPU are completely finished with the previous swapchain.
|
||||||
if (previousSwapChain->GetBackendType() != wgpu::BackendType::Null) {
|
DAWN_INVALID_IF(previousSwapChain->GetBackendType() != wgpu::BackendType::Null,
|
||||||
return DAWN_VALIDATION_ERROR("null::SwapChain cannot switch between APIs");
|
"null::SwapChain cannot switch between APIs");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -604,7 +604,7 @@ TEST_F(TextureViewValidationTest, TextureViewDescriptorDefaultsInvalidAspect) {
|
||||||
|
|
||||||
// Validation should catch the invalid aspect.
|
// Validation should catch the invalid aspect.
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc),
|
ASSERT_DEVICE_ERROR(texture.CreateView(&viewDesc),
|
||||||
testing::HasSubstr("Invalid value for WGPUTextureAspect"));
|
testing::HasSubstr("is invalid for WGPUTextureAspect"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test creating cube map texture view
|
// Test creating cube map texture view
|
||||||
|
|
Loading…
Reference in New Issue