GE Debugger: Record memcpy/memset too.

This commit is contained in:
Unknown W. Brackets 2017-06-03 00:09:58 -07:00
parent b2bd966adf
commit 37a894a558
4 changed files with 47 additions and 0 deletions

View file

@ -44,6 +44,9 @@ enum class CommandType : u8 {
INDICES = 3,
CLUT = 4,
TRANSFERSRC = 5,
MEMSET = 6,
MEMCPYDEST = 7,
MEMCPYDATA = 8,
TEXTURE0 = 0x10,
TEXTURE1 = 0x11,
@ -362,6 +365,40 @@ void NotifyCommand(u32 pc) {
}
}
void NotifyMemcpy(u32 dest, u32 src, u32 sz) {
if (Memory::IsVRAMAddress(dest)) {
FlushRegisters();
Command cmd{CommandType::MEMCPYDEST, sizeof(dest), (u32)pushbuf.size()};
pushbuf.resize(pushbuf.size() + sizeof(dest));
memcpy(pushbuf.data() + cmd.ptr, &dest, sizeof(dest));
sz = Memory::ValidSize(dest, sz);
EmitCommandWithRAM(CommandType::MEMCPYDATA, Memory::GetPointer(dest), sz);
}
}
void NotifyMemset(u32 dest, int v, u32 sz) {
struct MemsetCommand {
u32 dest;
int value;
u32 sz;
};
if (Memory::IsVRAMAddress(dest)) {
sz = Memory::ValidSize(dest, sz);
MemsetCommand data{dest, v, sz};
FlushRegisters();
Command cmd{CommandType::MEMSET, sizeof(data), (u32)pushbuf.size()};
pushbuf.resize(pushbuf.size() + sizeof(data));
memcpy(pushbuf.data() + cmd.ptr, &data, sizeof(data));
}
}
void NotifyUpload(u32 dest, u32 sz) {
NotifyMemcpy(dest, dest, sz);
}
void NotifyFrame() {
if (active) {
active = false;

View file

@ -24,6 +24,9 @@ namespace GPURecord {
bool IsActive();
void NotifyCommand(u32 pc);
void NotifyMemcpy(u32 dest, u32 src, u32 sz);
void NotifyMemset(u32 dest, int v, u32 sz);
void NotifyUpload(u32 dest, u32 sz);
void NotifyFrame();
};

View file

@ -2347,6 +2347,7 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) {
}
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemcpy(dest, src, size);
return false;
}
@ -2371,6 +2372,7 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) {
// Or perhaps a texture, let's invalidate.
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemset(dest, v, size);
return false;
}
@ -2387,6 +2389,7 @@ bool GPUCommon::PerformMemoryUpload(u32 dest, int size) {
// Cheat a bit to force an upload of the framebuffer.
// VRAM + 0x00400000 is simply a VRAM mirror.
if (Memory::IsVRAMAddress(dest)) {
GPURecord::NotifyUpload(dest, size);
return PerformMemoryCopy(dest, dest ^ 0x00400000, size);
}
return false;

View file

@ -37,6 +37,7 @@
#include "GPU/Software/TransformUnit.h"
#include "GPU/Common/DrawEngineCommon.h"
#include "GPU/Common/FramebufferCommon.h"
#include "GPU/Debugger/Record.h"
const int FB_WIDTH = 480;
const int FB_HEIGHT = 272;
@ -876,6 +877,7 @@ bool SoftGPU::PerformMemoryCopy(u32 dest, u32 src, int size)
{
// Nothing to update.
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemcpy(dest, src, size);
// Let's just be safe.
framebufferDirty_ = true;
return false;
@ -885,6 +887,7 @@ bool SoftGPU::PerformMemorySet(u32 dest, u8 v, int size)
{
// Nothing to update.
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyMemset(dest, v, size);
// Let's just be safe.
framebufferDirty_ = true;
return false;
@ -901,6 +904,7 @@ bool SoftGPU::PerformMemoryUpload(u32 dest, int size)
{
// Nothing to update.
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
GPURecord::NotifyUpload(dest, size);
return false;
}