From 6339c2fc9a2f909a291a2f44ffe61ef5a0f8a995 Mon Sep 17 00:00:00 2001 From: Xele02 Date: Sun, 17 Feb 2013 13:10:40 +0100 Subject: [PATCH 1/5] Correct crash when texture too small loaded in memory tex viewer Correct current thread PC in the list. --- Core/HLE/sceKernelThread.cpp | 5 ++++- Qt/debugger_memorytex.cpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index ea1f8730ef..52aa4981c5 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -2805,7 +2805,10 @@ std::vector GetThreadsInfo() info.name[KERNELOBJECT_MAX_NAME_LENGTH+1] = 0; info.status = t->nt.status; info.entrypoint = t->nt.entrypoint; - info.curPC = t->context.pc; + if(*iter == currentThread) + info.curPC = currentMIPS->pc; + else + info.curPC = t->context.pc; info.isCurrent = (*iter == currentThread); threadList.push_back(info); } diff --git a/Qt/debugger_memorytex.cpp b/Qt/debugger_memorytex.cpp index bc9ea6272d..cdbf4ae640 100644 --- a/Qt/debugger_memorytex.cpp +++ b/Qt/debugger_memorytex.cpp @@ -70,8 +70,10 @@ void Debugger_MemoryTex::on_readBtn_clicked() state.clutaddr = ui->clutaddr->text().toInt(0,16); state.clutaddrupper = ui->clutaddrupper->text().toInt(0,16); state.loadclut = ui->loadclut->text().toInt(0,16); + int bufW = state.texbufwidth[0] & 0x3ff; int w = 1 << (state.texsize[0] & 0xf); int h = 1 << ((state.texsize[0]>>8) & 0xf); + w = std::max(bufW,w); uchar* newData = new uchar[w*h*4]; if(gpu->DecodeTexture(newData, state)) From 0fefca672d325fe15662cedd99ab1f2aff4fcde4 Mon Sep 17 00:00:00 2001 From: Xele02 Date: Sun, 17 Feb 2013 18:25:43 +0100 Subject: [PATCH 2/5] Add 2 step mode for display list : Go to selected line and go to next draw using selected texture --- Core/Host.h | 4 ++-- GPU/GPUCommon.cpp | 2 +- Qt/QtHost.cpp | 24 ++++++++++++++++--- Qt/QtHost.h | 5 ++-- Qt/debugger_displaylist.cpp | 47 +++++++++++++++++++++++++++++++++++++ Qt/debugger_displaylist.h | 8 +++++++ Qt/debugger_displaylist.ui | 6 +++++ 7 files changed, 88 insertions(+), 8 deletions(-) diff --git a/Core/Host.h b/Core/Host.h index 65d1782489..c60d270a66 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -65,8 +65,8 @@ public: virtual bool GpuStep() { return false; } virtual void SendGPUStart() {} - virtual void SendGPUWait(u32 cmd) {} - virtual void SetGPUStep(bool value, int flag = 0) {} + virtual void SendGPUWait(u32 cmd, u32 addr, void* data) {} + virtual void SetGPUStep(bool value, int flag = 0, int data = 0) {} virtual void NextGPUStep() {} // Used for headless. diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index ff050581ed..8d710972ff 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -98,7 +98,7 @@ bool GPUCommon::InterpretList(DisplayList &list) #if defined(USING_QT_UI) if(host->GpuStep()) { - host->SendGPUWait(cmd); + host->SendGPUWait(cmd, list.pc, &gstate); } #endif u32 diff = op ^ gstate.cmdmem[cmd]; diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index ca55e43879..4295edf126 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -28,6 +28,7 @@ recursive_mutex m_hGPUStepMutex; QtHost::QtHost(MainWindow *mainWindow_) : mainWindow(mainWindow_) , m_GPUStep(false) + , m_GPUFlag(0) { QObject::connect(this,SIGNAL(BootDoneSignal()),mainWindow,SLOT(Boot())); } @@ -162,7 +163,7 @@ void QtHost::SendGPUStart() EmuThread_LockDraw(true); } -void QtHost::SendGPUWait(u32 cmd) +void QtHost::SendGPUWait(u32 cmd, u32 addr, void *data) { EmuThread_LockDraw(false); @@ -173,19 +174,36 @@ void QtHost::SendGPUWait(u32 cmd) } else if(m_GPUFlag == 0) { - mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } + else if(m_GPUFlag == 2 && addr == m_GPUData) + { + mainWindow->GetDialogDisasm()->UpdateDisplayList(); + mainWindow->GetDialogDisplaylist()->Update(); + m_hGPUStepEvent.wait(m_hGPUStepMutex); + } + else if(m_GPUFlag == 3 && (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE)) + { + GPUgstate *state = (GPUgstate*)data; + u32 texAddr = (state->texaddr[0] & 0xFFFFF0) | ((state->texbufwidth[0]<<8) & 0x0F000000); + if(texAddr == m_GPUData) + { + mainWindow->GetDialogDisasm()->UpdateDisplayList(); + mainWindow->GetDialogDisplaylist()->Update(); + m_hGPUStepEvent.wait(m_hGPUStepMutex); + } + } EmuThread_LockDraw(true); } -void QtHost::SetGPUStep(bool value, int flag) +void QtHost::SetGPUStep(bool value, int flag, int data) { m_GPUStep = value; m_GPUFlag = flag; + m_GPUData = data; } void QtHost::NextGPUStep() diff --git a/Qt/QtHost.h b/Qt/QtHost.h index 8f578c9fd5..3e9305694d 100644 --- a/Qt/QtHost.h +++ b/Qt/QtHost.h @@ -51,9 +51,9 @@ public: void SendCoreWait(bool); bool GpuStep(); - void SendGPUWait(u32 cmd); + void SendGPUWait(u32 cmd, u32 addr, void* data); void SendGPUStart(); - void SetGPUStep(bool value, int flag = 0); + void SetGPUStep(bool value, int flag = 0, int data = 0); void NextGPUStep(); signals: @@ -62,6 +62,7 @@ private: MainWindow* mainWindow; bool m_GPUStep; int m_GPUFlag; + int m_GPUData; }; #endif // QTAPP_H diff --git a/Qt/debugger_displaylist.cpp b/Qt/debugger_displaylist.cpp index 0f557354ca..0d7dff132b 100644 --- a/Qt/debugger_displaylist.cpp +++ b/Qt/debugger_displaylist.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "Core/CPU.h" #include "ui_debugger_displaylist.h" @@ -1518,3 +1519,49 @@ void Debugger_DisplayList::on_indexList_itemClicked(QTreeWidgetItem *item, int c { UpdateIndexInfo(); } + +void Debugger_DisplayList::on_displayListData_customContextMenuRequested(const QPoint &pos) +{ + QTreeWidgetItem* item = ui->displayListData->itemAt(pos); + if(!item) + return; + displayListDataSelected = item; + + QMenu menu(this); + + QAction *runToHere = new QAction(tr("Run to here"), this); + connect(runToHere, SIGNAL(triggered()), this, SLOT(RunToDLPC())); + menu.addAction(runToHere); + + menu.exec( ui->displayListData->mapToGlobal(pos)); +} + +void Debugger_DisplayList::RunToDLPC() +{ + u32 addr = displayListDataSelected->text(0).toInt(0,16); + host->SetGPUStep(true, 2, addr); + host->NextGPUStep(); +} + +void Debugger_DisplayList::on_texturesList_customContextMenuRequested(const QPoint &pos) +{ + QTreeWidgetItem* item = ui->texturesList->itemAt(pos); + if(!item) + return; + textureDataSelected = item; + + QMenu menu(this); + + QAction *runToDraw = new QAction(tr("Run to draw using this texture"), this); + connect(runToDraw, SIGNAL(triggered()), this, SLOT(RunToDrawTex())); + menu.addAction(runToDraw); + + menu.exec( ui->texturesList->mapToGlobal(pos)); +} + +void Debugger_DisplayList::RunToDrawTex() +{ + u32 addr = textureDataSelected->text(0).toInt(0,16); + host->SetGPUStep(true, 3, addr); + host->NextGPUStep(); +} diff --git a/Qt/debugger_displaylist.h b/Qt/debugger_displaylist.h index e237a84f31..a4ae4a0648 100644 --- a/Qt/debugger_displaylist.h +++ b/Qt/debugger_displaylist.h @@ -93,6 +93,12 @@ private slots: void on_indexList_itemClicked(QTreeWidgetItem *item, int column); + void on_displayListData_customContextMenuRequested(const QPoint &pos); + + void on_texturesList_customContextMenuRequested(const QPoint &pos); + void RunToDLPC(); + void RunToDrawTex(); + private: QString DisassembleOp(u32 pc, u32 op, u32 prev, const GPUgstate &state); @@ -100,6 +106,8 @@ private: DebugInterface* cpu; MainWindow* mainWindow; QTreeWidgetItem* displayListRowSelected; + QTreeWidgetItem* displayListDataSelected; + QTreeWidgetItem* textureDataSelected; int currentRenderFrameDisplay; FBO* currentTextureDisplay; float fboZoomFactor; diff --git a/Qt/debugger_displaylist.ui b/Qt/debugger_displaylist.ui index 77a3ee5415..894a479ad2 100644 --- a/Qt/debugger_displaylist.ui +++ b/Qt/debugger_displaylist.ui @@ -118,6 +118,9 @@ + + Qt::CustomContextMenu + false @@ -192,6 +195,9 @@ + + Qt::CustomContextMenu + Address From 9e0bc2ae893e695c2c825c4b52af54cbee51c1bc Mon Sep 17 00:00:00 2001 From: Xele02 Date: Sun, 17 Feb 2013 20:08:40 +0100 Subject: [PATCH 3/5] Better info for the display list code --- Qt/debugger_displaylist.cpp | 380 +++++++++++++++++++++++++++++++----- 1 file changed, 328 insertions(+), 52 deletions(-) diff --git a/Qt/debugger_displaylist.cpp b/Qt/debugger_displaylist.cpp index 0d7dff132b..0d9771ac7c 100644 --- a/Qt/debugger_displaylist.cpp +++ b/Qt/debugger_displaylist.cpp @@ -372,7 +372,7 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg { int bz_ucount = data & 0xFF; int bz_vcount = (data >> 8) & 0xFF; - return QString("DRAW BEZIER: %1 x %2").arg(bz_ucount).arg(bz_vcount); + return QString("DRAW BEZIER: U=%1 x V=%2").arg(bz_ucount).arg(bz_vcount); } break; @@ -380,9 +380,15 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg { int sp_ucount = data & 0xFF; int sp_vcount = (data >> 8) & 0xFF; + static const char* type[4] = { + "Close/Close", + "Open/Close", + "Close/Open", + "Open/Open" + }; int sp_utype = (data >> 16) & 0x3; int sp_vtype = (data >> 18) & 0x3; - return QString("DRAW SPLINE: %1 x %2, %3 x %4").arg(sp_ucount).arg(sp_vcount).arg(sp_utype).arg(sp_vtype); + return QString("DRAW SPLINE: U=%1 x V=%2, U Type = %3 , V Type = %4").arg(sp_ucount).arg(sp_vcount).arg(type[sp_utype]).arg(type[sp_vtype]); } break; @@ -459,13 +465,15 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_BJUMP: + { // bounding box jump. Let's just not jump, for now. - return QString("BBOX JUMP - unimplemented"); + u32 target = (((state.base & 0x00FF0000) << 8) | (op & 0xFFFFFC)) & 0x0FFFFFFF; + return QString("BBOX JUMP - %1 to %2").arg(pc,8,16,QChar('0')).arg(target,8,16,QChar('0')); break; - + } case GE_CMD_BOUNDINGBOX: // bounding box test. Let's do nothing. - return QString("BBOX TEST - unimplemented"); + return QString("BBOX TEST - number : %1").arg(data & 0xFFFF,4,16,QChar('0')); break; case GE_CMD_ORIGIN: @@ -473,9 +481,57 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_VERTEXTYPE: - return QString("SetVertexType: %1").arg(data,6,16,QChar('0')); - break; + { + const char* format[4] = + { + "No", + "8 Bits fixed", + "16 Bits fixed", + "Float" + }; + const char* colFormat[8] = + { + "No", + "", + "", + "", + "16-bit BGR-5650", + "16-bit ABGR-5551", + "16-bit ABGR-4444", + "32-bit ABGR-8888" + }; + QString retString = "SetVertexType:"; + u32 transform = data & GE_VTYPE_THROUGH_MASK; + retString += QString(" Transform : %1").arg(transform==0?"Transformed":"Raw"); + + u32 numVertMorph = (data & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT; + retString += QString(", Num Vtx Morph : %1").arg(numVertMorph); + + u32 numWeight = (data & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT; + retString += QString(", Num Weights : %1").arg(numWeight); + + u32 indexFmt = (data & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT; + retString += QString(", Index Format : %1").arg(format[indexFmt]); + + u32 weightFmt = (data & GE_VTYPE_WEIGHT_MASK) >> GE_VTYPE_WEIGHT_SHIFT; + retString += QString(", Weight Format : %1").arg(format[weightFmt]); + + u32 posFmt = (data & GE_VTYPE_POS_MASK) >> GE_VTYPE_POS_SHIFT; + retString += QString(", Position Format : %1").arg(format[posFmt]); + + u32 nrmFmt = (data & GE_VTYPE_NRM_MASK) >> GE_VTYPE_NRM_SHIFT; + retString += QString(", Normal Format : %1").arg(format[nrmFmt]); + + u32 colFmt = (data & GE_VTYPE_COL_MASK) >> GE_VTYPE_COL_SHIFT; + retString += QString(", Color Format : %1").arg(colFormat[colFmt]); + + u32 tcFmt = (data & GE_VTYPE_TC_MASK) >> GE_VTYPE_TC_SHIFT; + retString += QString(", Texture UV Format : %1").arg(format[tcFmt]); + + return retString; + break; + } case GE_CMD_OFFSETADDR: return QString("OffsetAddr: %1").arg(data,6,16,QChar('0')); break; @@ -588,9 +644,17 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_FRAMEBUFPIXFORMAT: - return QString("FramebufPixeFormat: %1").arg(data); + { + const char* fmt[4] = + { + "16-bit BGR 5650", + "16-bit ABGR 5551", + "16-bit ABGR 4444", + "32-bit ABGR 8888" + }; + return QString("FramebufPixeFormat: %1").arg(fmt[data]); break; - + } case GE_CMD_TEXADDR0: case GE_CMD_TEXADDR1: case GE_CMD_TEXADDR2: @@ -610,7 +674,7 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg case GE_CMD_TEXBUFWIDTH5: case GE_CMD_TEXBUFWIDTH6: case GE_CMD_TEXBUFWIDTH7: - return QString("Texture BUFWIDTHess %1: %2").arg(cmd-GE_CMD_TEXBUFWIDTH0).arg(data,6,16,QChar('0')); + return QString("Texture BUFWIDTHess %1: %2 width : %3").arg(cmd-GE_CMD_TEXBUFWIDTH0).arg(data,6,16,QChar('0')).arg(data & 0xFFFF); break; case GE_CMD_CLUTADDR: @@ -623,20 +687,41 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg case GE_CMD_LOADCLUT: // This could be used to "dirty" textures with clut. - return QString("Clut load"); + return QString("Clut load, numColor : %1").arg(data*8); break; case GE_CMD_TEXMAPMODE: - return QString("Tex map mode: %1").arg(data,6,16,QChar('0')); + { + const char* texMapMode[3] = + { + "Texture Coordinates (UV)", + "Texture Matrix", + "Environment Map" + }; + const char* texProjMode[4] = + { + "Position", + "Texture Coordinates", + "Normalized Normal", + "Normal" + }; + return QString("Tex map mode: Map mode : %1, Proj Mode : %2").arg(texMapMode[data & 0x3]).arg(texProjMode[(data >> 8) & 0x3]); break; - + } case GE_CMD_TEXSHADELS: return QString("Tex shade light sources: %1").arg(data,6,16,QChar('0')); break; case GE_CMD_CLUTFORMAT: { - return QString("Clut format: %1").arg(data,6,16,QChar('0')); + const char* fmt[4] = + { + "16-bit BGR 5650", + "16-bit ABGR 5551", + "16-bit ABGR 4444", + "32-bit ABGR 8888" + }; + return QString("Clut format: %1 , Fmt : %2").arg(data,6,16,QChar('0')).arg(fmt[data & 0x3]); } break; @@ -696,7 +781,7 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg case GE_CMD_TRANSFERSTART: // Orphis calls this TRXKICK { - return QString("Block Transfer Start"); + return QString("Block Transfer Start : %1").arg(data ? "32-bit texel size" : "16-bit texel size"); break; } @@ -772,9 +857,22 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg case GE_CMD_LIGHTTYPE1: case GE_CMD_LIGHTTYPE2: case GE_CMD_LIGHTTYPE3: - return QString("Light %1 type: %2").arg(cmd-GE_CMD_LIGHTTYPE0).arg(data,6,16,QChar('0')); + { + const char* lightType[3] = + { + "Directional Light", + "Point Light", + "Spot Light" + }; + const char* lightComp[3] = + { + "Ambient & Diffuse", + "Diffuse & Specular", + "Unknown (diffuse color, affected by specular power)" + }; + return QString("Light %1 type: %2 %3").arg(cmd-GE_CMD_LIGHTTYPE0).arg(lightType[(data) >> 8 & 0x3]).arg(lightComp[data & 0x3]); break; - + } case GE_CMD_LX0:case GE_CMD_LY0:case GE_CMD_LZ0: case GE_CMD_LX1:case GE_CMD_LY1:case GE_CMD_LZ1: case GE_CMD_LX2:case GE_CMD_LY2:case GE_CMD_LZ2: @@ -855,42 +953,78 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_CULL: - return QString("cull: %1").arg(data,6,16,QChar('0')); + { + const char* cull[2] = + { + "Clockwise visible", + "Counter-clockwise visible" + }; + return QString("cull: %1").arg(cull[data & 0x1]); break; - + } case GE_CMD_PATCHDIVISION: { int patch_div_s = data & 0xFF; int patch_div_t = (data >> 8) & 0xFF; - return QString("Patch subdivision: %1 x %2").arg(patch_div_s).arg(patch_div_t); + return QString("Patch subdivision: S=%1 x T=%2").arg(patch_div_s).arg(patch_div_t); } break; case GE_CMD_PATCHPRIMITIVE: - return QString("Patch Primitive: %1").arg(data); + { + const char* type[3] = + { + "Triangles", + "Lines", + "Points" + }; + return QString("Patch Primitive: %1").arg(type[data]); break; - + } case GE_CMD_PATCHFACING: - return QString( "Patch Facing: %1").arg(data); + { + const char* val[2] = + { + "Clockwise", + "Counter-Clockwise" + }; + return QString( "Patch Facing: %1").arg(val[data]); break; - + } case GE_CMD_REVERSENORMAL: return QString("Reverse normal: %1").arg(data); break; case GE_CMD_MATERIALUPDATE: - return QString("Material Update: %1").arg(data); + { + QString txt = ""; + if(data & 1) txt += " Ambient"; + if(data & 2) txt += " Diffuse"; + if(data & 4) txt += " Specular"; + return QString("Material Update: %1").arg(txt); break; - + } ////////////////////////////////////////////////////////////////// // CLEARING ////////////////////////////////////////////////////////////////// case GE_CMD_CLEARMODE: + { // If it becomes a performance problem, check diff&1 - return QString("Clear mode: %1").arg(data,6,16,QChar('0')); + const char* clearMode[8] = + { + "", + "Clear Color Buffer", + "Clear Stencil/Alpha Buffer", + "", + "Clear Depth Buffer", + "", + "", + "" + }; + return QString("Clear mode: %1, enabled : %2").arg(clearMode[(data >> 8) & 0xF]).arg(data & 0x1); break; - + } ////////////////////////////////////////////////////////////////// // ALPHA BLENDING @@ -900,9 +1034,31 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_BLENDMODE: - return QString("Blend mode: %1").arg(data,6,16,QChar('0')); + { + const char* func[9] = + { + "Source Color", + "One Minus Source Color", + "Source Alpha", + "One Minus Source Alpha", + "Destination Color", + "One Minus Destination Color", + "Destination Alpha", + "One Minus Destination Alpha", + "Fix" + }; + const char* op[6] = + { + "Add", + "Subtract", + "Reverse Subtract", + "Minimum Value", + "Maximum Value", + "Absolute Value" + }; + return QString("Blend mode: Src : %1, Dest : %2, Op : %3").arg(func[(data >> 4) & 0xF]).arg(func[(data >> 8) & 0xF]).arg(op[(data) & 0x7]); break; - + } case GE_CMD_BLENDFIXEDA: return QString("Blend fix A: %1").arg(data,6,16,QChar('0')); break; @@ -916,9 +1072,21 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_ALPHATEST: - return QString("Alpha test settings"); + { + const char* testFunc[8] = + { + "Never pass pixel", + "Always pass pixel", + "Pass pixel if match", + "Pass pixel if difference", + "Pass pixel if less", + "Pass pixel if less or equal", + "Pass pixel if greater", + "Pass pixel if greater or equal" + }; + return QString("Alpha test settings, Mask : %1, Ref : %2, Test : %3").arg((data >> 8) & 0xFF).arg((data >> 16) & 0xFF).arg(testFunc[data & 0x7]); break; - + } case GE_CMD_ANTIALIASENABLE: return QString("Antialias enable: %1").arg(data); break; @@ -928,22 +1096,71 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_COLORTESTENABLE: - return QString("Color Test enable: %1").arg(data); + { + const char* colorTest[4] = + { + "Never pass pixel", + "Always pass pixel", + "Pass pixel if color matches", + "Pass pixel if color differs" + }; + return QString("Color Test enable: %1").arg(colorTest[data]); break; - + } case GE_CMD_LOGICOPENABLE: - return QString("Logic op enable: %1").arg(data); + { + const char* logicOp[16] = + { + "Clear", + "And", + "Reverse And", + "Copy", + "Inverted And", + "No Operation", + "Exclusive Or", + "Or", + "Negated Or", + "Equivalence", + "Inverted", + "Reverse Or", + "Inverted Copy", + "Inverted Or", + "Negated And", + "Set" + }; + return QString("Logic op enable: %1").arg(logicOp[data]); break; - + } case GE_CMD_TEXFUNC: - return QString("TexFunc %1").arg(data&7); + { + const char* effect[8] = + { + "Modulate", + "Decal", + "Blend", + "Replace", + "Add", + "","","" + }; + return QString("TexFunc %1 / %2 / %3").arg((data&0x100)?"Texture alpha is read":"Texture alpha is ignored").arg((data & 0x10000)?"Fragment color is doubled":"Fragment color is untouched").arg(effect[data & 0x7]); break; - + } case GE_CMD_TEXFILTER: { - int min = data & 7; - int mag = (data >> 8) & 1; - return QString("TexFilter min: %1 mag: %2").arg( min).arg(mag); + const char* filter[8]= + { + "Nearest", + "Linear", + "", + "", + "Nearest; Mipmap Nearest", + "Linear; Mipmap Nearest", + "Nearest; Mipmap Linear", + "Linear; Mipmap Linear" + }; + int min = data & 0x7; + int mag = (data >> 8) & 0x7; + return QString("TexFilter min: %1 mag: %2").arg(filter[min]).arg(filter[mag]); } break; @@ -952,13 +1169,30 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_TEXMODE: - return QString("TexMode %1").arg(data,8,16,QChar('0')); + { + u32 maxMipMap = (data >> 16) & 0xF; + return QString("TexMode MaxmipMap : %1, Swizzle : %2").arg(maxMipMap).arg(data & 0x1); break; - + } case GE_CMD_TEXFORMAT: - return QString("TexFormat %1").arg(data,8,16,QChar('0')); + { + const char* texFmt[11] = + { + "16-bit BGR 5650", + "16-bit ABGR 5551", + "16-bit ABGR 4444", + "32-bit ABGR 8888", + "4-bit indexed", + "8-bit indexed", + "16-bit indexed", + "32-bit indexed", + "DXT1", + "DXT3", + "DXT5" + }; + return QString("TexFormat %1").arg(texFmt[data]); break; - + } case GE_CMD_TEXFLUSH: return QString("TexFlush"); break; @@ -968,9 +1202,15 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_TEXWRAP: - return QString("TexWrap %1").arg(data,8,16,QChar('0')); + { + const char* wrapMode[2] = + { + "Repeat", + "Clamp" + }; + return QString("TexWrap U : %1, V : %2").arg(wrapMode[data & 0x1]).arg(wrapMode[(data >> 8) & 0x1]); break; - + } case GE_CMD_TEXLEVEL: return QString("TexWrap Mode: %1 Offset: %2").arg(data&3).arg(data >> 16); break; @@ -1000,21 +1240,57 @@ QString Debugger_DisplayList::DisassembleOp(u32 pc, u32 op, u32 prev, const GPUg break; case GE_CMD_STENCILOP: - return QString("Stencil op: %1").arg(data,6,16,QChar('0')); + { + const char* stencilOp[8] = + { + "Keep stencil value", + "Zero stencil value", + "Replace stencil value", + "Invert stencil value", + "Increment stencil value", + "Decrement stencil value", + "","" + }; + return QString("Stencil op: ZFail : %1, Fail : %2, Pass : %3").arg(stencilOp[(data >> 16) & 0x7]).arg(stencilOp[(data >> 8) & 0x7]).arg(stencilOp[(data) & 0x7]); break; - + } case GE_CMD_STENCILTEST: - return QString("Stencil test: %1").arg(data,6,16,QChar('0')); + { + const char* testFunc[8] = + { + "Never pass stencil pixel", + "Always pass stencil pixel", + "Pass test if match", + "Pass test if difference", + "Pass test if less", + "Pass test if less or equal", + "Pass test if greater", + "Pass test if greater or equal" + }; + return QString("Stencil test, Mask : %1, Ref : %2, Test : %3").arg((data >> 8) & 0xFF).arg((data >> 16) & 0xFF).arg(testFunc[data & 0x7]); break; + } case GE_CMD_STENCILTESTENABLE: return QString("Stencil test enable: %1").arg(data); break; case GE_CMD_ZTEST: - return QString("Z test mode: %1").arg(data); + { + const char* testFunc[8] = + { + "Never pass stencil pixel", + "Always pass stencil pixel", + "Pass pixel if match", + "Pass pixel if difference", + "Pass pixel if less", + "Pass pixel if less or equal", + "Pass pixel if greater", + "Pass pixel if greater or equal" + }; + return QString("Z test mode: %1").arg(testFunc[data & 0x7]); break; - + } case GE_CMD_MORPHWEIGHT0: case GE_CMD_MORPHWEIGHT1: case GE_CMD_MORPHWEIGHT2: From ec8d32378aacf67e5545af7ef45423a3266a9aeb Mon Sep 17 00:00:00 2001 From: Xele02 Date: Sun, 17 Feb 2013 21:42:54 +0100 Subject: [PATCH 4/5] Add possibility to modify memory values Optim time when parsing DList for debug. --- Qt/ctrlmemview.cpp | 28 ++++++++++++++++++++++++++++ Qt/ctrlmemview.h | 1 + Qt/debugger_displaylist.cpp | 15 ++++++++------- 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Qt/ctrlmemview.cpp b/Qt/ctrlmemview.cpp index c7c6637436..0ebaa97775 100644 --- a/Qt/ctrlmemview.cpp +++ b/Qt/ctrlmemview.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "EmuThread.h" #include "Core/MemMap.h" @@ -221,6 +222,10 @@ void CtrlMemView::contextMenu(const QPoint &pos) connect(copyValue, SIGNAL(triggered()), this, SLOT(CopyValue())); menu.addAction(copyValue); + QAction *changeValue = new QAction(tr("C&hange value"), this); + connect(changeValue, SIGNAL(triggered()), this, SLOT(Change())); + menu.addAction(changeValue); + QAction *dump = new QAction(tr("Dump..."), this); connect(dump, SIGNAL(triggered()), this, SLOT(Dump())); menu.addAction(dump); @@ -230,7 +235,9 @@ void CtrlMemView::contextMenu(const QPoint &pos) void CtrlMemView::CopyValue() { + EmuThread_LockDraw(true); QApplication::clipboard()->setText(QString("%1").arg(Memory::ReadUnchecked_U32(selection),8,16,QChar('0'))); + EmuThread_LockDraw(false); } void CtrlMemView::Dump() @@ -238,6 +245,27 @@ void CtrlMemView::Dump() QMessageBox::information(this,"Sorry","This feature has not been implemented.",QMessageBox::Ok); } + +void CtrlMemView::Change() +{ + EmuThread_LockDraw(true); + QString curVal = QString("%1").arg(Memory::ReadUnchecked_U32(selection),8,16,QChar('0')); + EmuThread_LockDraw(false); + + bool ok; + QString text = QInputDialog::getText(this, tr("Set new value"), + tr("Set new value:"), QLineEdit::Normal, + curVal, &ok); + if (ok && !text.isEmpty()) + { + EmuThread_LockDraw(true); + Memory::WriteUnchecked_U32(text.toInt(0,16),selection); + EmuThread_LockDraw(false); + redraw(); + } +} + + int CtrlMemView::yToAddress(int y) { int ydiff=y-rect().bottom()/2-rowHeight/2; diff --git a/Qt/ctrlmemview.h b/Qt/ctrlmemview.h index 070b1af7f9..cc7f31c506 100644 --- a/Qt/ctrlmemview.h +++ b/Qt/ctrlmemview.h @@ -72,6 +72,7 @@ signals: public slots: void CopyValue(); void Dump(); + void Change(); private: int curAddress; int align; diff --git a/Qt/debugger_displaylist.cpp b/Qt/debugger_displaylist.cpp index 0d9771ac7c..c5103192f9 100644 --- a/Qt/debugger_displaylist.cpp +++ b/Qt/debugger_displaylist.cpp @@ -309,15 +309,16 @@ void Debugger_DisplayList::ShowDLCode() } usedIdxAddr.insert(iaddr); } - - for(int i = 0; i < ui->texturesList->columnCount(); i++) - ui->texturesList->resizeColumnToContents(i); - for(int i = 0; i < ui->vertexList->columnCount(); i++) - ui->vertexList->resizeColumnToContents(i); - for(int i = 0; i < ui->indexList->columnCount(); i++) - ui->indexList->resizeColumnToContents(i); } + + for(int i = 0; i < ui->texturesList->columnCount(); i++) + ui->texturesList->resizeColumnToContents(i); + for(int i = 0; i < ui->vertexList->columnCount(); i++) + ui->vertexList->resizeColumnToContents(i); + for(int i = 0; i < ui->indexList->columnCount(); i++) + ui->indexList->resizeColumnToContents(i); + UpdateVertexInfo(); UpdateIndexInfo(); } From 20597e4990edeaf6b812f8571a8f0361f8f52bb8 Mon Sep 17 00:00:00 2001 From: Xele02 Date: Sun, 17 Feb 2013 22:05:31 +0100 Subject: [PATCH 5/5] Sync native Put gui command in the gui thread. --- Qt/debugger_displaylist.cpp | 10 ++++++++-- Qt/debugger_displaylist.h | 2 ++ native | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Qt/debugger_displaylist.cpp b/Qt/debugger_displaylist.cpp index c5103192f9..5b688d7337 100644 --- a/Qt/debugger_displaylist.cpp +++ b/Qt/debugger_displaylist.cpp @@ -31,6 +31,7 @@ Debugger_DisplayList::Debugger_DisplayList(DebugInterface *_cpu, MainWindow* mai QObject::connect(this, SIGNAL(updateDisplayList_()), this, SLOT(UpdateDisplayListGUI())); QObject::connect(this, SIGNAL(updateRenderBufferList_()), this, SLOT(UpdateRenderBufferListGUI())); + QObject::connect(this, SIGNAL(updateRenderBuffer_()), this, SLOT(UpdateRenderBufferGUI())); } @@ -1498,6 +1499,11 @@ void Debugger_DisplayList::on_stopBtn_clicked() } void Debugger_DisplayList::UpdateRenderBuffer() +{ + emit updateRenderBuffer_(); +} + +void Debugger_DisplayList::UpdateRenderBufferGUI() { EmuThread_LockDraw(true); @@ -1580,7 +1586,7 @@ void Debugger_DisplayList::on_texturesList_itemDoubleClicked(QTreeWidgetItem *it void Debugger_DisplayList::on_comboBox_currentIndexChanged(int index) { currentRenderFrameDisplay = index; - UpdateRenderBuffer(); + UpdateRenderBufferGUI(); } void Debugger_DisplayList::UpdateRenderBufferList() @@ -1622,7 +1628,7 @@ void Debugger_DisplayList::on_fboList_itemClicked(QTreeWidgetItem *item, int col u64 addr = item->data(0,Qt::UserRole).toULongLong(); FBO* fbo = (FBO*)addr; currentTextureDisplay = fbo; - UpdateRenderBuffer(); + UpdateRenderBufferGUI(); } void Debugger_DisplayList::on_nextDLBtn_clicked() diff --git a/Qt/debugger_displaylist.h b/Qt/debugger_displaylist.h index a4ae4a0648..7ecec82302 100644 --- a/Qt/debugger_displaylist.h +++ b/Qt/debugger_displaylist.h @@ -54,10 +54,12 @@ protected: signals: void updateDisplayList_(); void updateRenderBufferList_(); + void updateRenderBuffer_(); private slots: void UpdateDisplayListGUI(); void UpdateRenderBufferListGUI(); + void UpdateRenderBufferGUI(); void releaseLock(); void on_displayList_itemClicked(QTreeWidgetItem *item, int column); diff --git a/native b/native index f5e7bd5a9c..f7db8ff0be 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit f5e7bd5a9c3e4b39a4eac71b577f06ad54f2bc96 +Subproject commit f7db8ff0bea971ed6c1332ce746101d3f0146010