From d46812a49fca696e3a8c98667b6ffa44cc2811fb Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 10 Apr 2013 00:06:29 +0200 Subject: [PATCH] Implement pullrq #1240 better, I think. --- GPU/GLES/Framebuffer.cpp | 17 ++++++++++++++--- GPU/GLES/TextureCache.cpp | 6 ++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 097c20c21f..0b3ab3d2eb 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -330,6 +330,7 @@ void FramebufferManager::SetRenderFrameBuffer() { if (!vfb) { gstate_c.textureChanged = true; vfb = new VirtualFramebuffer(); + vfb->fbo = 0; vfb->fb_address = fb_address; vfb->fb_stride = fb_stride; vfb->z_address = z_address; @@ -372,7 +373,6 @@ void FramebufferManager::SetRenderFrameBuffer() { vfb->fbo = fbo_create(vfb->renderWidth, vfb->renderHeight, 1, true, vfb->colorDepth); fbo_bind_as_render_target(vfb->fbo); } else { - vfb->fbo = 0; fbo_unbind(); // Let's ignore rendering to targets that have not (yet) been displayed. gstate_c.skipDrawReason |= SKIPDRAW_NON_DISPLAYED_FB; @@ -401,9 +401,20 @@ void FramebufferManager::SetRenderFrameBuffer() { vfb->last_frame_used = gpuStats.numFrames; vfb->dirtyAfterDisplay = true; - if (g_Config.bBufferedRendering && vfb->fbo) { - fbo_bind_as_render_target(vfb->fbo); + if (g_Config.bBufferedRendering) { + if (vfb->fbo) { + fbo_bind_as_render_target(vfb->fbo); + } else { + // wtf? This should only happen very briefly when toggling bBufferedRendering + fbo_unbind(); + } } else { + if (vfb->fbo) { + // wtf? This should only happen very briefly when toggling bBufferedRendering + textureCache_->NotifyFramebufferDestroyed(vfb->fb_address, vfb); + fbo_destroy(vfb->fbo); + vfb->fbo = 0; + } fbo_unbind(); // Let's ignore rendering to targets that have not (yet) been displayed. diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 67bf380cd8..593e9c0f13 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -1060,6 +1060,7 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level) break; case GE_TFMT_DXT3: + ERROR_LOG(G3D, "Warning: DXT3 textures not well supported"); dstFmt = GL_UNSIGNED_BYTE; { u32 *dst = tmpTexBuf32.data(); @@ -1078,14 +1079,11 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level) } break; - case GE_TFMT_DXT5: - ERROR_LOG(G3D, "Unhandled compressed texture, format %i! swizzle=%i", entry.format, gstate.texmode & 1); + case GE_TFMT_DXT5: // These work fine now dstFmt = GL_UNSIGNED_BYTE; { u32 *dst = tmpTexBuf32.data(); DXT5Block *src = (DXT5Block*)texptr; - - // Alpha is almost right for (int y = 0; y < h; y += 4) { u32 blockIndex = (y / 4) * (bufw / 4); for (int x = 0; x < std::min(bufw, w); x += 4) {