diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index a78087f03b..755ebb6a74 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -219,7 +219,6 @@ void TextureCacheCommon::SetTexture(bool force) { if (!Memory::IsValidAddress(texaddr)) { // Bind a null texture and return. Unbind(); - InvalidateLastTexture(); return; } @@ -482,7 +481,7 @@ bool TextureCacheCommon::HandleTextureChange(TexCacheEntry *const entry, const c // Instead, let's use glTexSubImage to replace the images. replaceImages = true; } else { - InvalidateLastTexture(entry); + InvalidateLastTexture(); ReleaseTexture(entry, true); entry->status &= ~TexCacheEntry::STATUS_IS_SCALED; } diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index b508639506..ac3643e99e 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -143,7 +143,7 @@ void TextureCacheD3D11::ReleaseTexture(TexCacheEntry *entry, bool delete_them) { } void TextureCacheD3D11::ForgetLastTexture() { - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); ID3D11ShaderResourceView *nullTex = nullptr; context_->PSSetShaderResources(0, 1, &nullTex); @@ -201,7 +201,7 @@ void TextureCacheD3D11::SetFramebufferSamplingParams(u16 bufferWidth, u16 buffer } void TextureCacheD3D11::StartFrame() { - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); timesInvalidatedAllThisFrame_ = 0; if (texelsScaledThisFrame_) { @@ -264,6 +264,7 @@ void TextureCacheD3D11::BindTexture(TexCacheEntry *entry) { void TextureCacheD3D11::Unbind() { ID3D11ShaderResourceView *nullView = nullptr; context_->PSSetShaderResources(0, 1, &nullView); + InvalidateLastTexture(); } class TextureShaderApplierD3D11 { @@ -438,7 +439,7 @@ void TextureCacheD3D11::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFra SetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight, samplerKey); ID3D11SamplerState *state = samplerCache_.GetOrCreateSampler(device_, samplerKey); context_->PSSetSamplers(0, 1, &state); - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); } diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 1188ac58bf..c7b229c1b8 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -96,7 +96,7 @@ void TextureCacheDX9::ReleaseTexture(TexCacheEntry *entry, bool delete_them) { } void TextureCacheDX9::ForgetLastTexture() { - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); } @@ -213,7 +213,7 @@ void TextureCacheDX9::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHe } void TextureCacheDX9::StartFrame() { - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); timesInvalidatedAllThisFrame_ = 0; if (texelsScaledThisFrame_) { @@ -279,6 +279,7 @@ void TextureCacheDX9::BindTexture(TexCacheEntry *entry) { void TextureCacheDX9::Unbind() { device_->SetTexture(0, NULL); + InvalidateLastTexture(); } class TextureShaderApplierDX9 { @@ -458,7 +459,7 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame framebufferManagerDX9_->RebindFramebuffer(); SetFramebufferSamplingParams(framebuffer->bufferWidth, framebuffer->bufferHeight); - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); } void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry, bool replaceImages) { diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index a43fe020f1..0af31d5925 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -340,6 +340,7 @@ void TextureCacheGLES::BindTexture(TexCacheEntry *entry) { void TextureCacheGLES::Unbind() { glBindTexture(GL_TEXTURE_2D, 0); + InvalidateLastTexture(); } class TextureShaderApplier { @@ -522,7 +523,7 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram CHECK_GL_ERROR_IF_DEBUG(); - lastBoundTexture = INVALID_TEX; + InvalidateLastTexture(); } ReplacedTextureFormat FromGLESFormat(GLenum fmt, bool useBGRA = false) { diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 3d424c6ced..1a265b6866 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -271,7 +271,7 @@ void TextureCacheVulkan::SetFramebufferSamplingParams(u16 bufferWidth, u16 buffe } void TextureCacheVulkan::StartFrame() { - lastBoundTexture = nullptr; + InvalidateLastTexture(); timesInvalidatedAllThisFrame_ = 0; texelsScaledThisFrame_ = 0; @@ -342,6 +342,7 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) { void TextureCacheVulkan::Unbind() { imageView_ = VK_NULL_HANDLE; sampler_ = VK_NULL_HANDLE; + InvalidateLastTexture(); } void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) { @@ -452,7 +453,7 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFr key.mipEnable = false; sampler_ = samplerCache_.GetOrCreateSampler(key); - lastBoundTexture = nullptr; + InvalidateLastTexture(); } }