Invalidate sampler with maxAnisotropy = 0
Bug: dawn:568 Change-Id: Ic0eee693a91153e2447c8f9830919f74c08fde48 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/36320 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Shrek Shao <shrekshao@google.com>
This commit is contained in:
parent
9a38e5b60d
commit
86980018b3
|
@ -20,12 +20,6 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
namespace {
|
||||
uint16_t GetClampedMaxAnisotropy(uint16_t value) {
|
||||
return value >= 1u ? value : 1u;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
namespace dawn_native {
|
||||
|
||||
MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descriptor) {
|
||||
|
@ -54,6 +48,8 @@ namespace dawn_native {
|
|||
"min, mag, and mipmap filter should be linear when using anisotropic "
|
||||
"filtering");
|
||||
}
|
||||
} else if (descriptor->maxAnisotropy == 0u) {
|
||||
return DAWN_VALIDATION_ERROR("max anisotropy cannot be set to 0");
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
|
||||
|
@ -79,7 +75,7 @@ namespace dawn_native {
|
|||
mLodMinClamp(descriptor->lodMinClamp),
|
||||
mLodMaxClamp(descriptor->lodMaxClamp),
|
||||
mCompareFunction(descriptor->compare),
|
||||
mMaxAnisotropy(GetClampedMaxAnisotropy(descriptor->maxAnisotropy)) {
|
||||
mMaxAnisotropy(descriptor->maxAnisotropy) {
|
||||
}
|
||||
|
||||
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
|
|
|
@ -61,6 +61,11 @@ namespace {
|
|||
// when maxAnisotropy > 1, min, mag, mipmap filter should be linear
|
||||
device.CreateSampler(&kValidAnisoSamplerDesc);
|
||||
}
|
||||
{
|
||||
wgpu::SamplerDescriptor samplerDesc = kValidAnisoSamplerDesc;
|
||||
samplerDesc.maxAnisotropy = 0;
|
||||
ASSERT_DEVICE_ERROR(device.CreateSampler(&samplerDesc));
|
||||
}
|
||||
{
|
||||
wgpu::SamplerDescriptor samplerDesc = kValidAnisoSamplerDesc;
|
||||
samplerDesc.minFilter = wgpu::FilterMode::Nearest;
|
||||
|
|
Loading…
Reference in New Issue