From 89206a8a099427e39b722e858c282042c185f69b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 12 Jun 2014 00:41:42 -0700 Subject: [PATCH 1/4] Allow render-to-tex with > 16 y offset. Trying to keep it cautious in case our sizes are wrong. --- GPU/GLES/TextureCache.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 981db87c99..6ef38e3640 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -313,10 +313,15 @@ void TextureCache::NotifyFramebuffer(u32 address, VirtualFramebuffer *framebuffe // Must be in VRAM so | 0x04000000 it is. const u32 addr = (address | 0x04000000) & 0x0FFFFFFF; + const u32 bpp = framebuffer->format == GE_FORMAT_8888 ? 4 : 2; const u64 cacheKey = (u64)addr << 32; // If it has a clut, those are the low 32 bits, so it'll be inside this range. // Also, if it's a subsample of the buffer, it'll also be within the FBO. - const u64 cacheKeyEnd = cacheKey + ((u64)(framebuffer->fb_stride * MAX_SUBAREA_Y_OFFSET) << 32); + u64 cacheKeyEnd = cacheKey + ((u64)(framebuffer->fb_stride * MAX_SUBAREA_Y_OFFSET * bpp) << 32); + if (addr >= 0x04000000 && addr < 0x04110000) { + // This range usually is dominated by framebuffers. Assume the entire height is up for grabs. + cacheKeyEnd = cacheKey + ((u64)(framebuffer->fb_stride * framebuffer->height * bpp) << 32); + } switch (msg) { case NOTIFY_FB_CREATED: From c29062de9fe0b63a4eaed0bf25886a471018a8d0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 12 Jun 2014 00:42:25 -0700 Subject: [PATCH 2/4] Add memory breakpoints on sceIo read/write. --- Core/HLE/sceIo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 665e37edd6..9daae77299 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -22,6 +22,7 @@ #include "native/thread/threadutil.h" #include "Core/Core.h" #include "Core/Config.h" +#include "Core/Debugger/Breakpoints.h" #include "Core/MemMap.h" #include "Core/System.h" #include "Core/Host.h" @@ -725,6 +726,7 @@ bool __IoRead(int &result, int id, u32 data_addr, int size) { result = ERROR_KERNEL_BAD_FILE_DESCRIPTOR; return true; } else if (Memory::IsValidAddress(data_addr)) { + CBreakPoints::ExecMemCheck(data_addr, true, size, currentMIPS->pc); u8 *data = (u8*) Memory::GetPointer(data_addr); if (f->npdrm) { result = npdrmRead(f, data, size); @@ -855,6 +857,8 @@ bool __IoWrite(int &result, int id, u32 data_addr, int size) { return true; } + CBreakPoints::ExecMemCheck(data_addr, false, size, currentMIPS->pc); + bool useThread = __KernelIsDispatchEnabled() && ioManagerThreadEnabled && size > IO_THREAD_MIN_DATA_SIZE; if (useThread) { // If there's a pending operation on this file, wait for it to finish and don't overwrite it. From 1a25456e5270a3357522c5bc6727ae2504960bed Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 12 Jun 2014 00:48:21 -0700 Subject: [PATCH 3/4] Detach a format mismatch that's not rendering. Assume we'd be better off reading ram. --- GPU/GLES/TextureCache.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 6ef38e3640..1360d90e8c 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -53,6 +53,9 @@ // Changes more frequent than this will be considered "frequent" and prevent texture scaling. #define TEXCACHE_FRAME_CHANGE_FREQUENT 15 +// Assume a framebuffer format is garbage after this many flips. +#define TEXCACHE_RENDERTEX_OLD_AGE 6 + #define TEXCACHE_NAME_CACHE_SIZE 16 #ifndef GL_UNPACK_ROW_LENGTH @@ -244,9 +247,14 @@ void TextureCache::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualF DEBUG_LOG(G3D, "Render to texture detected at %08x!", address); if (!entry->framebuffer || entry->invalidHint == -1) { if (entry->format != framebuffer->format) { - WARN_LOG_REPORT_ONCE(diffFormat1, G3D, "Render to texture with different formats %d != %d", entry->format, framebuffer->format); - // If it already has one, let's hope that one is correct. - AttachFramebufferInvalid(entry, framebuffer, fbInfo); + if (framebuffer->last_frame_render + TEXCACHE_RENDERTEX_OLD_AGE < gpuStats.numFlips) { + WARN_LOG_REPORT_ONCE(diffFormat3, G3D, "Render to texture with different formats %d != %d, no recent render", entry->format, framebuffer->format); + DetachFramebuffer(entry, address, framebuffer); + } else { + WARN_LOG_REPORT_ONCE(diffFormat1, G3D, "Render to texture with different formats %d != %d", entry->format, framebuffer->format); + // If it already has one, let's hope that one is correct. + AttachFramebufferInvalid(entry, framebuffer, fbInfo); + } } else { AttachFramebufferValid(entry, framebuffer, fbInfo); } From 025b92593a5c3dfbcbad954e1836e03146439e66 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 12 Jun 2014 07:46:56 -0700 Subject: [PATCH 4/4] Just don't use render-to-text format mismatches. This already excludes CLUTs. --- GPU/GLES/TextureCache.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index 1360d90e8c..75c6ec397a 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -53,9 +53,6 @@ // Changes more frequent than this will be considered "frequent" and prevent texture scaling. #define TEXCACHE_FRAME_CHANGE_FREQUENT 15 -// Assume a framebuffer format is garbage after this many flips. -#define TEXCACHE_RENDERTEX_OLD_AGE 6 - #define TEXCACHE_NAME_CACHE_SIZE 16 #ifndef GL_UNPACK_ROW_LENGTH @@ -247,14 +244,9 @@ void TextureCache::AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualF DEBUG_LOG(G3D, "Render to texture detected at %08x!", address); if (!entry->framebuffer || entry->invalidHint == -1) { if (entry->format != framebuffer->format) { - if (framebuffer->last_frame_render + TEXCACHE_RENDERTEX_OLD_AGE < gpuStats.numFlips) { - WARN_LOG_REPORT_ONCE(diffFormat3, G3D, "Render to texture with different formats %d != %d, no recent render", entry->format, framebuffer->format); - DetachFramebuffer(entry, address, framebuffer); - } else { - WARN_LOG_REPORT_ONCE(diffFormat1, G3D, "Render to texture with different formats %d != %d", entry->format, framebuffer->format); - // If it already has one, let's hope that one is correct. - AttachFramebufferInvalid(entry, framebuffer, fbInfo); - } + WARN_LOG_REPORT_ONCE(diffFormat1, G3D, "Render to texture with different formats %d != %d", entry->format, framebuffer->format); + // Let's avoid rendering when we know the format is wrong. May be a video/etc. updating memory. + DetachFramebuffer(entry, address, framebuffer); } else { AttachFramebufferValid(entry, framebuffer, fbInfo); }