Skip to content

Commit

Permalink
Merge pull request hrydgard#19731 from hrydgard/ge-debugger-refactor
Browse files Browse the repository at this point in the history
GE debugger refactor: Have GPUCommon own more of the debugging data
  • Loading branch information
hrydgard authored Dec 15, 2024
2 parents 72ee027 + 4223bcf commit b608257
Show file tree
Hide file tree
Showing 36 changed files with 430 additions and 404 deletions.
2 changes: 1 addition & 1 deletion Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void Core_RunLoopUntil(u64 globalticks) {
case CORE_RUNNING_GE:
switch (gpu->ProcessDLQueue()) {
case DLResult::DebugBreak:
GPUStepping::EnterStepping();
GPUStepping::EnterStepping(coreState);
break;
case DLResult::Error:
// We should elegantly report the error somehow, or I guess ignore it.
Expand Down
6 changes: 4 additions & 2 deletions Core/Debugger/WebSocket/GPURecordSubscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "Core/Debugger/WebSocket/WebSocketUtils.h"
#include "Core/System.h"
#include "GPU/Debugger/Record.h"
#include "GPU/GPU.h"
#include "GPU/Common/GPUDebugInterface.h"

struct WebSocketGPURecordState : public DebuggerSubscriber {
~WebSocketGPURecordState();
Expand All @@ -44,7 +46,7 @@ DebuggerSubscriber *WebSocketGPURecordInit(DebuggerEventHandlerMap &map) {
WebSocketGPURecordState::~WebSocketGPURecordState() {
// Clear the callback to hopefully avoid a crash.
if (pending_)
GPURecord::ClearCallback();
gpuDebug->GetRecorder()->ClearCallback();
}

// Begin recording (gpu.record.dump)
Expand All @@ -60,7 +62,7 @@ void WebSocketGPURecordState::Dump(DebuggerRequest &req) {
return req.Fail("CPU not started");
}

bool result = GPURecord::RecordNextFrame([=](const Path &filename) {
bool result = gpuDebug->GetRecorder()->RecordNextFrame([=](const Path &filename) {
lastFilename_ = filename;
pending_ = false;
});
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ void __DisplayFlip(int cyclesLate) {
// 4 here means 1 drawn, 4 skipped - so 12 fps minimum.
maxFrameskip = frameSkipNum;
}
if (numSkippedFrames >= maxFrameskip || GPURecord::IsActivePending()) {
if (numSkippedFrames >= maxFrameskip || gpuDebug->GetRecorder()->IsActivePending()) {
skipFrame = false;
}

Expand Down
4 changes: 2 additions & 2 deletions GPU/Common/FramebufferManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ bool FramebufferManagerCommon::PresentedThisFrame() const {
return presentation_->PresentedThisFrame();
}

void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format, GPURecord::Recorder *recorder) {
displayFramebufPtr_ = framebuf & 0x3FFFFFFF;
if (Memory::IsVRAMAddress(displayFramebufPtr_))
displayFramebufPtr_ = framebuf & 0x041FFFFF;
displayStride_ = stride;
displayFormat_ = format;
GPUDebug::NotifyDisplay(framebuf, stride, format);
GPURecord::NotifyDisplay(framebuf, stride, format);
recorder->NotifyDisplay(framebuf, stride, format);
}

VirtualFramebuffer *FramebufferManagerCommon::GetVFBAt(u32 addr) const {
Expand Down
6 changes: 5 additions & 1 deletion GPU/Common/FramebufferManagerCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ namespace Draw {
class DrawContext;
}

namespace GPURecord {
class Recorder;
}

struct DrawPixelsEntry {
Draw::Texture *tex;
uint64_t contentsHash;
Expand Down Expand Up @@ -302,7 +306,7 @@ class FramebufferManagerCommon {

void Init(int msaaLevel);
virtual void BeginFrame();
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format);
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format, GPURecord::Recorder *recorder);
void DestroyFramebuf(VirtualFramebuffer *v);

VirtualFramebuffer *DoSetRenderFrameBuffer(FramebufferHeuristicParams &params, u32 skipDrawReason);
Expand Down
8 changes: 8 additions & 0 deletions GPU/Common/GPUDebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class TextureCacheCommon;
struct VirtualFramebuffer;
struct DisplayList;

namespace GPURecord {
class Recorder;
}
class GPUBreakpoints;

struct GPUDebugOp {
u32 pc;
u8 cmd;
Expand Down Expand Up @@ -239,6 +244,9 @@ class GPUDebugInterface {
virtual const std::list<int> &GetDisplayListQueue() = 0;
virtual const DisplayList &GetDisplayList(int index) = 0;

virtual GPURecord::Recorder *GetRecorder() = 0;
virtual GPUBreakpoints *GetBreakpoints() = 0;

virtual bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ void TextureCacheCommon::NotifyWriteFormattedFromMemory(u32 addr, int size, int
videos_.push_back({ addr, (u32)size, gpuStats.numFlips });
}

void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) {
void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes, GPURecord::Recorder *recorder) {
if (loadBytes == 0) {
// Don't accidentally overwrite clutTotalBytes_ with a zero.
return;
Expand Down Expand Up @@ -1430,7 +1430,7 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) {
u32 bytes = Memory::ValidSize(clutAddr, loadBytes);
_assert_(bytes <= 2048);
bool performDownload = PSP_CoreParameter().compat.flags().AllowDownloadCLUT;
if (GPURecord::IsActive())
if (recorder->IsActive())
performDownload = true;
if (clutRenderAddress_ != 0xFFFFFFFF && performDownload) {
framebufferManager_->DownloadFramebufferForClut(clutRenderAddress_, clutRenderOffset_ + bytes);
Expand Down
6 changes: 5 additions & 1 deletion GPU/Common/TextureCacheCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class DrawContext;
class Texture;
}

namespace GPURecord {
class Recorder;
}

// Used by D3D11 and Vulkan, could be used by modern GL
struct SamplerCacheKey {
union {
Expand Down Expand Up @@ -334,7 +338,7 @@ class TextureCacheCommon {
TextureCacheCommon(Draw::DrawContext *draw, Draw2D *draw2D);
virtual ~TextureCacheCommon();

void LoadClut(u32 clutAddr, u32 loadBytes);
void LoadClut(u32 clutAddr, u32 loadBytes, GPURecord::Recorder *recorder);
bool GetCurrentClutBuffer(GPUDebugBuffer &buffer);

// This updates nextTexture_ / nextFramebufferTexture_, which is then used by ApplyTexture.
Expand Down
2 changes: 1 addition & 1 deletion GPU/D3D11/DrawEngineD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ void DrawEngineD3D11::DoFlush() {

ResetAfterDrawInline();
framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason);
GPUDebug::NotifyDraw();
GPUDebug::NotifyFlush();
}

TessellationDataTransferD3D11::TessellationDataTransferD3D11(ID3D11DeviceContext *context, ID3D11Device *device)
Expand Down
Loading

0 comments on commit b608257

Please sign in to comment.