From ef390c5c40af42bffdda3264ec3e10c1e827a229 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 19 Jun 2014 22:52:45 -0700 Subject: [PATCH 1/2] Double check upload/download are VRAM addresses. --- GPU/GLES/Framebuffer.cpp | 2 +- GPU/GLES/GLES_GPU.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 6fc83e0e90c1..e342ac084dab 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -982,7 +982,7 @@ void FramebufferManager::DoSetRenderFrameBuffer() { u32 byteSize = FramebufferByteSize(vfb); u32 fb_address_mem = (fb_address & 0x3FFFFFFF) | 0x04000000; - if (fb_address_mem + byteSize > framebufRangeEnd_) { + if (Memory::IsVRAMAddress(fb_address_mem) && fb_address_mem + byteSize > framebufRangeEnd_) { framebufRangeEnd_ = fb_address_mem + byteSize; } diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 78b03da430c8..d38a423a1ec2 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -2061,13 +2061,19 @@ bool GLES_GPU::PerformMemorySet(u32 dest, u8 v, int size) { bool GLES_GPU::PerformMemoryDownload(u32 dest, int size) { // Cheat a bit to force a download of the framebuffer. // VRAM + 0x00400000 is simply a VRAM mirror. - return gpu->PerformMemoryCopy(dest ^ 0x00400000, dest, size); + if (Memory::IsVRAMAddress(dest)) { + return gpu->PerformMemoryCopy(dest ^ 0x00400000, dest, size); + } + return false; } bool GLES_GPU::PerformMemoryUpload(u32 dest, int size) { // Cheat a bit to force an upload of the framebuffer. // VRAM + 0x00400000 is simply a VRAM mirror. - return gpu->PerformMemoryCopy(dest, dest ^ 0x00400000, size); + if (Memory::IsVRAMAddress(dest)) { + return gpu->PerformMemoryCopy(dest, dest ^ 0x00400000, size); + } + return false; } bool GLES_GPU::PerformStencilUpload(u32 dest, int size) { From 0c31e551e72e354eb4c110674207833ac66ef639 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 19 Jun 2014 23:02:26 -0700 Subject: [PATCH 2/2] Clear buffers before using them. Fixes a reported crash on an AMD card. --- GPU/GLES/Framebuffer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index e342ac084dab..fab295507253 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -986,13 +986,12 @@ void FramebufferManager::DoSetRenderFrameBuffer() { framebufRangeEnd_ = fb_address_mem + byteSize; } + // Some AMD drivers crash if we don't clear the buffer first? + ClearBuffer(); if (useBufferedRendering_ && !updateVRAM_) { gpu->PerformMemoryUpload(fb_address_mem, byteSize); gpu->PerformStencilUpload(fb_address_mem, byteSize); // TODO: Is it worth trying to upload the depth buffer? - ClearDepthBuffer(); - } else { - ClearBuffer(); } // Let's check for depth buffer overlap. Might be interesting.