dawn_native: handle NaN lod values in samplers

For samplers with NaN mLodMinClamp or mLodMaxClamp, the equality
operator returned false.
Adds checks for finite values, and also early returns if two pointers
are equal.

Bug: dawn:143, chromium:965633
Change-Id: Id5998d6eec275af0fbe30e3b4fcb3eed4fe64c6a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7401
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
This commit is contained in:
Idan Raiter
2019-05-22 17:18:52 +00:00
committed by Commit Bot service account
parent 18672ef994
commit 1c85976abe
3 changed files with 66 additions and 1 deletions

View File

@@ -18,6 +18,8 @@
#include "dawn_native/Device.h"
#include "dawn_native/ValidationUtils_autogen.h"
#include <cmath>
namespace dawn_native {
MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descriptor) {
@@ -25,6 +27,10 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
}
if (!std::isfinite(descriptor->lodMinClamp) || !std::isfinite(descriptor->lodMaxClamp)) {
return DAWN_VALIDATION_ERROR("LOD must be finite");
}
if (descriptor->lodMinClamp < 0 || descriptor->lodMaxClamp < 0) {
return DAWN_VALIDATION_ERROR("LOD must be positive");
}
@@ -95,6 +101,15 @@ namespace dawn_native {
}
bool SamplerBase::EqualityFunc::operator()(const SamplerBase* a, const SamplerBase* b) const {
if (a == b) {
return true;
}
ASSERT(std::isfinite(a->mLodMinClamp));
ASSERT(std::isfinite(b->mLodMinClamp));
ASSERT(std::isfinite(a->mLodMaxClamp));
ASSERT(std::isfinite(b->mLodMaxClamp));
return a->mAddressModeU == b->mAddressModeU && a->mAddressModeV == b->mAddressModeV &&
a->mAddressModeW == b->mAddressModeW && a->mMagFilter == b->mMagFilter &&
a->mMinFilter == b->mMinFilter && a->mMipmapFilter == b->mMipmapFilter &&