From 698bd75209b9f12d9e3d4f1df09471bd5591eade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 4 May 2018 22:20:41 +0200 Subject: [PATCH] Fix regression caused by the new depal code for Vulkan. Fixes #10993 --- GPU/GLES/TextureCacheGLES.cpp | 4 ++-- GPU/GPUState.h | 6 ++++++ GPU/Vulkan/DrawEngineVulkan.h | 5 ++++- GPU/Vulkan/TextureCacheVulkan.cpp | 12 ++++++++---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 096b634c8d..40ef4f0338 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -328,7 +328,7 @@ void TextureCacheGLES::BindTexture(TexCacheEntry *entry) { lastBoundTexture = entry->textureName; } UpdateSamplingParams(*entry, false); - gstate_c.useShaderDepal = false; + gstate_c.SetUseShaderDepal(false); } void TextureCacheGLES::Unbind() { @@ -461,7 +461,7 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram // Since we started/ended render passes, might need these. gstate_c.Dirty(DIRTY_DEPAL); - gstate_c.useShaderDepal = true; + gstate_c.SetUseShaderDepal(true); gstate_c.depalFramebufferFormat = framebuffer->drawnFormat; const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index e6724098c3..06b14867c4 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -517,6 +517,12 @@ struct GPUStateCache { bool IsDirty(u64 what) const { return (dirty & what) != 0ULL; } + void SetUseShaderDepal(bool depal) { + if (depal != useShaderDepal) { + useShaderDepal = depal; + Dirty(DIRTY_FRAGMENTSHADER_STATE); + } + } void SetTextureFullAlpha(bool fullAlpha) { if (fullAlpha != textureFullAlpha) { textureFullAlpha = fullAlpha; diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 0aec77065e..529b3b8071 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -180,7 +180,10 @@ public: void SetLineWidth(float lineWidth); void SetDepalTexture(VkImageView depal) { - boundDepal_ = depal; + if (boundDepal_ != depal) { + boundDepal_ = depal; + gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE); + } } private: diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 4d1a8bfe66..6dbb6a7255 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -328,7 +328,7 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) { UpdateSamplingParams(*entry, key); curSampler_ = samplerCache_.GetOrCreateSampler(key); drawEngine_->SetDepalTexture(VK_NULL_HANDLE); - gstate_c.useShaderDepal = false; + gstate_c.SetUseShaderDepal(false); } void TextureCacheVulkan::Unbind() { @@ -344,7 +344,7 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr DepalShaderVulkan *depalShader = nullptr; uint32_t clutMode = gstate.clutformat & 0xFFFFFF; - bool useShaderDepal = true; + bool useShaderDepal = framebufferManager_->GetCurrentRenderVFB() != framebuffer; if ((entry->status & TexCacheEntry::STATUS_DEPALETTIZE) && !g_Config.bDisableSlowFramebufEffects) { if (useShaderDepal) { @@ -356,9 +356,9 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr samplerKey.magFilt = false; samplerKey.minFilt = false; samplerKey.mipFilt = false; - // Make sure to update the uniforms. + // Make sure to update the uniforms, and also texture - needs a recheck. gstate_c.Dirty(DIRTY_DEPAL); - gstate_c.useShaderDepal = true; + gstate_c.SetUseShaderDepal(true); gstate_c.depalFramebufferFormat = framebuffer->drawnFormat; const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor; @@ -370,6 +370,8 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr return; } else { depalShader = depalShaderCache_->GetDepalettizeShader(clutMode, framebuffer->drawnFormat); + drawEngine_->SetDepalTexture(nullptr); + gstate_c.SetUseShaderDepal(false); } } if (depalShader) { @@ -466,6 +468,8 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr framebufferManager_->RebindFramebuffer(); // TODO: This line should usually not be needed. imageView_ = framebufferManagerVulkan_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); + drawEngine_->SetDepalTexture(nullptr); + gstate_c.SetUseShaderDepal(false); gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650); }