From 3bbb510b7a9ac4f3df500b3c9067c70b86c80814 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 28 Sep 2022 22:05:20 +1000 Subject: [PATCH] GS/HW: Make trilinear filtering behavior consistent across backends Previously, triln=0 would result in nearest mipmap filtering in D3D/Vulkan, but forced base level in OpenGL. --- pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp | 2 +- pcsx2/GS/Renderers/DX12/GSDevice12.cpp | 2 +- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 2 +- pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp index 9762463973..aeaaa77858 100644 --- a/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTextureFX11.cpp @@ -259,7 +259,7 @@ void GSDevice11::SetupPS(const PSSelector& sel, const GSHWDrawConfig::PSConstant sd.AddressV = ssel.tav ? D3D11_TEXTURE_ADDRESS_WRAP : D3D11_TEXTURE_ADDRESS_CLAMP; sd.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sd.MinLOD = 0.0f; - sd.MaxLOD = ssel.lodclamp ? 0.0f : FLT_MAX; + sd.MaxLOD = (ssel.lodclamp || !ssel.UseMipmapFiltering()) ? 0.25f : FLT_MAX; sd.MaxAnisotropy = std::clamp(anisotropy, 1, 16); sd.ComparisonFunc = D3D11_COMPARISON_NEVER; diff --git a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp index 8579de944a..e4c6972acf 100644 --- a/pcsx2/GS/Renderers/DX12/GSDevice12.cpp +++ b/pcsx2/GS/Renderers/DX12/GSDevice12.cpp @@ -908,7 +908,7 @@ bool GSDevice12::GetSampler(D3D12::DescriptorHandle* cpu_handle, GSHWDrawConfig: sd.AddressV = ss.tav ? D3D12_TEXTURE_ADDRESS_MODE_WRAP : D3D12_TEXTURE_ADDRESS_MODE_CLAMP; sd.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; sd.MinLOD = 0.0f; - sd.MaxLOD = ss.lodclamp ? 0.0f : FLT_MAX; + sd.MaxLOD = (ss.lodclamp || !ss.UseMipmapFiltering()) ? 0.25f : FLT_MAX; sd.MaxAnisotropy = std::clamp(GSConfig.MaxAnisotropy, 1, 16); sd.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER; diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index 6ea6dd028d..1e0ca7f6c9 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -883,7 +883,7 @@ GLuint GSDeviceOGL::CreateSampler(PSSamplerSelector sel) } glSamplerParameterf(sampler, GL_TEXTURE_MIN_LOD, -1000.0f); - glSamplerParameterf(sampler, GL_TEXTURE_MAX_LOD, sel.lodclamp ? 0.0f : 1000.0f); + glSamplerParameterf(sampler, GL_TEXTURE_MAX_LOD, sel.lodclamp ? 0.25f : 1000.0f); if (sel.tau) glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, GL_REPEAT); diff --git a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp index ddcad27440..8139f94dab 100644 --- a/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp +++ b/pcsx2/GS/Renderers/Vulkan/GSDeviceVK.cpp @@ -1029,7 +1029,7 @@ VkSampler GSDeviceVK::GetSampler(GSHWDrawConfig::SamplerSelector ss) VK_FALSE, // compare enable VK_COMPARE_OP_ALWAYS, // compare op 0.0f, // min lod - ss.lodclamp ? 0.25f : VK_LOD_CLAMP_NONE, // max lod + (ss.lodclamp || !ss.UseMipmapFiltering()) ? 0.25f : VK_LOD_CLAMP_NONE, // max lod VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // border VK_FALSE // unnormalized coordinates };