diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 7e251fa76..c824fc0ef 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -537,7 +537,7 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) { // It's possible for a game to (successfully) access outside valid memory. u32 bytes = Memory::ValidSize(clutAddr, loadBytes); if (clutRenderAddress_ != 0xFFFFFFFF && !g_Config.bDisableSlowFramebufEffects) { - DownloadFramebufferForClut(clutRenderAddress_, clutRenderOffset_ + bytes); + framebufferManager_->DownloadFramebufferForClut(clutRenderAddress_, clutRenderOffset_ + bytes); Memory::MemcpyUnchecked(clutBufRaw_, clutAddr, bytes); if (bytes < loadBytes) { memset((u8 *)clutBufRaw_ + bytes, 0x00, loadBytes - bytes); diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 8c6c83b5a..eef5d7f64 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -52,6 +52,8 @@ namespace Draw { class DrawContext; } +class FramebufferManagerCommon; + class TextureCacheCommon { public: TextureCacheCommon(Draw::DrawContext *draw); @@ -194,8 +196,6 @@ protected: void SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer); - virtual void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) = 0; - void DecimateVideos(); inline u32 QuickTexHash(TextureReplacer &replacer, u32 addr, int bufw, int w, int h, GETextureFormat format, TexCacheEntry *entry) { @@ -219,6 +219,7 @@ protected: Draw::DrawContext *draw_; TextureReplacer replacer; + FramebufferManagerCommon *framebufferManager_; bool clearCacheNextFrame_; bool lowMemoryMode_; diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 21d858721..cab431d1e 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -93,6 +93,11 @@ TextureCacheDX9::~TextureCacheDX9() { Clear(true); } +void TextureCacheDX9::SetFramebufferManager(FramebufferManagerDX9 *fbManager) { + framebufferManagerDX9_ = fbManager; + framebufferManager_ = fbManager; +} + void TextureCacheDX9::Clear(bool delete_them) { pD3Ddevice->SetTexture(0, NULL); lastBoundTexture = INVALID_TEX; @@ -409,10 +414,6 @@ void TextureCacheDX9::ApplyTexture() { } } -void TextureCacheDX9::DownloadFramebufferForClut(u32 clutAddr, u32 bytes) { - framebufferManager_->DownloadFramebufferForClut(clutAddr, bytes); -} - class TextureShaderApplierDX9 { public: struct Pos { @@ -544,7 +545,7 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame if (pshader) { LPDIRECT3DTEXTURE9 clutTexture = depalShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBuf_); - Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, Draw::FBO_8888); + Draw::Framebuffer *depalFBO = framebufferManagerDX9_->GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, Draw::FBO_8888); draw_->BindFramebufferAsRenderTarget(depalFBO); shaderManager_->DirtyLastShader(); @@ -560,7 +561,7 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT); pD3Ddevice->SetSamplerState(1, D3DSAMP_MIPFILTER, D3DTEXF_NONE); - framebufferManager_->BindFramebufferColor(0, framebuffer, BINDFBCOLOR_SKIP_COPY); + framebufferManagerDX9_->BindFramebufferColor(0, framebuffer, BINDFBCOLOR_SKIP_COPY); pD3Ddevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); pD3Ddevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT); pD3Ddevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE); @@ -578,13 +579,13 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame } else { entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - framebufferManager_->BindFramebufferColor(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); + framebufferManagerDX9_->BindFramebufferColor(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; } - framebufferManager_->RebindFramebuffer(); + framebufferManagerDX9_->RebindFramebuffer(); SetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight); lastBoundTexture = INVALID_TEX; diff --git a/GPU/Directx9/TextureCacheDX9.h b/GPU/Directx9/TextureCacheDX9.h index 2b2d4ce91..06df6117a 100644 --- a/GPU/Directx9/TextureCacheDX9.h +++ b/GPU/Directx9/TextureCacheDX9.h @@ -44,9 +44,7 @@ public: void Clear(bool delete_them); void StartFrame(); - void SetFramebufferManager(FramebufferManagerDX9 *fbManager) { - framebufferManager_ = fbManager; - } + void SetFramebufferManager(FramebufferManagerDX9 *fbManager); void SetDepalShaderCache(DepalShaderCacheDX9 *dpCache) { depalShaderCache_ = dpCache; } @@ -64,7 +62,6 @@ public: void ApplyTexture(); protected: - void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) override; void Unbind() override; private: @@ -106,7 +103,7 @@ private: int texelsScaledThisFrame_; int timesInvalidatedAllThisFrame_; - FramebufferManagerDX9 *framebufferManager_; + FramebufferManagerDX9 *framebufferManagerDX9_; DepalShaderCacheDX9 *depalShaderCache_; ShaderManagerDX9 *shaderManager_; }; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 8ae5e71bb..62496b9e2 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -81,6 +81,11 @@ TextureCacheGLES::~TextureCacheGLES() { Clear(true); } +void TextureCacheGLES::SetFramebufferManager(FramebufferManagerGLES *fbManager) { + framebufferManagerGL_ = fbManager; + framebufferManager_ = fbManager; +} + void TextureCacheGLES::Clear(bool delete_them) { glBindTexture(GL_TEXTURE_2D, 0); lastBoundTexture = INVALID_TEX; @@ -468,10 +473,6 @@ void TextureCacheGLES::ApplyTexture() { } } -void TextureCacheGLES::DownloadFramebufferForClut(u32 clutAddr, u32 bytes) { - framebufferManager_->DownloadFramebufferForClut(clutAddr, bytes); -} - class TextureShaderApplier { public: struct Pos { @@ -612,7 +613,7 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram } if (depal) { GLuint clutTexture = depalShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBuf_); - Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, Draw::FBO_8888); + Draw::Framebuffer *depalFBO = framebufferManagerGL_->GetTempFBO(framebuffer->renderWidth, framebuffer->renderHeight, Draw::FBO_8888); draw_->BindFramebufferAsRenderTarget(depalFBO); shaderManager_->DirtyLastShader(); @@ -624,7 +625,7 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram glBindTexture(GL_TEXTURE_2D, clutTexture); glActiveTexture(GL_TEXTURE0); - framebufferManager_->BindFramebufferColor(GL_TEXTURE0, gstate.getFrameBufRawAddress(), framebuffer, BINDFBCOLOR_SKIP_COPY); + framebufferManagerGL_->BindFramebufferColor(GL_TEXTURE0, gstate.getFrameBufRawAddress(), framebuffer, BINDFBCOLOR_SKIP_COPY); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -641,13 +642,13 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram } else { entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - framebufferManager_->BindFramebufferColor(GL_TEXTURE0, gstate.getFrameBufRawAddress(), framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); + framebufferManagerGL_->BindFramebufferColor(GL_TEXTURE0, gstate.getFrameBufRawAddress(), framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; } - framebufferManager_->RebindFramebuffer(); + framebufferManagerGL_->RebindFramebuffer(); SetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight); lastBoundTexture = INVALID_TEX; diff --git a/GPU/GLES/TextureCacheGLES.h b/GPU/GLES/TextureCacheGLES.h index 5af78487f..e3c031b60 100644 --- a/GPU/GLES/TextureCacheGLES.h +++ b/GPU/GLES/TextureCacheGLES.h @@ -51,9 +51,7 @@ public: void Clear(bool delete_them); void StartFrame(); - void SetFramebufferManager(FramebufferManagerGLES *fbManager) { - framebufferManager_ = fbManager; - } + void SetFramebufferManager(FramebufferManagerGLES *fbManager); void SetDepalShaderCache(DepalShaderCacheGLES *dpCache) { depalShaderCache_ = dpCache; } @@ -79,7 +77,6 @@ public: void ApplyTexture(); protected: - void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) override; void Unbind() override; private: @@ -106,7 +103,7 @@ private: u32 lastBoundTexture; float maxAnisotropyLevel; - FramebufferManagerGLES *framebufferManager_; + FramebufferManagerGLES *framebufferManagerGL_; DepalShaderCacheGLES *depalShaderCache_; ShaderManagerGLES *shaderManager_; DrawEngineGLES *drawEngine_; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index d1dd76798..77d1145e6 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -160,6 +160,11 @@ TextureCacheVulkan::~TextureCacheVulkan() { }, allocator_); } +void TextureCacheVulkan::SetFramebufferManager(FramebufferManagerVulkan *fbManager) { + framebufferManagerVulkan_ = fbManager; + framebufferManager_ = fbManager; +} + void TextureCacheVulkan::DeviceLost() { Clear(true); @@ -186,10 +191,6 @@ void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan) { samplerCache_.DeviceRestore(vulkan); } -void TextureCacheVulkan::DownloadFramebufferForClut(u32 clutAddr, u32 bytes) { - -} - void TextureCacheVulkan::Clear(bool delete_them) { lastBoundTexture = nullptr; for (TexCache::iterator iter = cache.begin(); iter != cache.end(); ++iter) { diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 456759d5c..7a7b34c5c 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -97,9 +97,7 @@ public: void DeviceLost(); void DeviceRestore(VulkanContext *vulkan); - void SetFramebufferManager(FramebufferManagerVulkan *fbManager) { - framebufferManager_ = fbManager; - } + void SetFramebufferManager(FramebufferManagerVulkan *fbManager); void SetDepalShaderCache(DepalShaderCacheVulkan *dpCache) { depalShaderCache_ = dpCache; } @@ -118,7 +116,6 @@ public: void ApplyTexture(VulkanPushBuffer *uploadBuffer, VkImageView &imageView, VkSampler &sampler); protected: - void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) override; void Unbind() override; private: @@ -152,7 +149,7 @@ private: int texelsScaledThisFrame_; int timesInvalidatedAllThisFrame_; - FramebufferManagerVulkan *framebufferManager_; + FramebufferManagerVulkan *framebufferManagerVulkan_; DepalShaderCacheVulkan *depalShaderCache_; ShaderManagerVulkan *shaderManager_; DrawEngineVulkan *drawEngine_;