From 867eb995055b532c05185c701c60be3980f883ae Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Sep 2022 07:25:03 -0700 Subject: [PATCH] PPGe: Cleanup memory writes for clarity. Switch from WriteStruct to PSPPointer as well. --- Core/Util/PPGeDraw.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 425552a453..2b83bb4ccd 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -178,18 +178,16 @@ static void BeginVertexData() { static void Vertex(float x, float y, float u, float v, int tw, int th, u32 color = 0xFFFFFFFF) { if (g_RemasterMode) { - PPGeRemasterVertex vtx; - vtx.x = x; vtx.y = y; vtx.z = 0; - vtx.u = u * tw; vtx.v = v * th; - vtx.color = color; - Memory::WriteStruct(dataWritePtr, &vtx); + auto vtx = PSPPointer::Create(dataWritePtr); + vtx->x = x; vtx->y = y; vtx->z = 0; + vtx->u = u * tw; vtx->v = v * th; + vtx->color = color; dataWritePtr += sizeof(vtx); } else { - PPGeVertex vtx; - vtx.x = x; vtx.y = y; vtx.z = 0; - vtx.u = u * tw; vtx.v = v * th; - vtx.color = color; - Memory::WriteStruct(dataWritePtr, &vtx); + auto vtx = PSPPointer::Create(dataWritePtr); + vtx->x = x; vtx->y = y; vtx->z = 0; + vtx->u = u * tw; vtx->v = v * th; + vtx->color = color; dataWritePtr += sizeof(vtx); } _dbg_assert_(dataWritePtr <= dataPtr + dataSize); @@ -197,8 +195,11 @@ static void Vertex(float x, float y, float u, float v, int tw, int th, u32 color } static void EndVertexDataAndDraw(int prim) { + _assert_msg_(vertexStart != 0, "Missing matching call to BeginVertexData()"); + NotifyMemInfo(MemBlockFlags::WRITE, vertexStart, dataWritePtr - vertexStart, "PPGe Vertex"); WriteCmdAddrWithBase(GE_CMD_VADDR, vertexStart); WriteCmd(GE_CMD_PRIM, (prim << 16) | vertexCount); + vertexStart = 0; } bool PPGeIsFontTextureAddress(u32 addr) { @@ -272,6 +273,7 @@ void __PPGeInit() { int val = i; palette[i] = (val << 12) | 0xFFF; } + NotifyMemInfo(MemBlockFlags::WRITE, palette.ptr, 16 * sizeof(u16_le), "PPGe Palette"); const u32_le *imagePtr = (u32_le *)imageData[0]; u8 *ramPtr = atlasPtr == 0 ? nullptr : (u8 *)Memory::GetPointer(atlasPtr); @@ -286,7 +288,10 @@ void __PPGeInit() { u8 cval = (a2 << 4) | a1; ramPtr[i] = cval; } - atlasHash = XXH3_64bits(ramPtr, atlasWidth * atlasHeight / 2); + if (atlasPtr != 0) { + atlasHash = XXH3_64bits(ramPtr, atlasSize); + NotifyMemInfo(MemBlockFlags::WRITE, atlasPtr, atlasSize, "PPGe Atlas"); + } free(imageData[0]); @@ -457,6 +462,7 @@ void PPGeEnd() if (dataWritePtr > dataPtr) { // We actually drew something gpu->EnableInterrupts(false); + NotifyMemInfo(MemBlockFlags::WRITE, dlPtr, dlWritePtr - dlPtr, "PPGe ListCmds"); u32 list = sceGeListEnQueue(dlPtr, dlWritePtr, -1, listArgs.ptr); DEBUG_LOG(SCEGE, "PPGe enqueued display list %i", list); gpu->EnableInterrupts(true);