Skip to content

Commit

Permalink
Merge pull request #16093 from unknownbrackets/ge-frame-dump
Browse files Browse the repository at this point in the history
GE Debugger: Fix small tex/clut recopying
  • Loading branch information
hrydgard authored Sep 24, 2022
2 parents b56bd0d + 7ff5434 commit 0ce4e1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions GPU/Debugger/Playback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Core/Config.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/MemBlockInfo.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/HLE/sceDisplay.h"
Expand Down Expand Up @@ -489,13 +490,12 @@ void DumpExecute::Clut(u32 ptr, u32 sz) {
// This is always run when we have the actual address set.
if (execClutAddr != 0) {
const bool isTarget = (execClutFlags & 1) != 0;
const bool unchangedVRAM = (execClutFlags & 2) != 0;

// TODO: Could use drawnVRAM flag, but it can be wrong.
// Could potentially always skip if !isTarget, but playing it safe for offset texture behavior.
if (Memory::IsValidRange(execClutAddr, sz) && !unchangedVRAM && (!isTarget || !g_Config.bSoftwareRendering)) {
if (Memory::IsValidRange(execClutAddr, sz) && (!isTarget || !g_Config.bSoftwareRendering)) {
// Intentionally don't trigger an upload here.
Memory::MemcpyUnchecked(execClutAddr, pushbuf_.data() + ptr, sz);
NotifyMemInfo(MemBlockFlags::WRITE, execClutAddr, sz, "ReplayClut");
}

execClutAddr = 0;
Expand Down Expand Up @@ -550,6 +550,7 @@ void DumpExecute::Memcpy(u32 ptr, u32 sz) {
if (Memory::IsVRAMAddress(execMemcpyDest)) {
SyncStall();
Memory::MemcpyUnchecked(execMemcpyDest, pushbuf_.data() + ptr, sz);
NotifyMemInfo(MemBlockFlags::WRITE, execMemcpyDest, sz, "ReplayMemcpy");
gpu->PerformMemoryUpload(execMemcpyDest, sz);
}
}
Expand Down Expand Up @@ -600,6 +601,7 @@ void DumpExecute::Framebuf(int level, u32 ptr, u32 sz) {
if (Memory::IsValidRange(framebuf->addr, pspSize) && !unchangedVRAM && (!isTarget || !g_Config.bSoftwareRendering)) {
// Intentionally don't trigger an upload here.
Memory::MemcpyUnchecked(framebuf->addr, pushbuf_.data() + ptr + headerSize, pspSize);
NotifyMemInfo(MemBlockFlags::WRITE, framebuf->addr, pspSize, "ReplayTex");
}
}

Expand Down
11 changes: 8 additions & 3 deletions GPU/Debugger/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,19 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) {
bool isDirtyVRAM = false;
bool isDrawnVRAM = false;
uint32_t start = (addr >> DIRTY_VRAM_SHIFT) & DIRTY_VRAM_MASK;
for (uint32_t i = 0; i < (sizeInRAM + DIRTY_VRAM_ROUND) >> DIRTY_VRAM_SHIFT; ++i) {
uint32_t blocks = (sizeInRAM + DIRTY_VRAM_ROUND) >> DIRTY_VRAM_SHIFT;
bool startEven = (addr & DIRTY_VRAM_ROUND) == 0;
bool endEven = ((addr + sizeInRAM) & DIRTY_VRAM_ROUND) == 0;
for (uint32_t i = 0; i < blocks; ++i) {
DirtyVRAMFlag flag = dirtyVRAM[start + i];
isDirtyVRAM = isDirtyVRAM || flag != DirtyVRAMFlag::CLEAN;
isDrawnVRAM = isDrawnVRAM || flag == DirtyVRAMFlag::DRAWN;

// Mark the VRAM clean now that it's been copied to VRAM.
if (flag == DirtyVRAMFlag::DIRTY)
dirtyVRAM[start + i] = DirtyVRAMFlag::CLEAN;
if (flag == DirtyVRAMFlag::DIRTY) {
if ((i > 0 || startEven) && (i < blocks || endEven))
dirtyVRAM[start + i] = DirtyVRAMFlag::CLEAN;
}
}

// The isTarget flag is mostly used for replay of dumps on a PSP.
Expand Down

0 comments on commit 0ce4e1b

Please sign in to comment.