diff --git a/GPU/Common/GPUDebugInterface.cpp b/GPU/Common/GPUDebugInterface.cpp index 55dc644cd79c..7b6cd223e190 100644 --- a/GPU/Common/GPUDebugInterface.cpp +++ b/GPU/Common/GPUDebugInterface.cpp @@ -533,7 +533,7 @@ bool GEExpressionFunctions::parseReference(char *str, uint32_t &referenceIndex) // For now, let's just support the register bits directly. GECmdInfo info; if (GECmdInfoByName(str, info)) { - referenceIndex = info.reg; + referenceIndex = info.cmd; return true; } @@ -599,8 +599,8 @@ bool GEExpressionFunctions::parseFieldReference(const char *ref, const char *fie } for (const auto &entry : fieldNames) { - if (entry.fmt == info.fmt && strcasecmp(field, entry.name) == 0) { - referenceIndex = (info.reg << 12) | (uint32_t)entry.field; + if (entry.fmt == info.cmdFmt && strcasecmp(field, entry.name) == 0) { + referenceIndex = (info.cmd << 12) | (uint32_t)entry.field; return true; } } @@ -624,7 +624,7 @@ bool GEExpressionFunctions::parseSymbol(char *str, uint32_t &symbolValue) { uint32_t GEExpressionFunctions::getReferenceValue(uint32_t referenceIndex) { GPUgstate state = gpu_->GetGState(); if (referenceIndex < 0x100) { - GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex)).fmt; + GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex)).cmdFmt; uint32_t value = state.cmdmem[referenceIndex]; if (fmt == GECmdFormat::FLOAT) return value << 8; @@ -633,7 +633,7 @@ uint32_t GEExpressionFunctions::getReferenceValue(uint32_t referenceIndex) { if (referenceIndex >= (uint32_t)GEReferenceIndex::FIELD_START && referenceIndex <= (uint32_t)GEReferenceIndex::FIELD_END) { uint32_t value = state.cmdmem[referenceIndex >> 12] & 0x00FFFFFF; - GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex >> 12)).fmt; + GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex >> 12)).cmdFmt; return getFieldValue(fmt, GECmdField(referenceIndex & 0xFF), value); } @@ -898,14 +898,14 @@ uint32_t GEExpressionFunctions::getFieldValue(GECmdFormat fmt, GECmdField field, ExpressionType GEExpressionFunctions::getReferenceType(uint32_t referenceIndex) { if (referenceIndex < 0x100) { - GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex)).fmt; + GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex)).cmdFmt; if (fmt == GECmdFormat::FLOAT) return EXPR_TYPE_FLOAT; return EXPR_TYPE_UINT; } if (referenceIndex >= (uint32_t)GEReferenceIndex::FIELD_START && referenceIndex <= (uint32_t)GEReferenceIndex::FIELD_END) { - GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex >> 12)).fmt; + GECmdFormat fmt = GECmdInfoByCmd(GECommand(referenceIndex >> 12)).cmdFmt; return getFieldType(fmt, GECmdField(referenceIndex & 0xFF)); } diff --git a/GPU/Debugger/Breakpoints.h b/GPU/Debugger/Breakpoints.h index 0910a68e92f0..cdb3215abf86 100644 --- a/GPU/Debugger/Breakpoints.h +++ b/GPU/Debugger/Breakpoints.h @@ -17,6 +17,7 @@ #pragma once +#include #include "Common/CommonTypes.h" namespace GPUBreakpoints { diff --git a/GPU/Debugger/GECommandTable.cpp b/GPU/Debugger/GECommandTable.cpp index aa05978be876..3a08a8d19974 100644 --- a/GPU/Debugger/GECommandTable.cpp +++ b/GPU/Debugger/GECommandTable.cpp @@ -19,7 +19,9 @@ #include "Common/Common.h" #include "Common/Log.h" #include "GPU/Debugger/GECommandTable.h" +#include "GPU/Debugger/Breakpoints.h" #include "GPU/ge_constants.h" +#include "StringUtils.h" struct GECmdAlias { GECommand reg; @@ -393,7 +395,7 @@ static constexpr GECmdAlias geCmdAliases[] = { bool GECmdInfoByName(const char *name, GECmdInfo &result) { for (const GECmdInfo &info : geCmdInfo) { - if (strcasecmp(info.name, name) == 0) { + if (equalsNoCase(info.name, name)) { result = info; return true; } @@ -401,7 +403,7 @@ bool GECmdInfoByName(const char *name, GECmdInfo &result) { for (const GECmdAlias &entry : geCmdAliases) { for (const char *alias : entry.aliases) { - if (alias && strcasecmp(alias, name) == 0) { + if (alias && equalsNoCase(alias, name)) { result = GECmdInfoByCmd(entry.reg); return true; } @@ -411,7 +413,27 @@ bool GECmdInfoByName(const char *name, GECmdInfo &result) { return false; } -GECmdInfo GECmdInfoByCmd(GECommand reg) { +const GECmdInfo &GECmdInfoByCmd(GECommand reg) { _assert_msg_((reg & 0xFF) == reg, "Invalid reg"); return geCmdInfo[reg & 0xFF]; } + +bool ToggleBreakpoint(const GECmdInfo &info) { + using namespace GPUBreakpoints; + if (IsCmdBreakpoint(info.cmd)) { + RemoveCmdBreakpoint(info.cmd); + if (info.otherCmd) + RemoveCmdBreakpoint(info.otherCmd); + if (info.otherCmd2) + RemoveCmdBreakpoint(info.otherCmd2); + return false; + } + + AddCmdBreakpoint(info.cmd); + if (info.otherCmd) + AddCmdBreakpoint(info.otherCmd); + if (info.otherCmd2) + AddCmdBreakpoint(info.otherCmd2); + return true; +} + diff --git a/GPU/Debugger/GECommandTable.h b/GPU/Debugger/GECommandTable.h index 75af2ea662ea..4bee175885a9 100644 --- a/GPU/Debugger/GECommandTable.h +++ b/GPU/Debugger/GECommandTable.h @@ -18,6 +18,8 @@ #pragma once #include +#include + #include "GPU/ge_constants.h" enum class GECmdFormat { @@ -116,17 +118,18 @@ enum CmdFormatType { CMD_FMT_INTEGER = CMD_FMT_HEX, }; - struct GECmdInfo { - GECommand reg; - const char *name; // scripting / expression name - GECmdFormat fmt; - const char *uiName; // friendly name - CmdFormatType fmtType; + GECommand cmd; + std::string_view name; // scripting / expression name + GECmdFormat cmdFmt; + std::string_view uiName; // friendly name + CmdFormatType fmt; uint8_t enableCmd; uint8_t otherCmd; uint8_t otherCmd2; }; bool GECmdInfoByName(const char *name, GECmdInfo &info); -GECmdInfo GECmdInfoByCmd(GECommand reg); +const GECmdInfo &GECmdInfoByCmd(GECommand reg); + +bool ToggleBreakpoint(const GECmdInfo &info); diff --git a/GPU/Debugger/State.cpp b/GPU/Debugger/State.cpp index 7bb1ef2d284b..f424f980de48 100644 --- a/GPU/Debugger/State.cpp +++ b/GPU/Debugger/State.cpp @@ -8,179 +8,175 @@ #include "GPU/Common/VertexDecoderCommon.h" #include "Core/System.h" -const TabStateRow g_stateFlagsRows[] = { - { "Lighting enable", GE_CMD_LIGHTINGENABLE, CMD_FMT_FLAG }, - { "Light 0 enable", GE_CMD_LIGHTENABLE0, CMD_FMT_FLAG }, - { "Light 1 enable", GE_CMD_LIGHTENABLE1, CMD_FMT_FLAG }, - { "Light 2 enable", GE_CMD_LIGHTENABLE2, CMD_FMT_FLAG }, - { "Light 3 enable", GE_CMD_LIGHTENABLE3, CMD_FMT_FLAG }, - { "Depth clamp enable", GE_CMD_DEPTHCLAMPENABLE, CMD_FMT_FLAG }, - { "Cullface enable", GE_CMD_CULLFACEENABLE, CMD_FMT_FLAG }, - { "Texture map enable", GE_CMD_TEXTUREMAPENABLE, CMD_FMT_FLAG }, - { "Fog enable", GE_CMD_FOGENABLE, CMD_FMT_FLAG }, - { "Dither enable", GE_CMD_DITHERENABLE, CMD_FMT_FLAG }, - { "Alpha blend enable", GE_CMD_ALPHABLENDENABLE, CMD_FMT_FLAG }, - { "Alpha test enable", GE_CMD_ALPHATESTENABLE, CMD_FMT_FLAG }, - { "Depth test enable", GE_CMD_ZTESTENABLE, CMD_FMT_FLAG }, - { "Stencil test enable", GE_CMD_STENCILTESTENABLE, CMD_FMT_FLAG }, - { "Antialias enable", GE_CMD_ANTIALIASENABLE, CMD_FMT_FLAG }, - { "Patch cull enable", GE_CMD_PATCHCULLENABLE, CMD_FMT_FLAG }, - { "Color test enable", GE_CMD_COLORTESTENABLE, CMD_FMT_FLAG }, - { "Logic op enable", GE_CMD_LOGICOPENABLE, CMD_FMT_FLAG }, - { "Depth write disable", GE_CMD_ZWRITEDISABLE, CMD_FMT_FLAG }, +const GECommand g_stateFlagsRows[] = { + GE_CMD_LIGHTINGENABLE, + GE_CMD_LIGHTENABLE0, + GE_CMD_LIGHTENABLE1, + GE_CMD_LIGHTENABLE2, + GE_CMD_LIGHTENABLE3, + GE_CMD_DEPTHCLAMPENABLE, + GE_CMD_CULLFACEENABLE, + GE_CMD_TEXTUREMAPENABLE, + GE_CMD_FOGENABLE, + GE_CMD_DITHERENABLE, + GE_CMD_ALPHABLENDENABLE, + GE_CMD_ALPHATESTENABLE, + GE_CMD_ZTESTENABLE, + GE_CMD_STENCILTESTENABLE, + GE_CMD_ANTIALIASENABLE, + GE_CMD_PATCHCULLENABLE, + GE_CMD_COLORTESTENABLE, + GE_CMD_LOGICOPENABLE, + GE_CMD_ZWRITEDISABLE, }; const size_t g_stateFlagsRowsSize = ARRAY_SIZE(g_stateFlagsRows); -const TabStateRow g_stateLightingRows[] = { - { "Ambient color", GE_CMD_AMBIENTCOLOR, CMD_FMT_HEX }, - { "Ambient alpha", GE_CMD_AMBIENTALPHA, CMD_FMT_HEX }, - { "Material update", GE_CMD_MATERIALUPDATE, CMD_FMT_MATERIALUPDATE }, - { "Material emissive", GE_CMD_MATERIALEMISSIVE, CMD_FMT_HEX }, - { "Material ambient", GE_CMD_MATERIALAMBIENT, CMD_FMT_HEX }, - { "Material diffuse", GE_CMD_MATERIALDIFFUSE, CMD_FMT_HEX }, - { "Material alpha", GE_CMD_MATERIALALPHA, CMD_FMT_HEX }, - { "Material specular", GE_CMD_MATERIALSPECULAR, CMD_FMT_HEX }, - { "Mat. specular coef", GE_CMD_MATERIALSPECULARCOEF, CMD_FMT_FLOAT24 }, - { "Reverse normals", GE_CMD_REVERSENORMAL, CMD_FMT_FLAG }, - { "Shade model", GE_CMD_SHADEMODE, CMD_FMT_SHADEMODEL }, - { "Light mode", GE_CMD_LIGHTMODE, CMD_FMT_LIGHTMODE, GE_CMD_LIGHTINGENABLE }, - { "Light type 0", GE_CMD_LIGHTTYPE0, CMD_FMT_LIGHTTYPE, GE_CMD_LIGHTENABLE0 }, - { "Light type 1", GE_CMD_LIGHTTYPE1, CMD_FMT_LIGHTTYPE, GE_CMD_LIGHTENABLE1 }, - { "Light type 2", GE_CMD_LIGHTTYPE2, CMD_FMT_LIGHTTYPE, GE_CMD_LIGHTENABLE2 }, - { "Light type 3", GE_CMD_LIGHTTYPE3, CMD_FMT_LIGHTTYPE, GE_CMD_LIGHTENABLE3 }, - { "Light pos 0", GE_CMD_LX0, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE0, GE_CMD_LY0, GE_CMD_LZ0 }, - { "Light pos 1", GE_CMD_LX1, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE1, GE_CMD_LY1, GE_CMD_LZ1 }, - { "Light pos 2", GE_CMD_LX2, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE2, GE_CMD_LY2, GE_CMD_LZ2 }, - { "Light pos 3", GE_CMD_LX3, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE3, GE_CMD_LY3, GE_CMD_LZ3 }, - { "Light dir 0", GE_CMD_LDX0, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE0, GE_CMD_LDY0, GE_CMD_LDZ0 }, - { "Light dir 1", GE_CMD_LDX1, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE1, GE_CMD_LDY1, GE_CMD_LDZ1 }, - { "Light dir 2", GE_CMD_LDX2, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE2, GE_CMD_LDY2, GE_CMD_LDZ2 }, - { "Light dir 3", GE_CMD_LDX3, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE3, GE_CMD_LDY3, GE_CMD_LDZ3 }, - { "Light att 0", GE_CMD_LKA0, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE0, GE_CMD_LKB0, GE_CMD_LKC0 }, - { "Light att 1", GE_CMD_LKA1, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE1, GE_CMD_LKB1, GE_CMD_LKC1 }, - { "Light att 2", GE_CMD_LKA2, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE2, GE_CMD_LKB2, GE_CMD_LKC2 }, - { "Light att 3", GE_CMD_LKA3, CMD_FMT_XYZ, GE_CMD_LIGHTENABLE3, GE_CMD_LKB3, GE_CMD_LKC3 }, - { "Lightspot coef 0", GE_CMD_LKS0, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE0 }, - { "Lightspot coef 1", GE_CMD_LKS1, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE1 }, - { "Lightspot coef 2", GE_CMD_LKS2, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE2 }, - { "Lightspot coef 3", GE_CMD_LKS3, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE3 }, - { "Light angle 0", GE_CMD_LKO0, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE0 }, - { "Light angle 1", GE_CMD_LKO1, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE1 }, - { "Light angle 2", GE_CMD_LKO2, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE2 }, - { "Light angle 3", GE_CMD_LKO3, CMD_FMT_FLOAT24, GE_CMD_LIGHTENABLE3 }, - { "Light ambient 0", GE_CMD_LAC0, CMD_FMT_HEX, GE_CMD_LIGHTENABLE0 }, - { "Light diffuse 0", GE_CMD_LDC0, CMD_FMT_HEX, GE_CMD_LIGHTENABLE0 }, - { "Light specular 0", GE_CMD_LSC0, CMD_FMT_HEX, GE_CMD_LIGHTENABLE0 }, - { "Light ambient 1", GE_CMD_LAC1, CMD_FMT_HEX, GE_CMD_LIGHTENABLE1 }, - { "Light diffuse 1", GE_CMD_LDC1, CMD_FMT_HEX, GE_CMD_LIGHTENABLE1 }, - { "Light specular 1", GE_CMD_LSC1, CMD_FMT_HEX, GE_CMD_LIGHTENABLE1 }, - { "Light ambient 2", GE_CMD_LAC2, CMD_FMT_HEX, GE_CMD_LIGHTENABLE2 }, - { "Light diffuse 2", GE_CMD_LDC2, CMD_FMT_HEX, GE_CMD_LIGHTENABLE2 }, - { "Light specular 2", GE_CMD_LSC2, CMD_FMT_HEX, GE_CMD_LIGHTENABLE2 }, - { "Light ambient 3", GE_CMD_LAC3, CMD_FMT_HEX, GE_CMD_LIGHTENABLE3 }, - { "Light diffuse 3", GE_CMD_LDC3, CMD_FMT_HEX, GE_CMD_LIGHTENABLE3 }, - { "Light specular 3", GE_CMD_LSC3, CMD_FMT_HEX, GE_CMD_LIGHTENABLE3 }, +const GECommand g_stateLightingRows[] = { + GE_CMD_AMBIENTCOLOR, + GE_CMD_AMBIENTALPHA, + GE_CMD_MATERIALUPDATE, + GE_CMD_MATERIALEMISSIVE, + GE_CMD_MATERIALAMBIENT, + GE_CMD_MATERIALDIFFUSE, + GE_CMD_MATERIALALPHA, + GE_CMD_MATERIALSPECULAR, + GE_CMD_MATERIALSPECULARCOEF, + GE_CMD_REVERSENORMAL, + GE_CMD_SHADEMODE, + GE_CMD_LIGHTMODE, + GE_CMD_LIGHTTYPE0, + GE_CMD_LIGHTTYPE1, + GE_CMD_LIGHTTYPE2, + GE_CMD_LIGHTTYPE3, + GE_CMD_LX0, + GE_CMD_LX1, + GE_CMD_LX2, + GE_CMD_LX3, + GE_CMD_LDX0, + GE_CMD_LDX1, + GE_CMD_LDX2, + GE_CMD_LDX3, + GE_CMD_LKA0, + GE_CMD_LKA1, + GE_CMD_LKA2, + GE_CMD_LKA3, + GE_CMD_LKS0, + GE_CMD_LKS1, + GE_CMD_LKS2, + GE_CMD_LKS3, + GE_CMD_LKO0, + GE_CMD_LKO1, + GE_CMD_LKO2, + GE_CMD_LKO3, + GE_CMD_LAC0, + GE_CMD_LDC0, + GE_CMD_LSC0, + GE_CMD_LAC1, + GE_CMD_LDC1, + GE_CMD_LSC1, + GE_CMD_LAC2, + GE_CMD_LDC2, + GE_CMD_LSC2, + GE_CMD_LAC3, + GE_CMD_LDC3, + GE_CMD_LSC3, }; const size_t g_stateLightingRowsSize = ARRAY_SIZE(g_stateLightingRows); -const TabStateRow g_stateTextureRows[] = { - { "Texture L0 addr", GE_CMD_TEXADDR0, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH0 }, - { "Texture L0 size", GE_CMD_TEXSIZE0, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Tex format", GE_CMD_TEXFORMAT, CMD_FMT_TEXFMT, GE_CMD_TEXTUREMAPENABLE }, - { "Tex CLUT", GE_CMD_CLUTADDR, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_CLUTADDRUPPER }, - { "Tex CLUT format", GE_CMD_CLUTFORMAT, CMD_FMT_CLUTFMT, GE_CMD_TEXTUREMAPENABLE }, - - { "Tex U scale", GE_CMD_TEXSCALEU, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE }, - { "Tex V scale", GE_CMD_TEXSCALEV, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE }, - { "Tex U offset", GE_CMD_TEXOFFSETU, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE }, - { "Tex V offset", GE_CMD_TEXOFFSETV, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE }, - { "Tex mapping mode", GE_CMD_TEXMAPMODE, CMD_FMT_TEXMAPMODE, GE_CMD_TEXTUREMAPENABLE }, - { "Tex shade srcs", GE_CMD_TEXSHADELS, CMD_FMT_TEXSHADELS, GE_CMD_TEXTUREMAPENABLE }, - { "Tex func", GE_CMD_TEXFUNC, CMD_FMT_TEXFUNC, GE_CMD_TEXTUREMAPENABLE }, - { "Tex env color", GE_CMD_TEXENVCOLOR, CMD_FMT_HEX, GE_CMD_TEXTUREMAPENABLE }, - { "Tex mode", GE_CMD_TEXMODE, CMD_FMT_TEXMODE, GE_CMD_TEXTUREMAPENABLE }, - { "Tex filtering", GE_CMD_TEXFILTER, CMD_FMT_TEXFILTER, GE_CMD_TEXTUREMAPENABLE }, - { "Tex wrapping", GE_CMD_TEXWRAP, CMD_FMT_TEXWRAP, GE_CMD_TEXTUREMAPENABLE }, - { "Tex level/bias", GE_CMD_TEXLEVEL, CMD_FMT_TEXLEVEL, GE_CMD_TEXTUREMAPENABLE }, - { "Tex lod slope", GE_CMD_TEXLODSLOPE, CMD_FMT_FLOAT24, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L1 addr", GE_CMD_TEXADDR1, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH1 }, - { "Texture L2 addr", GE_CMD_TEXADDR2, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH2 }, - { "Texture L3 addr", GE_CMD_TEXADDR3, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH3 }, - { "Texture L4 addr", GE_CMD_TEXADDR4, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH4 }, - { "Texture L5 addr", GE_CMD_TEXADDR5, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH5 }, - { "Texture L6 addr", GE_CMD_TEXADDR6, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH6 }, - { "Texture L7 addr", GE_CMD_TEXADDR7, CMD_FMT_PTRWIDTH, GE_CMD_TEXTUREMAPENABLE, GE_CMD_TEXBUFWIDTH7 }, - { "Texture L1 size", GE_CMD_TEXSIZE1, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L2 size", GE_CMD_TEXSIZE2, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L3 size", GE_CMD_TEXSIZE3, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L4 size", GE_CMD_TEXSIZE4, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L5 size", GE_CMD_TEXSIZE5, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L6 size", GE_CMD_TEXSIZE6, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, - { "Texture L7 size", GE_CMD_TEXSIZE7, CMD_FMT_TEXSIZE, GE_CMD_TEXTUREMAPENABLE }, +const GECommand g_stateTextureRows[] = { + GE_CMD_TEXADDR0, + GE_CMD_TEXSIZE0, + GE_CMD_TEXFORMAT, + GE_CMD_CLUTADDR, + GE_CMD_CLUTFORMAT, + GE_CMD_TEXSCALEU, + GE_CMD_TEXSCALEV, + GE_CMD_TEXOFFSETU, + GE_CMD_TEXOFFSETV, + GE_CMD_TEXMAPMODE, + GE_CMD_TEXSHADELS, + GE_CMD_TEXFUNC, + GE_CMD_TEXENVCOLOR, + GE_CMD_TEXMODE, + GE_CMD_TEXFILTER, + GE_CMD_TEXWRAP, + GE_CMD_TEXLEVEL, + GE_CMD_TEXLODSLOPE, + GE_CMD_TEXADDR1, + GE_CMD_TEXADDR2, + GE_CMD_TEXADDR3, + GE_CMD_TEXADDR4, + GE_CMD_TEXADDR5, + GE_CMD_TEXADDR6, + GE_CMD_TEXADDR7, + GE_CMD_TEXSIZE1, + GE_CMD_TEXSIZE2, + GE_CMD_TEXSIZE3, + GE_CMD_TEXSIZE4, + GE_CMD_TEXSIZE5, + GE_CMD_TEXSIZE6, + GE_CMD_TEXSIZE7, }; const size_t g_stateTextureRowsSize = ARRAY_SIZE(g_stateTextureRows); -const TabStateRow g_stateSettingsRows[] = { - { "Framebuffer", GE_CMD_FRAMEBUFPTR, CMD_FMT_PTRWIDTH, 0, GE_CMD_FRAMEBUFWIDTH }, - { "Framebuffer format", GE_CMD_FRAMEBUFPIXFORMAT, CMD_FMT_TEXFMT }, - { "Depthbuffer", GE_CMD_ZBUFPTR, CMD_FMT_PTRWIDTH, 0, GE_CMD_ZBUFWIDTH }, - { "Viewport Scale", GE_CMD_VIEWPORTXSCALE, CMD_FMT_XYZ, 0, GE_CMD_VIEWPORTYSCALE, GE_CMD_VIEWPORTZSCALE }, - { "Viewport Offset", GE_CMD_VIEWPORTXCENTER, CMD_FMT_XYZ, 0, GE_CMD_VIEWPORTYCENTER, GE_CMD_VIEWPORTZCENTER }, - { "Scissor", GE_CMD_SCISSOR1, CMD_FMT_XYXY, 0, GE_CMD_SCISSOR2 }, - { "Region", GE_CMD_REGION1, CMD_FMT_XYXY, 0, GE_CMD_REGION2 }, - { "Color test", GE_CMD_COLORTEST, CMD_FMT_COLORTEST, GE_CMD_COLORTESTENABLE, GE_CMD_COLORREF, GE_CMD_COLORTESTMASK }, - { "Alpha test", GE_CMD_ALPHATEST, CMD_FMT_ALPHATEST, GE_CMD_ALPHATESTENABLE }, - { "Clear mode", GE_CMD_CLEARMODE, CMD_FMT_CLEARMODE }, - { "Stencil test", GE_CMD_STENCILTEST, CMD_FMT_STENCILTEST, GE_CMD_STENCILTESTENABLE }, - { "Stencil test op", GE_CMD_STENCILOP, CMD_FMT_STENCILOP, GE_CMD_STENCILTESTENABLE }, - { "Depth test", GE_CMD_ZTEST, CMD_FMT_ZTEST, GE_CMD_ZTESTENABLE }, - { "RGB mask", GE_CMD_MASKRGB, CMD_FMT_HEX }, - { "Stencil/alpha mask", GE_CMD_MASKALPHA, CMD_FMT_HEX }, - { "Transfer src", GE_CMD_TRANSFERSRC, CMD_FMT_PTRWIDTH, 0, GE_CMD_TRANSFERSRCW }, - { "Transfer src pos", GE_CMD_TRANSFERSRCPOS, CMD_FMT_XY }, - { "Transfer dst", GE_CMD_TRANSFERDST, CMD_FMT_PTRWIDTH, 0, GE_CMD_TRANSFERDSTW }, - { "Transfer dst pos", GE_CMD_TRANSFERDSTPOS, CMD_FMT_XY }, - { "Transfer size", GE_CMD_TRANSFERSIZE, CMD_FMT_XYPLUS1 }, - { "Vertex type", GE_CMD_VERTEXTYPE, CMD_FMT_VERTEXTYPE }, - { "Offset addr", GE_CMD_OFFSETADDR, CMD_FMT_OFFSETADDR }, - { "Vertex addr", GE_CMD_VADDR, CMD_FMT_VADDR }, - { "Index addr", GE_CMD_IADDR, CMD_FMT_IADDR }, - { "Min Z", GE_CMD_MINZ, CMD_FMT_HEX }, - { "Max Z", GE_CMD_MAXZ, CMD_FMT_HEX }, - { "Offset", GE_CMD_OFFSETX, CMD_FMT_F16_XY, 0, GE_CMD_OFFSETY }, - { "Cull mode", GE_CMD_CULL, CMD_FMT_CULL, GE_CMD_CULLFACEENABLE }, - { "Alpha blend mode", GE_CMD_BLENDMODE, CMD_FMT_BLENDMODE, GE_CMD_ALPHABLENDENABLE }, - { "Blend color A", GE_CMD_BLENDFIXEDA, CMD_FMT_HEX, GE_CMD_ALPHABLENDENABLE }, - { "Blend color B", GE_CMD_BLENDFIXEDB, CMD_FMT_HEX, GE_CMD_ALPHABLENDENABLE }, - { "Logic Op", GE_CMD_LOGICOP, CMD_FMT_LOGICOP, GE_CMD_LOGICOPENABLE }, - { "Fog 1", GE_CMD_FOG1, CMD_FMT_FLOAT24, GE_CMD_FOGENABLE }, - { "Fog 2", GE_CMD_FOG2, CMD_FMT_FLOAT24, GE_CMD_FOGENABLE }, - { "Fog color", GE_CMD_FOGCOLOR, CMD_FMT_HEX, GE_CMD_FOGENABLE }, - { "Morph Weight 0", GE_CMD_MORPHWEIGHT0, CMD_FMT_FLOAT24 }, - { "Morph Weight 1", GE_CMD_MORPHWEIGHT1, CMD_FMT_FLOAT24 }, - { "Morph Weight 2", GE_CMD_MORPHWEIGHT2, CMD_FMT_FLOAT24 }, - { "Morph Weight 3", GE_CMD_MORPHWEIGHT3, CMD_FMT_FLOAT24 }, - { "Morph Weight 4", GE_CMD_MORPHWEIGHT4, CMD_FMT_FLOAT24 }, - { "Morph Weight 5", GE_CMD_MORPHWEIGHT5, CMD_FMT_FLOAT24 }, - { "Morph Weight 6", GE_CMD_MORPHWEIGHT6, CMD_FMT_FLOAT24 }, - { "Morph Weight 7", GE_CMD_MORPHWEIGHT7, CMD_FMT_FLOAT24 }, - // TODO: Format? - { "Patch division", GE_CMD_PATCHDIVISION, CMD_FMT_HEX }, - { "Patch primitive", GE_CMD_PATCHPRIMITIVE, CMD_FMT_PATCHPRIMITIVE }, - // TODO: Format? - { "Patch facing", GE_CMD_PATCHFACING, CMD_FMT_HEX, GE_CMD_PATCHCULLENABLE }, - { "Dither 0", GE_CMD_DITH0, CMD_FMT_HEX, GE_CMD_DITHERENABLE }, - { "Dither 1", GE_CMD_DITH1, CMD_FMT_HEX, GE_CMD_DITHERENABLE }, - { "Dither 2", GE_CMD_DITH2, CMD_FMT_HEX, GE_CMD_DITHERENABLE }, - { "Dither 3", GE_CMD_DITH3, CMD_FMT_HEX, GE_CMD_DITHERENABLE }, - { "Imm vertex XY", GE_CMD_VSCX, CMD_FMT_F16_XY, 0, GE_CMD_VSCY }, - { "Imm vertex Z", GE_CMD_VSCZ, CMD_FMT_HEX }, - { "Imm vertex tex STQ", GE_CMD_VTCS, CMD_FMT_XYZ, 0, GE_CMD_VTCT, GE_CMD_VTCQ }, - { "Imm vertex color0", GE_CMD_VCV, CMD_FMT_HEX }, - { "Imm vertex color1", GE_CMD_VSCV, CMD_FMT_HEX }, - { "Imm vertex fog", GE_CMD_VFC, CMD_FMT_HEX }, - // TODO: Format? - { "Imm vertex prim", GE_CMD_VAP, CMD_FMT_HEX }, +const GECommand g_stateSettingsRows[] = { + GE_CMD_FRAMEBUFPTR, + GE_CMD_FRAMEBUFPIXFORMAT, + GE_CMD_ZBUFPTR, + GE_CMD_VIEWPORTXSCALE, + GE_CMD_VIEWPORTXCENTER, + GE_CMD_SCISSOR1, + GE_CMD_REGION1, + GE_CMD_COLORTEST, + GE_CMD_ALPHATEST, + GE_CMD_CLEARMODE, + GE_CMD_STENCILTEST, + GE_CMD_STENCILOP, + GE_CMD_ZTEST, + GE_CMD_MASKRGB, + GE_CMD_MASKALPHA, + GE_CMD_TRANSFERSRC, + GE_CMD_TRANSFERSRCPOS, + GE_CMD_TRANSFERDST, + GE_CMD_TRANSFERDSTPOS, + GE_CMD_TRANSFERSIZE, + GE_CMD_VERTEXTYPE, + GE_CMD_OFFSETADDR, + GE_CMD_VADDR, + GE_CMD_IADDR, + GE_CMD_MINZ, + GE_CMD_MAXZ, + GE_CMD_OFFSETX, + GE_CMD_CULL, + GE_CMD_BLENDMODE, + GE_CMD_BLENDFIXEDA, + GE_CMD_BLENDFIXEDB, + GE_CMD_LOGICOP, + GE_CMD_FOG1, + GE_CMD_FOG2, + GE_CMD_FOGCOLOR, + GE_CMD_MORPHWEIGHT0, + GE_CMD_MORPHWEIGHT1, + GE_CMD_MORPHWEIGHT2, + GE_CMD_MORPHWEIGHT3, + GE_CMD_MORPHWEIGHT4, + GE_CMD_MORPHWEIGHT5, + GE_CMD_MORPHWEIGHT6, + GE_CMD_MORPHWEIGHT7, + GE_CMD_PATCHDIVISION, + GE_CMD_PATCHPRIMITIVE, + GE_CMD_PATCHFACING, + GE_CMD_DITH0, + GE_CMD_DITH1, + GE_CMD_DITH2, + GE_CMD_DITH3, + GE_CMD_VSCX, + GE_CMD_VSCZ, + GE_CMD_VTCS, + GE_CMD_VCV, + GE_CMD_VSCV, + GE_CMD_VFC, + GE_CMD_VAP, }; const size_t g_stateSettingsRowsSize = ARRAY_SIZE(g_stateSettingsRows); diff --git a/GPU/Debugger/State.h b/GPU/Debugger/State.h index e2380fe997db..916c568b14e5 100644 --- a/GPU/Debugger/State.h +++ b/GPU/Debugger/State.h @@ -24,19 +24,10 @@ enum VertexListCols { class GPUDebugInterface; -struct TabStateRow { - std::string_view title; - uint8_t cmd; - CmdFormatType fmt; - uint8_t enableCmd; - uint8_t otherCmd; - uint8_t otherCmd2; -}; - -extern const TabStateRow g_stateFlagsRows[]; -extern const TabStateRow g_stateLightingRows[]; -extern const TabStateRow g_stateTextureRows[]; -extern const TabStateRow g_stateSettingsRows[]; +extern const GECommand g_stateFlagsRows[]; +extern const GECommand g_stateLightingRows[]; +extern const GECommand g_stateTextureRows[]; +extern const GECommand g_stateSettingsRows[]; extern const size_t g_stateFlagsRowsSize; extern const size_t g_stateLightingRowsSize; extern const size_t g_stateTextureRowsSize; diff --git a/GPU/ge_constants.h b/GPU/ge_constants.h index 80db78dfac70..1d123e162093 100644 --- a/GPU/ge_constants.h +++ b/GPU/ge_constants.h @@ -19,7 +19,7 @@ #include -enum GECommand { +enum GECommand : uint8_t { GE_CMD_NOP = 0, GE_CMD_VADDR = 0x1, GE_CMD_IADDR = 0x2, diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index ad2a17f4ba88..c40c2fc1c337 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -12,6 +12,7 @@ #include "Core/HW/Display.h" #include "Common/StringUtils.h" #include "GPU/Debugger/State.h" +#include "GPU/Debugger/GECommandTable.h" #include "GPU/Debugger/Breakpoints.h" #include "GPU/Debugger/Debugger.h" #include "GPU/GPUState.h" @@ -337,7 +338,7 @@ void DrawGeStateWindow(ImConfig &cfg, GPUDebugInterface *gpuDebug) { return; } if (ImGui::BeginTabBar("GeRegs", ImGuiTabBarFlags_None)) { - auto buildStateTab = [&](const char *tabName, const TabStateRow *rows, size_t numRows) { + auto buildStateTab = [&](const char *tabName, const GECommand *rows, size_t numRows) { if (ImGui::BeginTabItem(tabName)) { if (ImGui::BeginTable("fpr", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { ImGui::TableSetupColumn("bkpt", ImGuiTableColumnFlags_WidthFixed); @@ -345,14 +346,15 @@ void DrawGeStateWindow(ImConfig &cfg, GPUDebugInterface *gpuDebug) { ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthStretch); for (size_t i = 0; i < numRows; i++) { + const GECmdInfo &info = GECmdInfoByCmd(rows[i]); + ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::Text("-"); // breakpoint ImGui::TableNextColumn(); - ImGui::TextUnformatted(rows[i].title.data(), rows[i].title.data() + rows[i].title.size()); + ImGui::TextUnformatted(info.uiName.data(), info.uiName.data() + info.uiName.size()); ImGui::TableNextColumn(); char temp[256]; - auto &info = rows[i]; const bool enabled = info.enableCmd == 0 || (gstate.cmdmem[info.enableCmd] & 1) == 1; const u32 value = gstate.cmdmem[info.cmd] & 0xFFFFFF; diff --git a/Windows/GEDebugger/TabState.cpp b/Windows/GEDebugger/TabState.cpp index 54176cc5da0c..ecb9b9f30c6b 100644 --- a/Windows/GEDebugger/TabState.cpp +++ b/Windows/GEDebugger/TabState.cpp @@ -59,38 +59,19 @@ enum StateValuesCols { STATEVALUES_COL_VALUE, }; -static std::vector watchList; +static std::vector watchList; -static void ToggleWatchList(const TabStateRow &info) { +static void ToggleWatchList(const GECommand cmd) { for (size_t i = 0; i < watchList.size(); ++i) { - if (watchList[i].cmd == info.cmd) { + if (watchList[i] == cmd) { watchList.erase(watchList.begin() + i); return; } } - - watchList.push_back(info); -} - -static bool ToggleBreakpoint(const TabStateRow &info) { - if (IsCmdBreakpoint(info.cmd)) { - RemoveCmdBreakpoint(info.cmd); - if (info.otherCmd) - RemoveCmdBreakpoint(info.otherCmd); - if (info.otherCmd2) - RemoveCmdBreakpoint(info.otherCmd2); - return false; - } - - AddCmdBreakpoint(info.cmd); - if (info.otherCmd) - AddCmdBreakpoint(info.otherCmd); - if (info.otherCmd2) - AddCmdBreakpoint(info.otherCmd2); - return true; + watchList.push_back(cmd); } -bool PromptStateValue(const TabStateRow &info, HWND hparent, const char *title, u32 &value) { +bool PromptStateValue(const GECmdInfo &info, HWND hparent, const char *title, u32 &value) { wchar_t wtitle[1024]; ConvertUTF8ToWString(wtitle, ARRAY_SIZE(wtitle), title); @@ -117,7 +98,7 @@ bool PromptStateValue(const TabStateRow &info, HWND hparent, const char *title, return InputBox_GetHex(GetModuleHandle(NULL), hparent, wtitle, value, value); } -CtrlStateValues::CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd) +CtrlStateValues::CtrlStateValues(const GECommand *rows, int rowCount, HWND hwnd) : GenericListControl(hwnd, stateValuesListDef), rows_(rows), rowCount_(rowCount) { SetIconList(12, 12, { (HICON)LoadIcon(GetModuleHandle(nullptr), (LPCWSTR)IDI_BREAKPOINT_SMALL) }); @@ -135,9 +116,11 @@ void CtrlStateValues::GetColumnText(wchar_t *dest, size_t destSize, int row, int break; case STATEVALUES_COL_NAME: - ConvertUTF8ToWString(dest, destSize, rows_[row].title); + { + ConvertUTF8ToWString(dest, destSize, GECmdInfoByCmd(rows_[row]).uiName); break; - + } + case STATEVALUES_COL_VALUE: { if (!gpuDebug) { @@ -145,7 +128,7 @@ void CtrlStateValues::GetColumnText(wchar_t *dest, size_t destSize, int row, int break; } - const auto info = rows_[row]; + const auto info = GECmdInfoByCmd(rows_[row]); const auto state = gpuDebug->GetGState(); const bool enabled = info.enableCmd == 0 || (state.cmdmem[info.enableCmd] & 1) == 1; const u32 value = state.cmdmem[info.cmd] & 0xFFFFFF; @@ -164,7 +147,7 @@ void CtrlStateValues::OnDoubleClick(int row, int column) { return; } - const auto info = rows_[row]; + const GECmdInfo &info = GECmdInfoByCmd(rows_[row]); if (column == STATEVALUES_COL_BREAKPOINT) { bool proceed = true; @@ -192,21 +175,21 @@ void CtrlStateValues::OnDoubleClick(int row, int column) { const auto state = gpuDebug->GetGState(); u32 newValue = state.cmdmem[info.cmd] & 0x00FFFFFF; - snprintf(title, sizeof(title), "New value for %.*s", (int)info.title.size(), info.title.data()); + snprintf(title, sizeof(title), "New value for %.*s", (int)info.uiName.size(), info.uiName.data()); if (PromptStateValue(info, GetHandle(), title, newValue)) { newValue |= state.cmdmem[info.cmd] & 0xFF000000; SetCmdValue(newValue); if (info.otherCmd) { newValue = state.cmdmem[info.otherCmd] & 0x00FFFFFF; - snprintf(title, sizeof(title), "New value for %.*s (secondary)", (int)info.title.size(), info.title.data()); + snprintf(title, sizeof(title), "New value for %.*s (secondary)", (int)info.uiName.size(), info.uiName.data()); if (PromptStateValue(info, GetHandle(), title, newValue)) { newValue |= state.cmdmem[info.otherCmd] & 0xFF000000; SetCmdValue(newValue); if (info.otherCmd2) { newValue = state.cmdmem[info.otherCmd2] & 0x00FFFFFF; - snprintf(title, sizeof(title), "New value for %.*s (tertiary)", (int)info.title.size(), info.title.data()); + snprintf(title, sizeof(title), "New value for %.*s (tertiary)", (int)info.uiName.size(), info.uiName.data()); if (PromptStateValue(info, GetHandle(), title, newValue)) { newValue |= state.cmdmem[info.otherCmd2] & 0xFF000000; SetCmdValue(newValue); @@ -225,7 +208,9 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) { return; } - const auto info = rows_[row]; + const GECommand cmd = rows_[row]; + const GECmdInfo &info = GECmdInfoByCmd(cmd); + const auto state = gpuDebug->GetGState(); POINT screenPt(point); @@ -292,7 +277,7 @@ void CtrlStateValues::OnRightClick(int row, int column, const POINT &point) { break; case ID_GEDBG_WATCH: - ToggleWatchList(info); + ToggleWatchList(cmd); SendMessage(GetParent(GetParent(GetHandle())), WM_GEDBG_UPDATE_WATCH, 0, 0); break; } @@ -314,7 +299,7 @@ void CtrlStateValues::SetCmdValue(u32 op) { bool CtrlStateValues::RowValuesChanged(int row) { _assert_(gpuDebug != nullptr && row >= 0 && row < rowCount_); - const auto info = rows_[row]; + const auto &info = GECmdInfoByCmd(rows_[row]); const auto state = gpuDebug->GetGState(); const auto lastState = GPUStepping::LastState(); @@ -328,7 +313,7 @@ bool CtrlStateValues::RowValuesChanged(int row) { return false; } -void CtrlStateValues::PromptBreakpointCond(const TabStateRow &info) { +void CtrlStateValues::PromptBreakpointCond(const GECmdInfo &info) { std::string expression; GPUBreakpoints::GetCmdBreakpointCond(info.cmd, &expression); if (!InputBox_GetString(GetModuleHandle(NULL), GetHandle(), L"Expression", expression, expression)) @@ -346,7 +331,7 @@ void CtrlStateValues::PromptBreakpointCond(const TabStateRow &info) { } -TabStateValues::TabStateValues(const TabStateRow *rows, size_t rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent) +TabStateValues::TabStateValues(const GECommand *rows, size_t rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent) : Dialog(dialogID, _hInstance, _hParent) { values = new CtrlStateValues(rows, (int)rowCount, GetDlgItem(m_hDlg, IDC_GEDBG_VALUES)); } diff --git a/Windows/GEDebugger/TabState.h b/Windows/GEDebugger/TabState.h index 61428ac450dd..64c7da4eec8e 100644 --- a/Windows/GEDebugger/TabState.h +++ b/Windows/GEDebugger/TabState.h @@ -20,14 +20,16 @@ #include "Windows/W32Util/DialogManager.h" #include "Windows/W32Util/Misc.h" +#include "GPU/Debugger/GECommandTable.h" + struct TabStateRow; class CtrlStateValues: public GenericListControl { public: - CtrlStateValues(const TabStateRow *rows, int rowCount, HWND hwnd); + CtrlStateValues(const GECommand *rows, int rowCount, HWND hwnd); // Used by watch. - void UpdateRows(const TabStateRow *rows, int rowCount) { + void UpdateRows(const GECommand *rows, int rowCount) { rows_ = rows; rowCount_ = rowCount; } @@ -47,15 +49,15 @@ class CtrlStateValues: public GenericListControl { private: bool RowValuesChanged(int row); void SetCmdValue(u32 op); - void PromptBreakpointCond(const TabStateRow &info); + void PromptBreakpointCond(const GECmdInfo &info); - const TabStateRow *rows_; + const GECommand *rows_; int rowCount_; }; class TabStateValues : public Dialog { public: - TabStateValues(const TabStateRow *rows, size_t rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent); + TabStateValues(const GECommand *rows, size_t rowCount, LPCSTR dialogID, HINSTANCE _hInstance, HWND _hParent); ~TabStateValues(); void Update() override {