From ea95eb420d9b2014f5c7d31ceb21e7d12ea76151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 16 Jul 2026 12:40:24 +0200 Subject: [PATCH] Clean up GetFramebufferSamplingParams --- GPU/Common/TextureCacheCommon.cpp | 37 ++++++++++++++++++++++++------- GPU/D3D11/DrawEngineD3D11.cpp | 4 ++-- GPU/GLES/DrawEngineGLES.cpp | 4 ++-- GPU/Vulkan/DrawEngineVulkan.cpp | 4 ++-- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 7f96bc2900..af0478aa91 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -338,18 +338,39 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac } SamplerCacheKey TextureCacheCommon::GetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight) { - // TODO: This call is pretty pointless, we overwrite most of it. - SamplerCacheKey key = GetSamplingParams(0, nullptr, true); + SamplerCacheKey key{}; - // In case auto max quality was on, restore min filt. Another fix for water in Outrun. - if (g_Config.iTexFiltering == TEX_FILTER_AUTO_MAX_QUALITY) { - int minFilt = gstate.texfilter & 0x7; - key.minFilt = minFilt & 1; + key.magFilt = gstate.isMagnifyFilteringEnabled(); + int minFilt = gstate.texfilter & 0x7; + key.minFilt = minFilt & 1; + key.mipEnable = false; + key.mipFilt = false; + key.mipFilt = false; + key.sClamp = gstate.isTexCoordClampedS(); + key.tClamp = gstate.isTexCoordClampedT(); + key.aniso = false; + key.texture3d = false; + + // Filtering overrides from replacements or settings. + switch ((TextureFiltering)g_Config.iTexFiltering) { + case TEX_FILTER_AUTO: + case TEX_FILTER_AUTO_MAX_QUALITY: + if (gstate_c.pixelMapped) { + key.magFilt = false; + key.minFilt = false; + } + break; + case TEX_FILTER_FORCE_LINEAR: + key.magFilt = true; + key.minFilt = true; + break; + case TEX_FILTER_FORCE_NEAREST: + key.magFilt = false; + key.minFilt = false; + break; } // Kill any mipmapping settings. - key.mipEnable = false; - key.mipFilt = false; key.aniso = 0.0f; key.maxLevel = 0.0f; key.lodBias = 0.0f; diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 16a047ea28..8f15646264 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -433,9 +433,9 @@ void DrawEngineD3D11::Flush() { params.clipInfoFlags = clipInfoFlags_; const SoftwareTransformAction action = RunSoftwareTransform(params, prim, swDec->VertexType(), swDec->GetDecVtxFmt(), numDecodedVerts_, VERTEX_BUFFER_MAX, vertexCount, inds, RemainingIndices(inds), &result); - - if (result.setSafeSize) + if (result.setSafeSize) { framebufferManager_->SetSafeSize(result.safeWidth, result.safeHeight); + } // TODO: This should be after BuildDrawingParams! if (textureNeedsApply) { diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 9ce95b58be..06909a8bc0 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -387,9 +387,9 @@ void DrawEngineGLES::Flush() { params.clipInfoFlags = clipInfoFlags_; const SoftwareTransformAction action = RunSoftwareTransform(params, prim, swDec->VertexType(), swDec->GetDecVtxFmt(), numDecodedVerts_, VERTEX_BUFFER_MAX, vertexCount, inds, RemainingIndices(inds), &result); - - if (result.setSafeSize) + if (result.setSafeSize) { framebufferManager_->SetSafeSize(result.safeWidth, result.safeHeight); + } if (textureNeedsApply) { gstate_c.pixelMapped = result.pixelMapped; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index a0582338a3..e387d4f110 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -427,9 +427,9 @@ void DrawEngineVulkan::Flush() { params.clipInfoFlags = clipInfoFlags_; const SoftwareTransformAction action = RunSoftwareTransform(params, prim, swDec->VertexType(), swDec->GetDecVtxFmt(), numDecodedVerts_, VERTEX_BUFFER_MAX, vertexCount, inds, RemainingIndices(inds), &result); - - if (result.setSafeSize) + if (result.setSafeSize) { framebufferManager_->SetSafeSize(result.safeWidth, result.safeHeight); + } // Only here, where we know whether to clear or to draw primitives, should we actually set the current framebuffer! Because that gives use the opportunity // to use a "pre-clear" render pass, for high efficiency on tilers.