From 05c225655dd10802b9b62ec8416667d5fe6540af Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 25 Mar 2023 23:19:21 -0700 Subject: [PATCH 1/2] GPU: Add xfer flag to ignore create vfb flags. Save icons need CPU reads to work. --- Core/HLE/ReplaceTables.cpp | 4 ++-- GPU/Common/FramebufferManagerCommon.cpp | 2 +- GPU/GPUInterface.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index ea49f5855a..7ea1577113 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -769,7 +769,7 @@ static int Hook_starocean_write_stencil() { static int Hook_topx_create_saveicon() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformReadbackToMemory(fb_address, 0x00044000); + gpu->PerformMemoryCopy(fb_address, fb_address, 0x00044000, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "topx_create_saveicon"); } return 0; @@ -820,7 +820,7 @@ static int Hook_growlanser_create_saveicon() { const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP]); const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { - gpu->PerformReadbackToMemory(fb_address, sz); + gpu->PerformMemoryCopy(fb_address, fb_address, sz, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "growlanser_create_saveicon"); } return 0; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 8c61276862..3695fe55ee 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1892,7 +1892,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, if (!dstBuffer && srcBuffer && channel != RASTER_DEPTH) { // Note - if we're here, we're in a memcpy, not a block transfer. Not allowing IntraVRAMBlockTransferAllowCreateFB. // Technically, that makes BlockTransferAllowCreateFB a bit of a misnomer. - if (PSP_CoreParameter().compat.flags().BlockTransferAllowCreateFB) { + if (PSP_CoreParameter().compat.flags().BlockTransferAllowCreateFB && !(flags & GPUCopyFlag::DISALLOW_CREATE_VFB)) { dstBuffer = CreateRAMFramebuffer(dst, srcBuffer->width, srcBuffer->height, srcBuffer->fb_stride, srcBuffer->fb_format); dstY = 0; } diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 6788e595d7..79c205341a 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -122,6 +122,7 @@ enum class GPUCopyFlag { MEMSET = 4, DEPTH_REQUESTED = 8, DEBUG_NOTIFIED = 16, + DISALLOW_CREATE_VFB = 32, }; ENUM_CLASS_BITOPS(GPUCopyFlag); From 2d13b401230035b1f1b80991febb3485aacf4efc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 25 Mar 2023 23:25:42 -0700 Subject: [PATCH 2/2] GPU: Rename match flags to avoid confusion. --- Core/HLE/ReplaceTables.cpp | 6 +++--- GPU/Common/FramebufferManagerCommon.cpp | 4 ++-- GPU/GPUCommon.cpp | 4 ++-- GPU/GPUInterface.h | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 7ea1577113..30afa6e26b 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -734,7 +734,7 @@ static int Hook_godseaterburst_depthmask_5551() { // This is added to read from the linearized mirror. uint32_t depthMirror = depthBuffer + 0x00200000; // Depth download required, or it won't work and will be transparent. - gpu->PerformMemoryCopy(depthMirror, depthMirror, size, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DEPTH_REQUESTED); + gpu->PerformMemoryCopy(depthMirror, depthMirror, size, GPUCopyFlag::FORCE_DST_MATCH_MEM | GPUCopyFlag::DEPTH_REQUESTED); NotifyMemInfo(MemBlockFlags::WRITE, depthMirror, size, "godseaterburst_depthmask_5551"); } @@ -769,7 +769,7 @@ static int Hook_starocean_write_stencil() { static int Hook_topx_create_saveicon() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryCopy(fb_address, fb_address, 0x00044000, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); + gpu->PerformMemoryCopy(fb_address, fb_address, 0x00044000, GPUCopyFlag::FORCE_DST_MATCH_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "topx_create_saveicon"); } return 0; @@ -820,7 +820,7 @@ static int Hook_growlanser_create_saveicon() { const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP]); const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { - gpu->PerformMemoryCopy(fb_address, fb_address, sz, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); + gpu->PerformMemoryCopy(fb_address, fb_address, sz, GPUCopyFlag::FORCE_DST_MATCH_MEM | GPUCopyFlag::DISALLOW_CREATE_VFB); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "growlanser_create_saveicon"); } return 0; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 3695fe55ee..67c92cee27 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1799,8 +1799,8 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, VirtualFramebuffer *dstBuffer = nullptr; VirtualFramebuffer *srcBuffer = nullptr; - bool ignoreDstBuffer = flags & GPUCopyFlag::FORCE_DST_MEM; - bool ignoreSrcBuffer = flags & (GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::MEMSET); + bool ignoreDstBuffer = flags & GPUCopyFlag::FORCE_DST_MATCH_MEM; + bool ignoreSrcBuffer = flags & (GPUCopyFlag::FORCE_SRC_MATCH_MEM | GPUCopyFlag::MEMSET); RasterChannel channel = flags & GPUCopyFlag::DEPTH_REQUESTED ? RASTER_DEPTH : RASTER_COLOR; u32 dstY = (u32)-1; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index bc4a26844e..5091c4350d 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1977,7 +1977,7 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { bool GPUCommon::PerformReadbackToMemory(u32 dest, int size) { if (Memory::IsVRAMAddress(dest)) { - return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_DST_MEM); + return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_DST_MATCH_MEM); } return false; } @@ -1985,7 +1985,7 @@ bool GPUCommon::PerformReadbackToMemory(u32 dest, int size) { bool GPUCommon::PerformWriteColorFromMemory(u32 dest, int size) { if (Memory::IsVRAMAddress(dest)) { GPURecord::NotifyUpload(dest, size); - return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::DEBUG_NOTIFIED); + return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_SRC_MATCH_MEM | GPUCopyFlag::DEBUG_NOTIFIED); } return false; } diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 79c205341a..d48713942d 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -116,9 +116,9 @@ ENUM_CLASS_BITOPS(WriteStencil); enum class GPUCopyFlag { NONE = 0, - FORCE_SRC_MEM = 1, - FORCE_DST_MEM = 2, - // Note: implies src == dst and FORCE_SRC_MEM. + FORCE_SRC_MATCH_MEM = 1, + FORCE_DST_MATCH_MEM = 2, + // Note: implies src == dst and FORCE_SRC_MATCH_MEM. MEMSET = 4, DEPTH_REQUESTED = 8, DEBUG_NOTIFIED = 16,