From 2e012b89666c3c67cea7839e6cc9f99ac49f96fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 16 Jul 2026 15:55:24 +0200 Subject: [PATCH] Unify the "BindSampler" function between the backends --- GPU/Common/TextureCacheCommon.cpp | 7 +++++++ GPU/Common/TextureCacheCommon.h | 3 ++- GPU/D3D11/TextureCacheD3D11.cpp | 9 --------- GPU/D3D11/TextureCacheD3D11.h | 1 - GPU/GLES/TextureCacheGLES.cpp | 7 ------- GPU/GLES/TextureCacheGLES.h | 1 - GPU/Vulkan/TextureCacheVulkan.cpp | 7 ------- GPU/Vulkan/TextureCacheVulkan.h | 1 - 8 files changed, 9 insertions(+), 27 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 01ceb0035e..e0730ba286 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2693,6 +2693,13 @@ void TextureCacheCommon::DeleteTexture(TexCache::iterator it) { cache_.erase(it); } +void TextureCacheCommon::BindSampler(TexCacheEntry *entry, bool flatZ) { + _dbg_assert_(entry); + int maxLevel = (entry->status & TexStatus::NO_MIPS) ? 0 : entry->maxLevel; + SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry, flatZ); + ApplySamplingParams(samplerKey); +} + bool TextureCacheCommon::CheckFullHash(TexCacheEntry *entry, bool &doDelete) { int w = gstate.getTextureWidth(0); int h = gstate.getTextureHeight(0); diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 92d0bd47a6..7798d8ed0c 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -406,7 +406,8 @@ protected: bool PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEntry *entry); virtual void BindTexture(TexCacheEntry *entry) = 0; - virtual void BindSampler(TexCacheEntry *entry, bool flatZ) = 0; + + void BindSampler(TexCacheEntry *entry, bool flatZ); virtual void Unbind() = 0; virtual void ReleaseTexture(TexCacheEntry *entry, bool delete_them) = 0; diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 163487201d..f1c20ede88 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -222,15 +222,6 @@ void TextureCacheD3D11::BindTexture(TexCacheEntry *entry) { } } -void TextureCacheD3D11::BindSampler(TexCacheEntry *entry, bool flatZ) { - _dbg_assert_(entry); - int maxLevel = (entry->status & TexStatus::NO_MIPS) ? 0 : entry->maxLevel; - SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry, flatZ); - ComPtr state; - samplerCache_.GetOrCreateSampler(device_, samplerKey, &state); - context_->PSSetSamplers(0, 1, state.GetAddressOf()); -} - void TextureCacheD3D11::ApplySamplingParams(const SamplerCacheKey &key) { ComPtr state; samplerCache_.GetOrCreateSampler(device_, key, &state); diff --git a/GPU/D3D11/TextureCacheD3D11.h b/GPU/D3D11/TextureCacheD3D11.h index 0f99fa3508..791830902e 100644 --- a/GPU/D3D11/TextureCacheD3D11.h +++ b/GPU/D3D11/TextureCacheD3D11.h @@ -65,7 +65,6 @@ public: protected: void BindTexture(TexCacheEntry *entry) override; - void BindSampler(TexCacheEntry *entry, bool flatZ) override; void Unbind() override; void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override; void BindAsClutTexture(Draw::Texture *tex, bool smooth) override; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 5ef1826062..b1de09c524 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -189,13 +189,6 @@ void TextureCacheGLES::BindTexture(TexCacheEntry *entry) { } } -void TextureCacheGLES::BindSampler(TexCacheEntry *entry, bool flatZ) { - _dbg_assert_(entry); - int maxLevel = (entry->status & TexStatus::NO_MIPS) ? 0 : entry->maxLevel; - SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry, flatZ); - ApplySamplingParams(samplerKey); -} - void TextureCacheGLES::Unbind() { render_->BindTexture(TEX_SLOT_PSP_TEXTURE, nullptr); ForgetLastTexture(); diff --git a/GPU/GLES/TextureCacheGLES.h b/GPU/GLES/TextureCacheGLES.h index 84d1ccc5e7..22d88dba16 100644 --- a/GPU/GLES/TextureCacheGLES.h +++ b/GPU/GLES/TextureCacheGLES.h @@ -54,7 +54,6 @@ public: protected: void BindTexture(TexCacheEntry *entry) override; - void BindSampler(TexCacheEntry *entry, bool flatZ) override; void Unbind() override; void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index b5aa3f4138..689615dab2 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -585,13 +585,6 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) { imageView_ = entry->vkTex->GetImageView(); } -void TextureCacheVulkan::BindSampler(TexCacheEntry *entry, bool flatZ) { - _dbg_assert_(entry); - int maxLevel = (entry->status & TexStatus::NO_MIPS) ? 0 : entry->maxLevel; - SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry, flatZ); - curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey); -} - void TextureCacheVulkan::ApplySamplingParams(const SamplerCacheKey &key) { curSampler_ = samplerCache_.GetOrCreateSampler(key); } diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 580cd3cb5c..ff8d0a7d49 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -86,7 +86,6 @@ public: protected: void BindTexture(TexCacheEntry *entry) override; - void BindSampler(TexCacheEntry *entry, bool flatZ) override; void Unbind() override; void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override; void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;