diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 1fedfa67d3..04a8669ce1 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -252,6 +252,24 @@ void TextureCacheCommon::UpdateSamplingParams(int maxLevel, u32 texAddr, Sampler } } +void TextureCacheCommon::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key) { + UpdateSamplingParams(0, 0, key); + + key.mipEnable = false; + key.minFilt &= 1; + key.mipFilt = 0; + key.magFilt &= 1; + key.aniso = 0.0; + + // Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case. + int w = gstate.getTextureWidth(0); + int h = gstate.getTextureHeight(0); + if (w != bufferWidth || h != bufferHeight) { + key.sClamp = true; + key.tClamp = true; + } +} + void TextureCacheCommon::UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode) { // If the texture is >= 512 pixels tall... if (entry->dim >= 0x900) { diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 652eba6578..db75b9baba 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -284,8 +284,9 @@ protected: } u32 EstimateTexMemoryUsage(const TexCacheEntry *entry); - void GetSamplingParams(int &minFilt, int &magFilt, bool &sClamp, bool &tClamp, float &lodBias, int maxLevel, u32 addr, GETexLevelMode &mode); + void UpdateSamplingParams(int maxLevel, u32 texAddr, SamplerCacheKey &key); // Used by D3D11 and Vulkan. + void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key); void UpdateMaxSeenV(TexCacheEntry *entry, bool throughMode); FramebufferMatchInfo MatchFramebuffer(const TextureDefinition &entry, VirtualFramebuffer *framebuffer, u32 texaddrOffset, FramebufferNotificationChannel channel) const; diff --git a/GPU/D3D11/GPU_D3D11.h b/GPU/D3D11/GPU_D3D11.h index 0c1f1d3524..bf41243b88 100644 --- a/GPU/D3D11/GPU_D3D11.h +++ b/GPU/D3D11/GPU_D3D11.h @@ -17,19 +17,19 @@ #pragma once -#include -#include +#include +#include #include #include "GPU/GPUCommon.h" #include "GPU/D3D11/DrawEngineD3D11.h" -#include "GPU/D3D11/TextureCacheD3D11.h" #include "GPU/D3D11/DepalettizeShaderD3D11.h" #include "GPU/Common/VertexDecoderCommon.h" class FramebufferManagerD3D11; class ShaderManagerD3D11; class LinkedShaderD3D11; +class TextureCacheD3D11; class GPU_D3D11 : public GPUCommon { public: diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index b9ceb5326e..3957b48c5c 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -156,24 +156,6 @@ void TextureCacheD3D11::InvalidateLastTexture(TexCacheEntry *entry) { } } -void TextureCacheD3D11::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key) { - UpdateSamplingParams(0, 0, key); - - key.mipEnable = false; - key.minFilt &= 1; - key.mipFilt = 0; - key.magFilt &= 1; - - // Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case. - // This happens whether we have OES_texture_npot or not. - int w = gstate.getTextureWidth(0); - int h = gstate.getTextureHeight(0); - if (w != bufferWidth || h != bufferHeight) { - key.sClamp = true; - key.tClamp = true; - } -} - void TextureCacheD3D11::StartFrame() { InvalidateLastTexture(); timesInvalidatedAllThisFrame_ = 0; diff --git a/GPU/D3D11/TextureCacheD3D11.h b/GPU/D3D11/TextureCacheD3D11.h index db154c5a77..6aa3bcda9e 100644 --- a/GPU/D3D11/TextureCacheD3D11.h +++ b/GPU/D3D11/TextureCacheD3D11.h @@ -60,7 +60,6 @@ public: void ForgetLastTexture() override; void InvalidateLastTexture(TexCacheEntry *entry = nullptr) override; - void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key); bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; protected: diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index aab20eabe1..6f33fcf90c 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -17,13 +17,12 @@ #pragma once -#include -#include +#include +#include #include "GPU/GPUCommon.h" #include "GPU/Directx9/FramebufferManagerDX9.h" #include "GPU/Directx9/DrawEngineDX9.h" -#include "GPU/Directx9/TextureCacheDX9.h" #include "GPU/Directx9/DepalettizeShaderDX9.h" #include "GPU/Common/VertexDecoderCommon.h" @@ -31,6 +30,7 @@ namespace DX9 { class ShaderManagerDX9; class LinkedShaderDX9; +class TextureCacheDX9; class GPU_DX9 : public GPUCommon { public: diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index cafe16f7d0..5343a3100b 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -119,23 +119,6 @@ D3DFORMAT getClutDestFormat(GEPaletteFormat format) { return D3DFMT_A8R8G8B8; } -void TextureCacheDX9::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key) { - UpdateSamplingParams(0, 0, key); - - key.mipEnable = false; - key.minFilt &= 1; - key.mipFilt = 0; - key.magFilt &= 1; - - // Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case. - int w = gstate.getTextureWidth(0); - int h = gstate.getTextureHeight(0); - if (w != bufferWidth || h != bufferHeight) { - key.sClamp = true; - key.tClamp = true; - } -} - void TextureCacheDX9::ApplySamplingParams(const SamplerCacheKey &key) { dxstate.texMinFilter.set(key.minFilt ? D3DTEXF_LINEAR : D3DTEXF_POINT); dxstate.texMipFilter.set(key.mipFilt ? D3DTEXF_LINEAR : D3DTEXF_POINT); diff --git a/GPU/Directx9/TextureCacheDX9.h b/GPU/Directx9/TextureCacheDX9.h index 9b2d9315bc..3a0c291586 100644 --- a/GPU/Directx9/TextureCacheDX9.h +++ b/GPU/Directx9/TextureCacheDX9.h @@ -52,8 +52,6 @@ public: void ForgetLastTexture() override; void InvalidateLastTexture(TexCacheEntry *entry = nullptr) override; - void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key); - bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; protected: diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index 0775ec8d8b..5bb68e2ef3 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -17,17 +17,17 @@ #pragma once -#include -#include +#include +#include #include "GPU/GPUCommon.h" #include "GPU/GLES/FramebufferManagerGLES.h" #include "GPU/GLES/DrawEngineGLES.h" -#include "GPU/GLES/TextureCacheGLES.h" #include "GPU/GLES/DepalettizeShaderGLES.h" #include "GPU/GLES/FragmentTestCacheGLES.h" class ShaderManagerGLES; +class TextureCacheGLES; class LinkedShader; class GPU_GLES : public GPUCommon { diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index cb0ce93ef2..1b7af5f044 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -130,20 +130,6 @@ void TextureCacheGLES::ApplySamplingParams(const SamplerCacheKey &key) { MagFiltGL[magKey], key.minFilt ? GL_LINEAR : GL_NEAREST, aniso); } -void TextureCacheGLES::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key) { - UpdateSamplingParams(0, 0, key); - key.mipEnable = false; // framebuffers can't mipmap. - // Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case. - // This happens whether we have OES_texture_npot or not. - int w = gstate.getTextureWidth(0); - int h = gstate.getTextureHeight(0); - if (w != bufferWidth || h != bufferHeight) { - key.sClamp = true; - key.tClamp = true; - } - key.aniso = 0.0f; -} - static void ConvertColors(void *dstBuf, const void *srcBuf, Draw::DataFormat dstFmt, int numPixels) { const u32 *src = (const u32 *)srcBuf; u32 *dst = (u32 *)dstBuf; diff --git a/GPU/GLES/TextureCacheGLES.h b/GPU/GLES/TextureCacheGLES.h index 42329b57a2..7564b635b5 100644 --- a/GPU/GLES/TextureCacheGLES.h +++ b/GPU/GLES/TextureCacheGLES.h @@ -63,7 +63,6 @@ public: } } - void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key); bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; void DeviceLost(); diff --git a/GPU/Vulkan/DebugVisVulkan.cpp b/GPU/Vulkan/DebugVisVulkan.cpp index 8f2cc381a4..023e840d56 100644 --- a/GPU/Vulkan/DebugVisVulkan.cpp +++ b/GPU/Vulkan/DebugVisVulkan.cpp @@ -25,6 +25,7 @@ #include "Common/Vulkan/VulkanImage.h" #include "GPU/Vulkan/GPU_Vulkan.h" #include "GPU/Vulkan/VulkanUtil.h" +#include "GPU/Vulkan/TextureCacheVulkan.h" #undef DrawText diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index a56304869b..894cc295b4 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -17,18 +17,18 @@ #pragma once -#include -#include +#include +#include #include "GPU/GPUCommon.h" #include "GPU/Vulkan/DrawEngineVulkan.h" #include "GPU/Vulkan/PipelineManagerVulkan.h" -#include "GPU/Vulkan/TextureCacheVulkan.h" #include "GPU/Vulkan/DepalettizeShaderVulkan.h" class FramebufferManagerVulkan; class ShaderManagerVulkan; class LinkedShader; +class TextureCacheVulkan; class GPU_Vulkan : public GPUCommon { public: diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 56980441dc..596badb5c7 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -28,7 +28,6 @@ #include "Core/Reporting.h" #include "GPU/Vulkan/GPU_Vulkan.h" #include "GPU/Vulkan/PipelineManagerVulkan.h" -#include "GPU/Vulkan/TextureCacheVulkan.h" #include "GPU/Vulkan/FramebufferManagerVulkan.h" #include "GPU/Vulkan/ShaderManagerVulkan.h" #include "GPU/Vulkan/DrawEngineVulkan.h" diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 6ecd34e419..e17cbae949 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -439,25 +439,6 @@ static const VkFilter MagFiltVK[2] = { VK_FILTER_LINEAR }; -void TextureCacheVulkan::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key) { - UpdateSamplingParams(0, 0, key); - - key.mipEnable = false; - key.minFilt &= 1; - key.mipFilt = 0; - key.magFilt &= 1; - - // Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case. - // This happens whether we have OES_texture_npot or not. - int w = gstate.getTextureWidth(0); - int h = gstate.getTextureHeight(0); - - if (w != bufferWidth || h != bufferHeight) { - key.sClamp = true; - key.tClamp = true; - } -} - void TextureCacheVulkan::StartFrame() { InvalidateLastTexture(); depalShaderCache_->Decimate(); diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 059b4be0ec..7aaa04d56e 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -100,7 +100,6 @@ public: imageView = imageView_; sampler = curSampler_; } - void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key); bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override;