From 2d53eb54563a474f90bbe5b790e9125c6f145dde Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 21 May 2016 15:40:58 -0700 Subject: [PATCH] Ensure we don't try to hash framebuffers. Let's keep when we do things consistent: measure alpha on apply always. --- GPU/Directx9/TextureCacheDX9.cpp | 35 ++++++++++++++----------------- GPU/GLES/TextureCache.cpp | 35 ++++++++++++++----------------- GPU/Vulkan/TextureCacheVulkan.cpp | 35 ++++++++++++++----------------- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 5c0ba999fb..ebcb2f6e46 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -649,28 +649,9 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu framebuffer->usageFlags |= FB_USAGE_TEXTURE; bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; if (useBufferedRendering) { - const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat(); const u64 cachekey = entry->CacheKey(); const auto &fbInfo = fbTexInfo_[cachekey]; - LPDIRECT3DPIXELSHADER9 pshader = nullptr; - if ((entry->status & TexCacheEntry::STATUS_DEPALETTIZE) && !g_Config.bDisableSlowFramebufEffects) { - pshader = depalShaderCache_->GetDepalettizePixelShader(clutFormat, framebuffer->drawnFormat); - } - if (pshader) { - const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); - const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; - - TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1); - gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; - gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; - } else { - entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - - gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; - gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; - } - // Keep the framebuffer alive. framebuffer->last_frame_used = gpuStats.numFlips; @@ -694,6 +675,10 @@ void TextureCacheDX9::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebu pD3Ddevice->SetTexture(0, NULL); gstate_c.needShaderTexClamp = false; } + + nextNeedsRehash_ = false; + nextNeedsChange_ = false; + nextNeedsRebuild_ = false; } void TextureCacheDX9::ApplyTexture() { @@ -911,8 +896,20 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame shaderApply.Shade(); fbo_bind_color_as_texture(depalFBO, 0); + + const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); + const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; + + TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1); + gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; + gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; } else { + entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; + framebufferManager_->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(); diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index e97e399775..ff281bc2d6 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -719,28 +719,9 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffe framebuffer->usageFlags |= FB_USAGE_TEXTURE; bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; if (useBufferedRendering) { - const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat(); const u64 cachekey = entry->CacheKey(); const auto &fbInfo = fbTexInfo_[cachekey]; - DepalShader *depal = nullptr; - if ((entry->status & TexCacheEntry::STATUS_DEPALETTIZE) && !g_Config.bDisableSlowFramebufEffects) { - depal = depalShaderCache_->GetDepalettizeShader(clutFormat, framebuffer->drawnFormat); - } - if (depal) { - const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); - const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; - - TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1); - gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; - gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; - } else { - entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - - gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; - gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; - } - // Keep the framebuffer alive. framebuffer->last_frame_used = gpuStats.numFlips; @@ -763,6 +744,10 @@ void TextureCache::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffe glBindTexture(GL_TEXTURE_2D, 0); gstate_c.needShaderTexClamp = false; } + + nextNeedsRehash_ = false; + nextNeedsChange_ = false; + nextNeedsRebuild_ = false; } void TextureCache::ApplyTexture() { @@ -985,8 +970,20 @@ void TextureCache::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuf shaderApply.Shade(); fbo_bind_color_as_texture(depalFBO, 0); + + const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); + const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; + + TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormat(clutFormat), clutTotalColors, clutTotalColors, 1); + gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; + gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; } else { + entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; + framebufferManager_->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(); diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index d3bb0bc159..7ad675778c 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -659,28 +659,9 @@ void TextureCacheVulkan::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFram framebuffer->usageFlags |= FB_USAGE_TEXTURE; bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; if (useBufferedRendering) { - const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat(); const u64 cachekey = entry->CacheKey(); const auto &fbInfo = fbTexInfo_[cachekey]; - DepalShaderVulkan *depal = nullptr; - if ((entry->status & TexCacheEntry::STATUS_DEPALETTIZE) && !g_Config.bDisableSlowFramebufEffects) { - // depal = depalShaderCache_->GetDepalettizeShader(clutFormat, framebuffer->drawnFormat); - } - if (depal) { - const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); - const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; - - TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormatVulkan(clutFormat), clutTotalColors, clutTotalColors, 1); - gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; - gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; - } else { - entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; - - gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; - gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; - } - // Keep the framebuffer alive. framebuffer->last_frame_used = gpuStats.numFlips; @@ -702,6 +683,10 @@ void TextureCacheVulkan::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFram } gstate_c.needShaderTexClamp = false; } + + nextNeedsRehash_ = false; + nextNeedsChange_ = false; + nextNeedsRebuild_ = false; } void TextureCacheVulkan::ApplyTexture(VulkanPushBuffer *uploadBuffer, VkImageView &imageView, VkSampler &sampler) { @@ -847,6 +832,18 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VkCommandBuffer cmd, TexCacheEn //depalFBO->EndPass(cmd); //depalFBO->TransitionToTexture(cmd); //imageView = depalFBO->GetColorImageView(); + + const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); + const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; + + TexCacheEntry::Status alphaStatus = CheckAlpha(clutBuf_, getClutDestFormatVulkan(clutFormat), clutTotalColors, clutTotalColors, 1); + gstate_c.textureFullAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_FULL; + gstate_c.textureSimpleAlpha = alphaStatus == TexCacheEntry::STATUS_ALPHA_SIMPLE; + } else { + entry->status &= ~TexCacheEntry::STATUS_DEPALETTIZE; + + gstate_c.textureFullAlpha = gstate.getTextureFormat() == GE_TFMT_5650; + gstate_c.textureSimpleAlpha = gstate_c.textureFullAlpha; } /*