From 3f48e446b6f2113ff9e5eeffdb3596353710ae1c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 25 Aug 2018 09:57:37 -0700 Subject: [PATCH] GPU: Fix texture handling on framebuf detach. We were never creating/recreating the texture, so we ended up with null. Caused all sorts of problems. --- GPU/Common/TextureCacheCommon.cpp | 3 +++ ext/native/thin3d/GLRenderManager.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index b4a0a6f4aa..cadf9abf0d 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -713,6 +713,9 @@ void TextureCacheCommon::DetachFramebuffer(TexCacheEntry *entry, u32 address, Vi const u64 cachekey = entry->CacheKey(); cacheSizeEstimate_ += EstimateTexMemoryUsage(entry); entry->framebuffer = nullptr; + // Force the hash to change in case we had one before. + // Otherwise we never recreate the texture. + entry->hash ^= 1; fbTexInfo_.erase(cachekey); host->GPUNotifyTextureAttachment(entry->addr); } diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index 8751b9b7d3..c2cdb086cd 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -345,6 +345,7 @@ bool GLRenderManager::CopyFramebufferToMemorySync(GLRFramebuffer *src, int aspec } void GLRenderManager::CopyImageToMemorySync(GLRTexture *texture, int mipLevel, int x, int y, int w, int h, Draw::DataFormat destFormat, uint8_t *pixels, int pixelStride) { + _assert_(texture); GLRStep *step = new GLRStep{ GLRStepType::READBACK_IMAGE }; step->readback_image.texture = texture; step->readback_image.mipLevel = mipLevel;