From 601d8ff6292d32e16b90bc125904ad2fa75bcb97 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 4 Dec 2023 21:22:02 +1000 Subject: [PATCH] MetalDevice: Anisotropy should be minimum 1 --- src/util/d3d11_texture.cpp | 2 +- src/util/d3d12_texture.cpp | 2 +- src/util/metal_device.mm | 2 +- src/util/opengl_texture.cpp | 6 ++---- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/util/d3d11_texture.cpp b/src/util/d3d11_texture.cpp index f0c6548f9..eca2705bd 100644 --- a/src/util/d3d11_texture.cpp +++ b/src/util/d3d11_texture.cpp @@ -197,7 +197,7 @@ std::unique_ptr D3D11Device::CreateSampler(const GPUSampler::Config& desc.MinLOD = static_cast(config.min_lod); desc.MaxLOD = static_cast(config.max_lod); - if (config.anisotropy > 0) + if (config.anisotropy > 1) { desc.Filter = D3D11_FILTER_ANISOTROPIC; desc.MaxAnisotropy = config.anisotropy; diff --git a/src/util/d3d12_texture.cpp b/src/util/d3d12_texture.cpp index 33af43a40..48600f7ac 100644 --- a/src/util/d3d12_texture.cpp +++ b/src/util/d3d12_texture.cpp @@ -806,7 +806,7 @@ D3D12DescriptorHandle D3D12Device::GetSampler(const GPUSampler::Config& config) desc.MinLOD = static_cast(config.min_lod); desc.MaxLOD = static_cast(config.max_lod); - if (config.anisotropy > 0) + if (config.anisotropy > 1) { desc.Filter = D3D12_FILTER_ANISOTROPIC; desc.MaxAnisotropy = config.anisotropy; diff --git a/src/util/metal_device.mm b/src/util/metal_device.mm index 846072bbe..46e36ec14 100644 --- a/src/util/metal_device.mm +++ b/src/util/metal_device.mm @@ -1264,7 +1264,7 @@ std::unique_ptr MetalDevice::CreateSampler(const GPUSampler::Config& MTLSamplerMipFilterNotMipmapped; desc.lodMinClamp = static_cast(config.min_lod); desc.lodMaxClamp = static_cast(config.max_lod); - desc.maxAnisotropy = config.anisotropy; + desc.maxAnisotropy = std::max(config.anisotropy, 1); if (config.address_u == GPUSampler::AddressMode::ClampToBorder || config.address_v == GPUSampler::AddressMode::ClampToBorder || diff --git a/src/util/opengl_texture.cpp b/src/util/opengl_texture.cpp index dbbf2285a..ee3ece6e7 100644 --- a/src/util/opengl_texture.cpp +++ b/src/util/opengl_texture.cpp @@ -376,10 +376,8 @@ std::unique_ptr OpenGLDevice::CreateSampler(const GPUSampler::Config glSamplerParameterf(sampler, GL_TEXTURE_MIN_LOD, static_cast(config.min_lod)); glSamplerParameterf(sampler, GL_TEXTURE_MAX_LOD, static_cast(config.max_lod)); glSamplerParameterfv(sampler, GL_TEXTURE_BORDER_COLOR, config.GetBorderFloatColor().data()); - if (config.anisotropy) - { - // TODO - } + if (config.anisotropy > 1) + glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY, static_cast(config.anisotropy.GetValue())); return std::unique_ptr(new OpenGLSampler(sampler)); }