mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Add maxAnisotropy to GPUSamplerDescriptor
Adds some maxAnisotropy implementation. Adds an end2end test, drawing a slanted plane with a texture of which each mipmap has a different color, with different maxAnisotropy values. You can get an idea of what it does at https://jsfiddle.net/t64kpu81/85/ Needs further CTS. Bug: dawn:568 Change-Id: I89ac56d8cf0fbb655358bf6effa016ddc1f8426f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35143 Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
c08276644f
commit
f8c5e4ab74
@@ -20,6 +20,12 @@
|
||||
|
||||
#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) {
|
||||
@@ -40,6 +46,16 @@ namespace dawn_native {
|
||||
"Min lod clamp value cannot greater than max lod clamp value");
|
||||
}
|
||||
|
||||
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_TRY(ValidateFilterMode(descriptor->minFilter));
|
||||
DAWN_TRY(ValidateFilterMode(descriptor->magFilter));
|
||||
DAWN_TRY(ValidateFilterMode(descriptor->mipmapFilter));
|
||||
@@ -62,7 +78,8 @@ namespace dawn_native {
|
||||
mMipmapFilter(descriptor->mipmapFilter),
|
||||
mLodMinClamp(descriptor->lodMinClamp),
|
||||
mLodMaxClamp(descriptor->lodMaxClamp),
|
||||
mCompareFunction(descriptor->compare) {
|
||||
mCompareFunction(descriptor->compare),
|
||||
mMaxAnisotropy(GetClampedMaxAnisotropy(descriptor->maxAnisotropy)) {
|
||||
}
|
||||
|
||||
SamplerBase::SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||
@@ -87,7 +104,8 @@ namespace dawn_native {
|
||||
size_t SamplerBase::ComputeContentHash() {
|
||||
ObjectContentHasher recorder;
|
||||
recorder.Record(mAddressModeU, mAddressModeV, mAddressModeW, mMagFilter, mMinFilter,
|
||||
mMipmapFilter, mLodMinClamp, mLodMaxClamp, mCompareFunction);
|
||||
mMipmapFilter, mLodMinClamp, mLodMaxClamp, mCompareFunction,
|
||||
mMaxAnisotropy);
|
||||
return recorder.GetContentHash();
|
||||
}
|
||||
|
||||
@@ -105,7 +123,7 @@ namespace dawn_native {
|
||||
a->mAddressModeW == b->mAddressModeW && a->mMagFilter == b->mMagFilter &&
|
||||
a->mMinFilter == b->mMinFilter && a->mMipmapFilter == b->mMipmapFilter &&
|
||||
a->mLodMinClamp == b->mLodMinClamp && a->mLodMaxClamp == b->mLodMaxClamp &&
|
||||
a->mCompareFunction == b->mCompareFunction;
|
||||
a->mCompareFunction == b->mCompareFunction && a->mMaxAnisotropy == b->mMaxAnisotropy;
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
Reference in New Issue
Block a user