From 5cf13ee84a8162b847d3c30685f1a2694b54ec2f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 12 Oct 2013 18:31:13 -0700 Subject: [PATCH 1/6] Add "Step Prim" button, reorganize buttons a bit. --- Windows/GEDebugger/GEDebugger.cpp | 7 +++++++ Windows/GEDebugger/GEDebugger.h | 1 + Windows/ppsspp.rc | 13 +++++++------ Windows/resource.h | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 998a761195..f7cdf8d011 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -331,6 +331,13 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { SetBreakNext(BREAK_NEXT_FRAME); break; + case IDC_GEDBG_STEPPRIM: + AddCmdBreakpoint(GE_CMD_PRIM, true); + AddCmdBreakpoint(GE_CMD_BEZIER, true); + AddCmdBreakpoint(GE_CMD_SPLINE, true); + SetBreakNext(BREAK_NEXT_PRIM); + break; + case IDC_GEDBG_BREAKTEX: { if (!gpuDebug) { diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 17744bb0fb..64e017b3d1 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -40,6 +40,7 @@ enum BreakNextType { BREAK_NEXT_TEX, BREAK_NEXT_NONTEX, BREAK_NEXT_FRAME, + BREAK_NEXT_PRIM, }; class CtrlDisplayListView; diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index 85d5318688..eea8a6cec1 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -171,17 +171,18 @@ EXSTYLE WS_EX_ACCEPTFILES | WS_EX_TOOLWINDOW CAPTION "GE" FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - PUSHBUTTON "Step Draw",IDC_GEDBG_STEPDRAW,0,0,48,14 - PUSHBUTTON "Step Into",IDC_GEDBG_STEP,52,0,48,14 - PUSHBUTTON "Step Tex",IDC_GEDBG_STEPTEX,104,0,48,14 - PUSHBUTTON "Step Frame",IDC_GEDBG_STEPFRAME,156,0,48,14 - PUSHBUTTON "Resume",IDC_GEDBG_RESUME,208,0,48,14 + PUSHBUTTON "Step &Frame",IDC_GEDBG_STEPFRAME,10,2,48,14 + PUSHBUTTON "Step &Tex",IDC_GEDBG_STEPTEX,62,2,48,14 + PUSHBUTTON "Step &Draw",IDC_GEDBG_STEPDRAW,114,2,48,14 + PUSHBUTTON "Step &Prim",IDC_GEDBG_STEPPRIM,166,2,48,14 + PUSHBUTTON "Step &Into",IDC_GEDBG_STEP,218,2,48,14 + PUSHBUTTON "&Resume",IDC_GEDBG_RESUME,270,2,48,14 CONTROL "",IDC_GEDBG_TEX,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,10,20,128,128 CONTROL "",IDC_GEDBG_FRAME,"SimpleGLWindow",WS_CHILD | WS_VISIBLE,148,20,256,136 CONTROL "",IDC_GEDBG_MAINTAB,"SysTabControl32",TCS_TABS | TCS_FOCUSNEVER,10,216,480,180 EDITTEXT IDC_GEDBG_FRAMEBUFADDR,148,192,128,12,ES_READONLY | NOT WS_BORDER EDITTEXT IDC_GEDBG_TEXADDR,10,152,128,12,ES_READONLY | NOT WS_BORDER - PUSHBUTTON "Break on Texture...",IDC_GEDBG_BREAKTEX,24,172,100,14 + PUSHBUTTON "Break on Te&xture...",IDC_GEDBG_BREAKTEX,24,172,100,14 CONTROL "",IDC_GEDBG_FBTABS,"SysTabControl32",TCS_BUTTONS | TCS_FOCUSNEVER,384,192,110,12 END diff --git a/Windows/resource.h b/Windows/resource.h index f50a955e7d..b27ce498ff 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -296,6 +296,7 @@ #define IDC_GEDBG_BREAKTEX 40135 #define ID_OPTIONS_PAUSE_FOCUS 40136 #define ID_TEXTURESCALING_AUTO 40137 +#define IDC_GEDBG_STEPPRIM 40138 // Dummy option to let the buffered rendering hotkey cycle through all the options. #define ID_OPTIONS_BUFFEREDRENDERINGDUMMY 40500 @@ -308,7 +309,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 254 -#define _APS_NEXT_COMMAND_VALUE 40138 +#define _APS_NEXT_COMMAND_VALUE 40139 #define _APS_NEXT_CONTROL_VALUE 1193 #define _APS_NEXT_SYMED_VALUE 101 #endif From d5af703a5a90205e0c5957ca469724aa940b98f1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 12 Oct 2013 22:17:24 -0700 Subject: [PATCH 2/6] Add a stub for a vertex preview. --- Windows/GEDebugger/GEDebugger.cpp | 11 ++++-- Windows/GEDebugger/GEDebugger.h | 1 + Windows/GEDebugger/SimpleGLWindow.cpp | 18 ++++++++-- Windows/GEDebugger/SimpleGLWindow.h | 6 +++- Windows/GEDebugger/VertexPreview.cpp | 50 +++++++++++++++++++++++++++ Windows/PPSSPP.vcxproj | 1 + Windows/PPSSPP.vcxproj.filters | 3 ++ 7 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 Windows/GEDebugger/VertexPreview.cpp diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index f7cdf8d011..edcf20903c 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -20,7 +20,6 @@ #include #include "base/functional.h" -#include "base/mutex.h" #include "Windows/GEDebugger/GEDebugger.h" #include "Windows/GEDebugger/SimpleGLWindow.h" #include "Windows/GEDebugger/CtrlDisplayListView.h" @@ -216,6 +215,13 @@ void CGEDebugger::UpdatePreviews() { DisplayList list; if (gpuDebug != NULL && gpuDebug->GetCurrentDisplayList(list)) { + const u32 op = Memory::Read_U32(list.pc); + const u32 cmd = op >> 24; + // TODO: Bezier/spline? + if (cmd == GE_CMD_PRIM) { + UpdatePrimPreview(op); + } + displayList->setDisplayList(list); } @@ -226,8 +232,7 @@ void CGEDebugger::UpdatePreviews() { lists->Update(); } -void CGEDebugger::UpdateSize(WORD width, WORD height) -{ +void CGEDebugger::UpdateSize(WORD width, WORD height) { // only resize the tab for now HWND tabControl = GetDlgItem(m_hDlg, IDC_GEDBG_MAINTAB); diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 64e017b3d1..de2ef79cad 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -63,6 +63,7 @@ protected: private: void SetupPreviews(); void UpdatePreviews(); + void UpdatePrimPreview(u32 op); void UpdateSize(WORD width, WORD height); void SavePosition(); void SetBreakNext(BreakNextType type); diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index 2b329365ca..0db94d4028 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -254,11 +254,13 @@ void SimpleGLWindow::Draw(u8 *data, int w, int h, bool flipped, Format fmt) { Redraw(); } -void SimpleGLWindow::Redraw() { +void SimpleGLWindow::Redraw(bool andSwap) { DrawChecker(); if (tw_ == 0 && th_ == 0) { - Swap(); + if (andSwap) { + Swap(); + } return; } @@ -310,7 +312,9 @@ void SimpleGLWindow::Redraw() { glActiveTexture(GL_TEXTURE0); glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices); - Swap(); + if (andSwap) { + Swap(); + } } void SimpleGLWindow::Clear() { @@ -319,6 +323,14 @@ void SimpleGLWindow::Clear() { Redraw(); } +void SimpleGLWindow::Begin() { + Redraw(false); +} + +void SimpleGLWindow::End() { + Swap(); +} + bool SimpleGLWindow::DragStart(int mouseX, int mouseY) { // Only while zoomed in, otherwise it's shrink to fit mode or fixed. if (!zoom_) { diff --git a/Windows/GEDebugger/SimpleGLWindow.h b/Windows/GEDebugger/SimpleGLWindow.h index 97b36c8e53..310fec5746 100644 --- a/Windows/GEDebugger/SimpleGLWindow.h +++ b/Windows/GEDebugger/SimpleGLWindow.h @@ -49,11 +49,15 @@ struct SimpleGLWindow { void Clear(); void Draw(u8 *data, int w, int h, bool flipped = false, Format = FORMAT_8888); - void Redraw(); + void Redraw(bool andSwap = true); void Initialize(u32 flags); static SimpleGLWindow *GetFrom(HWND hwnd); static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + // To draw something custom. + void Begin(); + void End(); + void SetFlags(u32 flags) { flags_ = flags; } diff --git a/Windows/GEDebugger/VertexPreview.cpp b/Windows/GEDebugger/VertexPreview.cpp new file mode 100644 index 0000000000..283844a185 --- /dev/null +++ b/Windows/GEDebugger/VertexPreview.cpp @@ -0,0 +1,50 @@ +// Copyright (c) 2013- PPSSPP Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0 or later versions. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include "Windows/GEDebugger/GEDebugger.h" +#include "Windows/GEDebugger/SimpleGLWindow.h" +#include "GPU/GPUInterface.h" +#include "GPU/Common/GPUDebugInterface.h" +#include "GPU/GPUState.h" + +// TODO: Possibly a shader here to do the transforms? + +void CGEDebugger::UpdatePrimPreview(u32 op) { + const u32 prim_type = (op >> 16) & 0xFF; + const u32 count = op & 0xFFFF; + if (prim_type >= 7) { + ERROR_LOG(COMMON, "Unsupported prim type: %x", op); + return; + } + if (!gpuDebug) { + ERROR_LOG(COMMON, "Invalid debugging environment, shutting down?", op); + return; + } + if (count == 0) { + return; + } + + const GEPrimitiveType prim = static_cast(prim_type); + + frameWindow->Begin(); + // TODO: Get the coords, render on top of the texture and framebuffer previews. + // TODO: glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);? + frameWindow->End(); + + texWindow->Begin(); + texWindow->End(); +} \ No newline at end of file diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index fd555f0d77..1682290d28 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -287,6 +287,7 @@ + diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 9c944deaa3..7753ca85f2 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -134,6 +134,9 @@ Windows\Debugger + + Windows\GE Debugger + From 428a8181e53dc9ff7da68ab715cca6194f59de27 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 00:38:52 -0700 Subject: [PATCH 3/6] Format stencil and alpha tests differently. One is the stored value on the right, the other is the vertex value on the left. --- GPU/GeDisasm.cpp | 4 ++-- Windows/GEDebugger/TabState.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index ef582cebc8..4520a1676c 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -807,8 +807,8 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) { case GE_CMD_ALPHATEST: { - const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; - sprintf(buffer, "Alpha test settings: %06x (%02x%s(c & %02x))", data, (data >> 8) & 0xFF, alphaTestFuncs[data & 7], (data >> 16) & 0xFF); + const char *alphaTestFuncs[] = { " NEVER ", " ALWAYS ", " == ", " != ", " < ", " <= ", " > ", " >= " }; + sprintf(buffer, "Alpha test settings: %06x ((c & %02x)%s%02x)", data, (data >> 16) & 0xFF, (data >> 8) & 0xFF, alphaTestFuncs[data & 7]); } break; diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index baca3a3e39..6681874283 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -49,6 +49,7 @@ enum CmdFormatType { CMD_FMT_TEXFMT, CMD_FMT_COLORTEST, CMD_FMT_ALPHATEST, + CMD_FMT_STENCILTEST, CMD_FMT_ZTEST, CMD_FMT_OFFSETADDR, CMD_FMT_VADDR, @@ -208,7 +209,7 @@ static const TabStateRow stateSettingsRows[] = { { L"Cull mode", GE_CMD_CULL, CMD_FMT_NUM, GE_CMD_CULLFACEENABLE }, { L"Color test", GE_CMD_COLORTEST, CMD_FMT_COLORTEST, GE_CMD_COLORTESTENABLE, GE_CMD_COLORREF, GE_CMD_COLORTESTMASK }, { L"Alpha test", GE_CMD_ALPHATEST, CMD_FMT_ALPHATEST, GE_CMD_ALPHATESTENABLE }, - { L"Stencil test", GE_CMD_STENCILTEST, CMD_FMT_ALPHATEST, GE_CMD_STENCILTESTENABLE }, + { L"Stencil test", GE_CMD_STENCILTEST, CMD_FMT_STENCILTEST, GE_CMD_STENCILTESTENABLE }, { L"Stencil test op", GE_CMD_STENCILOP, CMD_FMT_STENCILOP, GE_CMD_STENCILTESTENABLE }, { L"Depth test", GE_CMD_ZTEST, CMD_FMT_ZTEST, GE_CMD_ZTESTENABLE }, { L"Alpha blend mode", GE_CMD_BLENDMODE, CMD_FMT_BLENDMODE, GE_CMD_ALPHABLENDENABLE }, @@ -368,13 +369,19 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab break; case CMD_FMT_ALPHATEST: + case CMD_FMT_STENCILTEST: { - static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; + static const char *alphaTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; const u8 mask = (value >> 16) & 0xff; const u8 ref = (value >> 8) & 0xff; const u8 func = (value >> 0) & 0xff; if (func < (u8)ARRAY_SIZE(alphaTestFuncs)) { - swprintf(dest, L"pass if (a & %02x) %S (%02x & %02x)", mask, alphaTestFuncs[func], ref, mask); + if (info.fmt == CMD_FMT_ALPHATEST) { + swprintf(dest, L"pass if (a & %02x) %S (%02x & %02x)", mask, alphaTestFuncs[func], ref, mask); + } else if (info.fmt == CMD_FMT_STENCILTEST) { + // Stencil test is the other way around. + swprintf(dest, L"pass if (%02x & %02x) %S (a & %02x)", ref, mask, alphaTestFuncs[func], mask); + } } else { swprintf(dest, L"%06x", value); } @@ -383,7 +390,7 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab case CMD_FMT_ZTEST: { - static const char *zTestFuncs[] = { "NEVER", "ALWAYS", " == ", " != ", " < ", " <= ", " > ", " >= " }; + static const char *zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" }; if (value < (u32)ARRAY_SIZE(zTestFuncs)) { swprintf(dest, L"pass if src %S dst", zTestFuncs[value]); } else { From 1a3bba5ff7e388a073f3a2da8be6bf0db98c47e8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 00:49:36 -0700 Subject: [PATCH 4/6] Add a format for clearmode. --- Windows/GEDebugger/TabState.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 6681874283..cd242d904d 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -58,6 +58,7 @@ enum CmdFormatType { CMD_FMT_STENCILOP, CMD_FMT_BLENDMODE, CMD_FMT_FLAG, + CMD_FMT_CLEARMODE, }; struct TabStateRow { @@ -189,8 +190,7 @@ static const TabStateRow stateTextureRows[] = { }; static const TabStateRow stateSettingsRows[] = { - // TODO: Format. This is almost a flag... - { L"Clear mode", GE_CMD_CLEARMODE, CMD_FMT_HEX }, + { L"Clear mode", GE_CMD_CLEARMODE, CMD_FMT_CLEARMODE }, { L"Framebuffer", GE_CMD_FRAMEBUFPTR, CMD_FMT_PTRWIDTH, 0, GE_CMD_FRAMEBUFWIDTH }, { L"Framebuffer format", GE_CMD_FRAMEBUFPIXFORMAT, CMD_FMT_TEXFMT }, { L"Depthbuffer", GE_CMD_ZBUFPTR, CMD_FMT_PTRWIDTH, 0, GE_CMD_ZBUFWIDTH }, @@ -494,6 +494,26 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab } break; + case CMD_FMT_CLEARMODE: + if (value == 0) { + swprintf(dest, L"%d", value); + } else if ((value & ~(GE_CLEARMODE_ALL | 1)) == 0) { + const char *clearmodes[] = { + "1, write disabled", + "1, write color", + "1, write alpha/stencil", + "1, write color, alpha/stencil", + "1, write depth", + "1, write color, depth", + "1, write alpha/stencil, depth", + "1, write color, alpha/stencil, depth", + }; + swprintf(dest, L"%S", clearmodes[value >> 8]); + } else { + swprintf(dest, L"%06x", value); + } + break; + case CMD_FMT_FLAG: if ((value & ~1) == 0) { swprintf(dest, L"%d", value); From a90af9b519c936f451db9348739156e5510bb369 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 10:13:24 -0700 Subject: [PATCH 5/6] Format a few more state values. --- Windows/GEDebugger/TabState.cpp | 76 ++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 6 deletions(-) diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index cd242d904d..2a896af8c4 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -59,6 +59,9 @@ enum CmdFormatType { CMD_FMT_BLENDMODE, CMD_FMT_FLAG, CMD_FMT_CLEARMODE, + CMD_FMT_TEXFUNC, + CMD_FMT_TEXMODE, + CMD_FMT_LOGICOP, }; struct TabStateRow { @@ -155,8 +158,7 @@ static const TabStateRow stateTextureRows[] = { { L"Tex mapping mode", GE_CMD_TEXMAPMODE, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. { L"Tex shade srcs", GE_CMD_TEXSHADELS, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, - // TODO: Format. - { L"Tex mode", GE_CMD_TEXMODE, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, + { L"Tex mode", GE_CMD_TEXMODE, CMD_FMT_TEXMODE, GE_CMD_TEXTUREMAPENABLE }, { L"Tex format", GE_CMD_TEXFORMAT, CMD_FMT_TEXFMT, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. { L"Tex filtering", GE_CMD_TEXFILTER, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, @@ -166,8 +168,7 @@ static const TabStateRow stateTextureRows[] = { { L"Tex level/bias", GE_CMD_TEXLEVEL, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. { L"Tex lod slope", GE_CMD_TEXLODSLOPE, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, - // TODO: Format. - { L"Tex func", GE_CMD_TEXFUNC, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, + { L"Tex func", GE_CMD_TEXFUNC, CMD_FMT_TEXFUNC, GE_CMD_TEXTUREMAPENABLE }, { L"Tex env color", GE_CMD_TEXENVCOLOR, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, { L"CLUT", GE_CMD_CLUTADDR, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_CLUTADDRUPPER }, { L"CLUT format", GE_CMD_CLUTFORMAT, CMD_FMT_TEXFMT, GE_CMD_TEXTUREMAPENABLE }, @@ -215,8 +216,7 @@ static const TabStateRow stateSettingsRows[] = { { L"Alpha blend mode", GE_CMD_BLENDMODE, CMD_FMT_BLENDMODE, GE_CMD_ALPHABLENDENABLE }, { L"Blend color A", GE_CMD_BLENDFIXEDA, CMD_FMT_HEX, GE_CMD_ALPHABLENDENABLE }, { L"Blend color B", GE_CMD_BLENDFIXEDB, CMD_FMT_HEX, GE_CMD_ALPHABLENDENABLE }, - // TODO: Format. - { L"Logic Op", GE_CMD_LOGICOP, CMD_FMT_HEX, GE_CMD_LOGICOPENABLE }, + { L"Logic Op", GE_CMD_LOGICOP, CMD_FMT_LOGICOP, GE_CMD_LOGICOPENABLE }, { L"Fog 1", GE_CMD_FOG1, CMD_FMT_FLOAT24, GE_CMD_FOGENABLE }, { L"Fog 2", GE_CMD_FOG2, CMD_FMT_FLOAT24, GE_CMD_FOGENABLE }, { L"Fog color", GE_CMD_FOGCOLOR, CMD_FMT_HEX, GE_CMD_FOGENABLE }, @@ -514,6 +514,70 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab } break; + case CMD_FMT_TEXFUNC: + { + const char *texfuncs[] = { + "modulate", + "decal", + "blend", + "replace", + "add", + }; + const u8 func = (value >> 0) & 0xFF; + const u8 rgba = (value >> 8) & 0xFF; + const u8 colorDouble = (value >> 16) & 0xFF; + + if (rgba <= 1 && colorDouble <= 1 && func < (u8)ARRAY_SIZE(texfuncs)) { + swprintf(dest, L"%S, %S%S", texfuncs[func], rgba ? "RGBA" : "RGB", colorDouble ? ", color doubling" : ""); + } else { + swprintf(dest, L"%06x", value); + } + } + break; + + case CMD_FMT_TEXMODE: + { + const u8 swizzle = (value >> 0) & 0xFF; + const u8 clutLevels = (value >> 8) & 0xFF; + const u8 maxLevel = (value >> 16) & 0xFF; + + if (swizzle <= 1 && clutLevels <= 1 && maxLevel <= 7) { + swprintf(dest, L"%S%d levels%S", swizzle ? "swizzled, " : "", maxLevel + 1, clutLevels ? ", CLUT per level" : ""); + } else { + swprintf(dest, L"%06x", value); + } + } + break; + + case CMD_FMT_LOGICOP: + { + const char *logicOps[] = { + "clear", + "and", + "reverse and", + "copy", + "inverted and", + "noop", + "xor", + "or", + "negated or", + "equivalence", + "inverted", + "reverse or", + "inverted copy", + "inverted or", + "negated and", + "set", + }; + + if (value < ARRAY_SIZE(logicOps)) { + swprintf(dest, L"%S", logicOps[value]); + } else { + swprintf(dest, L"%06x", value); + } + } + break; + case CMD_FMT_FLAG: if ((value & ~1) == 0) { swprintf(dest, L"%d", value); From 991aa032736b065a580fbbe7e97ad5e748f24e30 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 13 Oct 2013 10:24:21 -0700 Subject: [PATCH 6/6] A few more texture related formats. --- GPU/GeDisasm.cpp | 5 +++- Windows/GEDebugger/TabState.cpp | 42 ++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index 4520a1676c..74325f698f 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -905,7 +905,10 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer) { break; case GE_CMD_TEXWRAP: - sprintf(buffer, "TexWrap %06x", data); + if (data & ~0x0101) + sprintf(buffer, "TexWrap %s s, %s t (extra %x)", data & 1 ? "clamp" : "wrap", data & 0x100 ? "clamp" : "wrap", data); + else + sprintf(buffer, "TexWrap %s s, %s t", data & 1 ? "clamp" : "wrap", data & 0x100 ? "clamp" : "wrap"); break; case GE_CMD_TEXLEVEL: diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 2a896af8c4..51bf7bb5f2 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -47,6 +47,7 @@ enum CmdFormatType { CMD_FMT_F16_XY, CMD_FMT_VERTEXTYPE, CMD_FMT_TEXFMT, + CMD_FMT_CLUTFMT, CMD_FMT_COLORTEST, CMD_FMT_ALPHATEST, CMD_FMT_STENCILTEST, @@ -62,6 +63,7 @@ enum CmdFormatType { CMD_FMT_TEXFUNC, CMD_FMT_TEXMODE, CMD_FMT_LOGICOP, + CMD_FMT_TEXWRAP, }; struct TabStateRow { @@ -162,8 +164,7 @@ static const TabStateRow stateTextureRows[] = { { L"Tex format", GE_CMD_TEXFORMAT, CMD_FMT_TEXFMT, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. { L"Tex filtering", GE_CMD_TEXFILTER, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, - // TODO: Format. - { L"Tex wrapping", GE_CMD_TEXWRAP, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, + { L"Tex wrapping", GE_CMD_TEXWRAP, CMD_FMT_TEXWRAP, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. { L"Tex level/bias", GE_CMD_TEXLEVEL, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, // TODO: Format. @@ -171,7 +172,7 @@ static const TabStateRow stateTextureRows[] = { { L"Tex func", GE_CMD_TEXFUNC, CMD_FMT_TEXFUNC, GE_CMD_TEXTUREMAPENABLE }, { L"Tex env color", GE_CMD_TEXENVCOLOR, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, { L"CLUT", GE_CMD_CLUTADDR, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_CLUTADDRUPPER }, - { L"CLUT format", GE_CMD_CLUTFORMAT, CMD_FMT_TEXFMT, GE_CMD_TEXTUREMAPENABLE }, + { L"CLUT format", GE_CMD_CLUTFORMAT, CMD_FMT_CLUTFMT, GE_CMD_TEXTUREMAPENABLE }, { L"Texture L0 addr", GE_CMD_TEXADDR0, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH0 }, { L"Texture L1 addr", GE_CMD_TEXADDR1, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH1 }, { L"Texture L2 addr", GE_CMD_TEXADDR2, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH2 }, @@ -355,6 +356,29 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab } break; + case CMD_FMT_CLUTFMT: + { + const char *clutformats[] = { + "BGR 5650", + "ABGR 1555", + "ABGR 4444", + "ABGR 8888", + }; + const u8 palette = (value >> 0) & 0xFF; + const u8 mask = (value >> 8) & 0xFF; + const u8 offset = (value >> 16) & 0xFF; + if (palette < (u8)ARRAY_SIZE(clutformats) && offset < 0x20) { + if (offset == 0) { + swprintf(dest, L"%S & %02x", clutformats[palette], mask); + } else { + swprintf(dest, L"%S & %02x, offset +%d", clutformats[palette], mask, offset); + } + } else { + swprintf(dest, L"%06x", value); + } + } + break; + case CMD_FMT_COLORTEST: { static const char *colorTests[] = {"NEVER", "ALWAYS", " == ", " != "}; @@ -578,6 +602,18 @@ void FormatStateRow(wchar_t *dest, const TabStateRow &info, u32 value, bool enab } break; + case CMD_FMT_TEXWRAP: + { + if ((value & ~0x0101) == 0) { + const bool clampS = (value & 0x0001) != 0; + const bool clampT = (value & 0x0100) != 0; + swprintf(dest, L"%S s, %S t", clampS ? "clamp" : "wrap", clampT ? "clamp" : "wrap"); + } else { + swprintf(dest, L"%06x", value); + } + } + break; + case CMD_FMT_FLAG: if ((value & ~1) == 0) { swprintf(dest, L"%d", value);