mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Add some initial methods to GPUDebugInterface.
This commit is contained in:
parent
eabd8b5302
commit
3787471791
7 changed files with 163 additions and 17 deletions
|
@ -17,11 +17,39 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "GPU/GPUInterface.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
struct GPUDebugOp {
|
||||
u32 pc;
|
||||
u8 cmd;
|
||||
u32 op;
|
||||
std::string desc;
|
||||
};
|
||||
|
||||
class GPUDebugInterface {
|
||||
public:
|
||||
virtual bool GetCurrentDisplayList(DisplayList &list) = 0;
|
||||
virtual std::vector<DisplayList> ActiveDisplayLists() = 0;
|
||||
virtual void ResetListPC(int listID, u32 pc) = 0;
|
||||
virtual void ResetListStall(int listID, u32 stall) = 0;
|
||||
virtual void ResetListState(int listID, DisplayListState state) = 0;
|
||||
|
||||
GPUDebugOp DissassembleOp(u32 pc) {
|
||||
return DissassembleOp(pc, Memory::Read_U32(pc));
|
||||
}
|
||||
virtual GPUDebugOp DissassembleOp(u32 pc, u32 op) = 0;
|
||||
virtual std::vector<GPUDebugOp> DissassembleOpRange(u32 startpc, u32 endpc) = 0;
|
||||
|
||||
virtual u32 GetRelativeAddress(u32 data) = 0;
|
||||
virtual u32 GetVertexAddress() = 0;
|
||||
virtual u32 GetIndexAddress() = 0;
|
||||
virtual GPUgstate GetGState() = 0;
|
||||
|
||||
// TODO:
|
||||
// current list / all lists
|
||||
// cmds / matrices / addresses
|
||||
// cached framebuffers / textures / vertices?
|
||||
// get content of framebuffer / texture
|
||||
// vertex / texture decoding?
|
||||
|
|
|
@ -976,3 +976,101 @@ void GPUCommon::SyncEnd(WaitType waitType, int listid, bool wokeThreads) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GPUCommon::GetCurrentDisplayList(DisplayList &list) {
|
||||
easy_guard guard(listLock);
|
||||
if (!currentList) {
|
||||
return false;
|
||||
}
|
||||
list = *currentList;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<DisplayList> GPUCommon::ActiveDisplayLists() {
|
||||
std::vector<DisplayList> result;
|
||||
|
||||
easy_guard guard(listLock);
|
||||
for (auto it = dlQueue.begin(), end = dlQueue.end(); it != end; ++it) {
|
||||
result.push_back(dls[*it]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void GPUCommon::ResetListPC(int listID, u32 pc) {
|
||||
if (listID < 0 || listID >= DisplayListMaxCount) {
|
||||
_dbg_assert_msg_(G3D, false, "listID out of range: %d", listID);
|
||||
return;
|
||||
}
|
||||
|
||||
easy_guard guard(listLock);
|
||||
dls[listID].pc = pc;
|
||||
}
|
||||
|
||||
void GPUCommon::ResetListStall(int listID, u32 stall) {
|
||||
if (listID < 0 || listID >= DisplayListMaxCount) {
|
||||
_dbg_assert_msg_(G3D, false, "listID out of range: %d", listID);
|
||||
return;
|
||||
}
|
||||
|
||||
easy_guard guard(listLock);
|
||||
dls[listID].stall = stall;
|
||||
}
|
||||
|
||||
void GPUCommon::ResetListState(int listID, DisplayListState state) {
|
||||
if (listID < 0 || listID >= DisplayListMaxCount) {
|
||||
_dbg_assert_msg_(G3D, false, "listID out of range: %d", listID);
|
||||
return;
|
||||
}
|
||||
|
||||
easy_guard guard(listLock);
|
||||
dls[listID].state = state;
|
||||
}
|
||||
|
||||
GPUDebugOp GPUCommon::DissassembleOp(u32 pc, u32 op) {
|
||||
char buffer[1024];
|
||||
GeDisassembleOp(pc, op, Memory::Read_U32(pc - 4), buffer);
|
||||
|
||||
GPUDebugOp info;
|
||||
info.pc = pc;
|
||||
info.cmd = op >> 24;
|
||||
info.op = op;
|
||||
info.desc = buffer;
|
||||
return info;
|
||||
}
|
||||
|
||||
std::vector<GPUDebugOp> GPUCommon::DissassembleOpRange(u32 startpc, u32 endpc) {
|
||||
char buffer[1024];
|
||||
std::vector<GPUDebugOp> result;
|
||||
GPUDebugOp info;
|
||||
|
||||
u32 prev = Memory::Read_U32(startpc - 4);
|
||||
for (u32 pc = startpc; pc < endpc; pc += 4) {
|
||||
u32 op = Memory::Read_U32(pc);
|
||||
GeDisassembleOp(pc, op, prev, buffer);
|
||||
prev = op;
|
||||
|
||||
info.pc = pc;
|
||||
info.cmd = op >> 24;
|
||||
info.op = op;
|
||||
info.desc = buffer;
|
||||
result.push_back(info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
u32 GPUCommon::GetRelativeAddress(u32 data) {
|
||||
return gstate_c.getRelativeAddress(data);
|
||||
}
|
||||
|
||||
u32 GPUCommon::GetVertexAddress() {
|
||||
return gstate_c.vertexAddr;
|
||||
}
|
||||
|
||||
u32 GPUCommon::GetIndexAddress() {
|
||||
return gstate_c.indexAddr;
|
||||
}
|
||||
|
||||
GPUgstate GPUCommon::GetGState() {
|
||||
return gstate;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
typedef ThreadEventQueue<GPUInterface, GPUEvent, GPUEventType, GPU_EVENT_INVALID, GPU_EVENT_SYNC_THREAD, GPU_EVENT_FINISH_EVENT_LOOP> GPUThreadEventQueue;
|
||||
|
||||
class GPUCommon : public GPUThreadEventQueue
|
||||
class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface
|
||||
{
|
||||
public:
|
||||
GPUCommon();
|
||||
|
@ -138,6 +138,21 @@ private:
|
|||
}
|
||||
|
||||
public:
|
||||
// From GPUDebugInterface.
|
||||
virtual bool GetCurrentDisplayList(DisplayList &list);
|
||||
virtual std::vector<DisplayList> ActiveDisplayLists();
|
||||
virtual void ResetListPC(int listID, u32 pc);
|
||||
virtual void ResetListStall(int listID, u32 stall);
|
||||
virtual void ResetListState(int listID, DisplayListState state);
|
||||
|
||||
virtual GPUDebugOp DissassembleOp(u32 pc, u32 op);
|
||||
virtual std::vector<GPUDebugOp> DissassembleOpRange(u32 startpc, u32 endpc);
|
||||
|
||||
virtual u32 GetRelativeAddress(u32 data);
|
||||
virtual u32 GetVertexAddress();
|
||||
virtual u32 GetIndexAddress();
|
||||
virtual GPUgstate GetGState();
|
||||
|
||||
virtual DisplayList* getList(int listid)
|
||||
{
|
||||
return &dls[listid];
|
||||
|
@ -147,10 +162,6 @@ public:
|
|||
{
|
||||
return dlQueue;
|
||||
}
|
||||
DisplayList* GetCurrentDisplayList()
|
||||
{
|
||||
return currentList;
|
||||
}
|
||||
virtual bool DecodeTexture(u8* dest, GPUgstate state)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -244,7 +244,6 @@ public:
|
|||
virtual void DumpNextFrame() = 0;
|
||||
virtual void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) = 0;
|
||||
virtual const std::list<int>& GetDisplayLists() = 0;
|
||||
virtual DisplayList* GetCurrentDisplayList() = 0;
|
||||
virtual bool DecodeTexture(u8* dest, GPUgstate state) = 0;
|
||||
virtual std::vector<FramebufferInfo> GetFramebufferList() = 0;
|
||||
};
|
||||
|
|
|
@ -33,28 +33,33 @@
|
|||
GPUgstate gstate;
|
||||
GPUStateCache gstate_c;
|
||||
GPUInterface *gpu;
|
||||
GPUDebugInterface *gpuDebug;
|
||||
GPUStatistics gpuStats;
|
||||
|
||||
template <typename T>
|
||||
static void SetGPU(T *obj) {
|
||||
gpu = obj;
|
||||
gpuDebug = obj;
|
||||
}
|
||||
|
||||
bool GPU_Init() {
|
||||
switch (PSP_CoreParameter().gpuCore) {
|
||||
case GPU_NULL:
|
||||
gpu = new NullGPU();
|
||||
SetGPU(new NullGPU());
|
||||
break;
|
||||
case GPU_GLES:
|
||||
#ifndef _XBOX
|
||||
gpu = new GLES_GPU();
|
||||
SetGPU(new GLES_GPU());
|
||||
#endif
|
||||
break;
|
||||
case GPU_SOFTWARE:
|
||||
#if !(defined(__SYMBIAN32__) || defined(_XBOX))
|
||||
gpu = new SoftGPU();
|
||||
SetGPU(new SoftGPU());
|
||||
#endif
|
||||
break;
|
||||
case GPU_DIRECTX9:
|
||||
#if defined(_XBOX)
|
||||
gpu = new DIRECTX9_GPU();
|
||||
#elif defined(_WIN32)
|
||||
gpu = new DIRECTX9_GPU();
|
||||
#if defined(_XBOX) || defined(_WIN32)
|
||||
SetGPU(new DIRECTX9_GPU());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -65,6 +70,7 @@ bool GPU_Init() {
|
|||
void GPU_Shutdown() {
|
||||
delete gpu;
|
||||
gpu = 0;
|
||||
gpuDebug = 0;
|
||||
}
|
||||
|
||||
void InitGfxState() {
|
||||
|
|
|
@ -516,10 +516,12 @@ void ShutdownGfxState();
|
|||
void ReapplyGfxState();
|
||||
|
||||
class GPUInterface;
|
||||
class GPUDebugInterface;
|
||||
|
||||
extern GPUgstate gstate;
|
||||
extern GPUStateCache gstate_c;
|
||||
extern GPUInterface *gpu;
|
||||
extern GPUDebugInterface *gpuDebug;
|
||||
extern GPUStatistics gpuStats;
|
||||
|
||||
inline u32 GPUStateCache::getRelativeAddress(u32 data) const {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "GPU/GPUState.h"
|
||||
#include "GPU/GPUInterface.h"
|
||||
#include "GPU/GeDisasm.h"
|
||||
#include "GPU/Common/GPUDebugInterface.h"
|
||||
#include "EmuThread.h"
|
||||
#include "Core/Host.h"
|
||||
|
||||
|
@ -546,8 +547,9 @@ void Debugger_Disasm::UpdateDisplayListGUI()
|
|||
EmuThread_LockDraw(true);
|
||||
const std::list<int>& dlQueue = gpu->GetDisplayLists();
|
||||
|
||||
DisplayList* dl = gpu->GetCurrentDisplayList();
|
||||
if(dl)
|
||||
DisplayList dlist;
|
||||
DisplayList* dl = &dlist;
|
||||
if(gpuDebug->GetCurrentDisplayList(dlist))
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
item->setText(0,QString::number(dl->id));
|
||||
|
|
Loading…
Add table
Reference in a new issue