Improve validation errors for Sampler
Bug: dawn:563 Change-Id: I4bc774fd89c1a0b7adfca2b5bd7734751257b18b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65800 Auto-Submit: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a089e8c4f2
commit
575a198764
|
@ -1388,7 +1388,8 @@ namespace dawn_native {
|
|||
DAWN_TRY(ValidateIsAlive());
|
||||
descriptor = descriptor != nullptr ? descriptor : &defaultDescriptor;
|
||||
if (IsValidationEnabled()) {
|
||||
DAWN_TRY(ValidateSamplerDescriptor(this, descriptor));
|
||||
DAWN_TRY_CONTEXT(ValidateSamplerDescriptor(this, descriptor), "validating %s",
|
||||
descriptor);
|
||||
}
|
||||
return GetOrCreateSampler(descriptor);
|
||||
}
|
||||
|
|
|
@ -23,33 +23,31 @@
|
|||
namespace dawn_native {
|
||||
|
||||
MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descriptor) {
|
||||
if (descriptor->nextInChain != nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
||||
}
|
||||
DAWN_INVALID_IF(descriptor->nextInChain != nullptr, "nextInChain must be nullptr");
|
||||
|
||||
if (std::isnan(descriptor->lodMinClamp) || std::isnan(descriptor->lodMaxClamp)) {
|
||||
return DAWN_VALIDATION_ERROR("LOD clamp bounds must not be NaN");
|
||||
}
|
||||
DAWN_INVALID_IF(std::isnan(descriptor->lodMinClamp) || std::isnan(descriptor->lodMaxClamp),
|
||||
"LOD clamp bounds [%f, %f] contain a NaN.", descriptor->lodMinClamp,
|
||||
descriptor->lodMaxClamp);
|
||||
|
||||
if (descriptor->lodMinClamp < 0 || descriptor->lodMaxClamp < 0) {
|
||||
return DAWN_VALIDATION_ERROR("LOD clamp bounds must be positive");
|
||||
}
|
||||
DAWN_INVALID_IF(descriptor->lodMinClamp < 0 || descriptor->lodMaxClamp < 0,
|
||||
"LOD clamp bounds [%f, %f] contain contain a negative number.",
|
||||
descriptor->lodMinClamp, descriptor->lodMaxClamp);
|
||||
|
||||
if (descriptor->lodMinClamp > descriptor->lodMaxClamp) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"Min lod clamp value cannot greater than max lod clamp value");
|
||||
}
|
||||
DAWN_INVALID_IF(descriptor->lodMinClamp > descriptor->lodMaxClamp,
|
||||
"LOD min clamp (%f) is larger than the max clamp (%f).",
|
||||
descriptor->lodMinClamp, descriptor->lodMaxClamp);
|
||||
|
||||
if (descriptor->maxAnisotropy > 1) {
|
||||
if (descriptor->minFilter != wgpu::FilterMode::Linear ||
|
||||
descriptor->magFilter != wgpu::FilterMode::Linear ||
|
||||
descriptor->mipmapFilter != wgpu::FilterMode::Linear) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"min, mag, and mipmap filter should be linear when using anisotropic "
|
||||
"filtering");
|
||||
}
|
||||
DAWN_INVALID_IF(descriptor->minFilter != wgpu::FilterMode::Linear ||
|
||||
descriptor->magFilter != wgpu::FilterMode::Linear ||
|
||||
descriptor->mipmapFilter != wgpu::FilterMode::Linear,
|
||||
"One of minFilter (%s), magFilter (%s) or mipmapFilter (%s) is not %s "
|
||||
"while using anisotropic filter (maxAnisotropy is %f)",
|
||||
descriptor->magFilter, descriptor->minFilter, descriptor->mipmapFilter,
|
||||
wgpu::FilterMode::Linear, descriptor->maxAnisotropy);
|
||||
} else if (descriptor->maxAnisotropy == 0u) {
|
||||
return DAWN_VALIDATION_ERROR("max anisotropy cannot be set to 0");
|
||||
return DAWN_FORMAT_VALIDATION_ERROR("Max anisotropy (%f) is less than 1.",
|
||||
descriptor->maxAnisotropy);
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
|
||||
|
|
Loading…
Reference in New Issue