Extract FormatStateRow() from the Win32 GE debugger to GPU/Debugger/Registers

This commit is contained in:
Henrik Rydgård committed 2024-12-05 10:07:29 +01:00
1 parent 0c524b712e
commit 21997784bf
23 files changed
+927 -807

No files matched your search

+2
View File
@@ -1970,6 +1970,8 @@ set(GPU_SOURCES
GPU/Debugger/Record.cpp
GPU/Debugger/Record.h
GPU/Debugger/RecordFormat.h
GPU/Debugger/State.cpp
GPU/Debugger/State.h
GPU/Debugger/Stepping.cpp
GPU/Debugger/Stepping.h
GPU/ge_constants.h
+532
View File
@@ -0,0 +1,532 @@
#include <cstdio>
#include "Common/Common.h"
#include "GPU/Debugger/State.h"
#include "GPU/GPU.h"
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/GeDisasm.h"
void FormatStateRow(GPUDebugInterface *gpudebug, char *dest, size_t destSize, CmdFormatType fmt, u32 value, bool enabled, u32 otherValue, u32 otherValue2) {
switch (fmt) {
case CMD_FMT_HEX:
snprintf(dest, destSize, "%06x", value);
break;
case CMD_FMT_NUM:
snprintf(dest, destSize, "%d", value);
break;
case CMD_FMT_FLOAT24:
snprintf(dest, destSize, "%f", getFloat24(value));
break;
case CMD_FMT_PTRWIDTH:
value |= (otherValue & 0x00FF0000) << 8;
otherValue &= 0xFFFF;
snprintf(dest, destSize, "%08x, w=%d", value, otherValue);
break;
case CMD_FMT_XY:
{
int x = value & 0x3FF;
int y = value >> 10;
snprintf(dest, destSize, "%d,%d", x, y);
}
break;
case CMD_FMT_XYPLUS1:
{
int x = value & 0x3FF;
int y = value >> 10;
snprintf(dest, destSize, "%d,%d", x + 1, y + 1);
}
break;
case CMD_FMT_XYXY:
{
int x1 = value & 0x3FF;
int y1 = value >> 10;
int x2 = otherValue & 0x3FF;
int y2 = otherValue >> 10;
snprintf(dest, destSize, "%d,%d - %d,%d", x1, y1, x2, y2);
}
break;
case CMD_FMT_XYZ:
{
float x = getFloat24(value);
float y = getFloat24(otherValue);
float z = getFloat24(otherValue2);
snprintf(dest, destSize, "%f, %f, %f", x, y, z);
}
break;
case CMD_FMT_TEXSIZE:
{
int w = 1 << (value & 0x1f);
int h = 1 << ((value >> 8) & 0x1f);
snprintf(dest, destSize, "%dx%d", w, h);
}
break;
case CMD_FMT_F16_XY:
{
float x = (float)value / 16.0f;
float y = (float)otherValue / 16.0f;
snprintf(dest, destSize, "%fx%f", x, y);
}
break;
case CMD_FMT_VERTEXTYPE:
{
char buffer[256];
GeDescribeVertexType(value, buffer);
snprintf(dest, destSize, "%s", buffer);
}
break;
case CMD_FMT_TEXFMT:
{
static const char *texformats[] = {
"5650",
"5551",
"4444",
"8888",
"CLUT4",
"CLUT8",
"CLUT16",
"CLUT32",
"DXT1",
"DXT3",
"DXT5",
};
if (value < (u32)ARRAY_SIZE(texformats)) {
snprintf(dest, destSize, "%s", texformats[value]);
} else if ((value & 0xF) < (u32)ARRAY_SIZE(texformats)) {
snprintf(dest, destSize, "%s (extra bits %06x)", texformats[value & 0xF], value & ~0xF);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_CLUTFMT:
{
const char *clutformats[] = {
"BGR 5650",
"ABGR 1555",
"ABGR 4444",
"ABGR 8888",
};
const u8 palette = (value >> 0) & 3;
const u8 shift = (value >> 2) & 0x3F;
const u8 mask = (value >> 8) & 0xFF;
const u8 offset = (value >> 16) & 0xFF;
if (offset < 0x20 && shift < 0x20) {
if (offset == 0 && shift == 0) {
snprintf(dest, destSize, "%s ind & %02x", clutformats[palette], mask);
} else {
snprintf(dest, destSize, "%s (ind >> %d) & %02x, offset +%d", clutformats[palette], shift, mask, offset);
}
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_COLORTEST:
{
static const char *colorTests[] = { "NEVER", "ALWAYS", " == ", " != " };
const u32 mask = otherValue2;
const u32 ref = otherValue;
if (value < (u32)ARRAY_SIZE(colorTests)) {
snprintf(dest, destSize, "pass if (c & %06x) %s (%06x & %06x)", mask, colorTests[value], ref, mask);
} else {
snprintf(dest, destSize, "%06x, ref=%06x, maks=%06x", value, ref, mask);
}
}
break;
case CMD_FMT_ALPHATEST:
case CMD_FMT_STENCILTEST:
{
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)) {
if (fmt == CMD_FMT_ALPHATEST) {
snprintf(dest, destSize, "pass if (a & %02x) %s (%02x & %02x)", mask, alphaTestFuncs[func], ref, mask);
} else if (fmt == CMD_FMT_STENCILTEST) {
// Stencil test is the other way around.
snprintf(dest, destSize, "pass if (%02x & %02x) %s (a & %02x)", ref, mask, alphaTestFuncs[func], mask);
}
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_ZTEST:
{
static const char *zTestFuncs[] = { "NEVER", "ALWAYS", "==", "!=", "<", "<=", ">", ">=" };
if (value < (u32)ARRAY_SIZE(zTestFuncs)) {
snprintf(dest, destSize, "pass if src %s dst", zTestFuncs[value]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_OFFSETADDR:
snprintf(dest, destSize, "%08x", gpuDebug->GetRelativeAddress(0));
break;
case CMD_FMT_VADDR:
snprintf(dest, destSize, "%08x", gpuDebug->GetVertexAddress());
break;
case CMD_FMT_IADDR:
snprintf(dest, destSize, "%08x", gpuDebug->GetIndexAddress());
break;
case CMD_FMT_MATERIALUPDATE:
{
static const char *materialTypes[] = {
"none",
"ambient",
"diffuse",
"ambient, diffuse",
"specular",
"ambient, specular",
"diffuse, specular",
"ambient, diffuse, specular",
};
if (value < (u32)ARRAY_SIZE(materialTypes)) {
snprintf(dest, destSize, "%s", materialTypes[value]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_SHADEMODEL:
if (value == 0) {
snprintf(dest, destSize, "flat");
} else if (value == 1) {
snprintf(dest, destSize, "gouraud");
} else {
snprintf(dest, destSize, "%06x", value);
}
break;
case CMD_FMT_STENCILOP:
{
static const char *stencilOps[] = { "KEEP", "ZERO", "REPLACE", "INVERT", "INCREMENT", "DECREMENT" };
const u8 sfail = (value >> 0) & 0xFF;
const u8 zfail = (value >> 8) & 0xFF;
const u8 pass = (value >> 16) & 0xFF;
const u8 totalValid = (u8)ARRAY_SIZE(stencilOps);
if (sfail < totalValid && zfail < totalValid && pass < totalValid) {
snprintf(dest, destSize, "fail=%s, pass/depthfail=%s, pass=%s", stencilOps[sfail], stencilOps[zfail], stencilOps[pass]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_BLENDMODE:
{
const char *blendModes[] = {
"add",
"subtract",
"reverse subtract",
"min",
"max",
"abs subtract",
};
const char *blendFactorsA[] = {
"dst",
"1.0 - dst",
"src.a",
"1.0 - src.a",
"dst.a",
"1.0 - dst.a",
"2.0 * src.a",
"1.0 - 2.0 * src.a",
"2.0 * dst.a",
"1.0 - 2.0 * dst.a",
"fixed",
};
const char *blendFactorsB[] = {
"src",
"1.0 - src",
"src.a",
"1.0 - src.a",
"dst.a",
"1.0 - dst.a",
"2.0 * src.a",
"1.0 - 2.0 * src.a",
"2.0 * dst.a",
"1.0 - 2.0 * dst.a",
"fixed",
};
const u8 blendFactorA = (value >> 0) & 0xF;
const u8 blendFactorB = (value >> 4) & 0xF;
const u32 blendMode = (value >> 8);
if (blendFactorA < (u8)ARRAY_SIZE(blendFactorsA) && blendFactorB < (u8)ARRAY_SIZE(blendFactorsB) && blendMode < (u32)ARRAY_SIZE(blendModes)) {
snprintf(dest, destSize, "%s: %s, %s", blendModes[blendMode], blendFactorsA[blendFactorA], blendFactorsB[blendFactorB]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_CLEARMODE:
if (value == 0) {
snprintf(dest, destSize, "%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",
};
snprintf(dest, destSize, "%s", clearmodes[value >> 8]);
} else {
snprintf(dest, destSize, "%06x", value);
}
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)) {
snprintf(dest, destSize, "%s, %s%s", texfuncs[func], rgba ? "RGBA" : "RGB", colorDouble ? ", color doubling" : "");
} else {
snprintf(dest, destSize, "%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) {
snprintf(dest, destSize, "%s%d levels%s", swizzle ? "swizzled, " : "", maxLevel + 1, clutLevels ? ", CLUT per level" : "");
} else {
snprintf(dest, destSize, "%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)) {
snprintf(dest, destSize, "%s", logicOps[value]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_TEXWRAP:
{
if ((value & ~0x0101) == 0) {
const bool clampS = (value & 0x0001) != 0;
const bool clampT = (value & 0x0100) != 0;
snprintf(dest, destSize, "%s s, %s t", clampS ? "clamp" : "wrap", clampT ? "clamp" : "wrap");
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_TEXLEVEL:
{
static const char *mipLevelModes[3] = {
"auto + bias",
"bias",
"slope + bias",
};
const int mipLevel = value & 0xFFFF;
const int biasFixed = (s8)(value >> 16);
const float bias = (float)biasFixed / 16.0f;
if (mipLevel == 0 || mipLevel == 1 || mipLevel == 2) {
snprintf(dest, destSize, "%s: %f", mipLevelModes[mipLevel], bias);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_TEXFILTER:
{
const char *textureFilters[] = {
"nearest",
"linear",
NULL,
NULL,
"nearest, mipmap nearest",
"linear, mipmap nearest",
"nearest, mipmap linear",
"linear, mipmap linear",
};
if ((value & ~0x0107) == 0 && textureFilters[value & 7] != NULL) {
const int min = (value & 0x0007) >> 0;
const int mag = (value & 0x0100) >> 8;
snprintf(dest, destSize, "min: %s, mag: %s", textureFilters[min], textureFilters[mag]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_TEXMAPMODE:
{
static const char *const uvGenModes[] = {
"tex coords",
"tex matrix",
"tex env map",
"unknown (tex coords?)",
};
static const char *const uvProjModes[] = {
"pos",
"uv",
"normalized normal",
"normal",
};
if ((value & ~0x0303) == 0) {
const int uvGen = (value & 0x0003) >> 0;
const int uvProj = (value & 0x0300) >> 8;
snprintf(dest, destSize, "gen: %s, proj: %s", uvGenModes[uvGen], uvProjModes[uvProj]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_TEXSHADELS:
if ((value & ~0x0303) == 0) {
const int sLight = (value & 0x0003) >> 0;
const int tLight = (value & 0x0300) >> 8;
snprintf(dest, destSize, "s: %d, t: %d", sLight, tLight);
} else {
snprintf(dest, destSize, "%06x", value);
}
break;
case CMD_FMT_LIGHTMODE:
if (value == 0) {
snprintf(dest, destSize, "mixed color");
} else if (value == 1) {
snprintf(dest, destSize, "separate specular");
} else {
snprintf(dest, destSize, "%06x", value);
}
break;
case CMD_FMT_LIGHTTYPE:
{
static const char * const lightComputations[] = {
"diffuse",
"diffuse + spec",
"pow(diffuse)",
"unknown (diffuse?)",
};
static const char * const lightTypes[] = {
"directional",
"point",
"spot",
"unknown (directional?)",
};
if ((value & ~0x0303) == 0) {
const int comp = (value & 0x0003) >> 0;
const int type = (value & 0x0300) >> 8;
snprintf(dest, destSize, "type: %s, comp: %s", lightTypes[type], lightComputations[comp]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_CULL:
if (value == 0) {
snprintf(dest, destSize, "front (CW)");
} else if (value == 1) {
snprintf(dest, destSize, "back (CCW)");
} else {
snprintf(dest, destSize, "%06x", value);
}
break;
case CMD_FMT_PATCHPRIMITIVE:
{
static const char * const patchPrims[] = {
"triangles",
"lines",
"points",
};
if (value < (u32)ARRAY_SIZE(patchPrims)) {
snprintf(dest, destSize, "%s", patchPrims[value]);
} else {
snprintf(dest, destSize, "%06x", value);
}
}
break;
case CMD_FMT_FLAG:
if ((value & ~1) == 0) {
snprintf(dest, destSize, "%d", value);
} else {
snprintf(dest, destSize, "%06x", value);
}
break;
default:
snprintf(dest, destSize, "BAD FORMAT %06x", value);
}
// TODO: Turn row grey or some such?
if (!enabled) {
strcat(dest, " (disabled)");
}
}
+54
View File
@@ -0,0 +1,54 @@
#pragma once
#include <string_view>
#include <cstdint>
#include "Common/CommonTypes.h"
// Extracted from Windows/GE Debugger/TabState.cpp
enum CmdFormatType {
CMD_FMT_HEX = 0,
CMD_FMT_NUM,
CMD_FMT_FLOAT24,
CMD_FMT_PTRWIDTH,
CMD_FMT_XY,
CMD_FMT_XYXY,
CMD_FMT_XYZ,
CMD_FMT_XYPLUS1,
CMD_FMT_TEXSIZE,
CMD_FMT_F16_XY,
CMD_FMT_VERTEXTYPE,
CMD_FMT_TEXFMT,
CMD_FMT_CLUTFMT,
CMD_FMT_COLORTEST,
CMD_FMT_ALPHATEST,
CMD_FMT_STENCILTEST,
CMD_FMT_ZTEST,
CMD_FMT_OFFSETADDR,
CMD_FMT_VADDR,
CMD_FMT_IADDR,
CMD_FMT_MATERIALUPDATE,
CMD_FMT_STENCILOP,
CMD_FMT_BLENDMODE,
CMD_FMT_FLAG,
CMD_FMT_CLEARMODE,
CMD_FMT_TEXFUNC,
CMD_FMT_TEXMODE,
CMD_FMT_LOGICOP,
CMD_FMT_TEXWRAP,
CMD_FMT_TEXLEVEL,
CMD_FMT_TEXFILTER,
CMD_FMT_TEXMAPMODE,
CMD_FMT_TEXSHADELS,
CMD_FMT_SHADEMODEL,
CMD_FMT_LIGHTMODE,
CMD_FMT_LIGHTTYPE,
CMD_FMT_CULL,
CMD_FMT_PATCHPRIMITIVE,
};
class GPUDebugInterface;
void FormatStateRow(GPUDebugInterface *debug, char *dest, size_t destSize, CmdFormatType fmt, u32 value, bool enabled, u32 otherValue, u32 otherValue2);
+2
View File
@@ -386,6 +386,7 @@
<ClInclude Include="Debugger\Playback.h" />
<ClInclude Include="Debugger\Record.h" />
<ClInclude Include="Debugger\RecordFormat.h" />
<ClInclude Include="Debugger\State.h" />
<ClInclude Include="Debugger\Stepping.h" />
<ClInclude Include="Directx9\FramebufferManagerDX9.h" />
<ClInclude Include="Directx9\GPU_DX9.h" />
@@ -533,6 +534,7 @@
<ClCompile Include="Debugger\GECommandTable.cpp" />
<ClCompile Include="Debugger\Playback.cpp" />
<ClCompile Include="Debugger\Record.cpp" />
<ClCompile Include="Debugger\State.cpp" />
<ClCompile Include="Debugger\Stepping.cpp" />
<ClCompile Include="Directx9\FramebufferManagerDX9.cpp" />
<ClCompile Include="Directx9\GPU_DX9.cpp" />
+6
View File
@@ -276,6 +276,9 @@
<ClInclude Include="Common\VertexDecoderHandwritten.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Debugger\State.h">
<Filter>Debugger</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math3D.cpp">
@@ -548,6 +551,9 @@
<ClCompile Include="Common\VertexDecoderHandwritten.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Debugger\State.cpp">
<Filter>Debugger</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="..\assets\shaders\tex_4xbrz.csh">
+23 -4
View File
@@ -1995,23 +1995,42 @@ bool GPUCommon::DescribeCodePtr(const u8 *ptr, std::string &name) {
}
void GPUCommon::DrawImGuiDebugger() {
// Proof of concept
if (ImGui::Button("Run")) {
if (ImGui::Button("Run/Resume")) {
Core_Resume();
}
ImGui::SameLine();
if (ImGui::Button("Next Tex")) {
ImGui::TextUnformatted("Break:");
ImGui::SameLine();
if (ImGui::Button("Frame")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::FRAME);
}
ImGui::SameLine();
if (ImGui::Button("Tex")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::TEX);
}
ImGui::SameLine();
if (ImGui::Button("Next Prim")) {
if (ImGui::Button("NonTex")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::NONTEX);
}
ImGui::SameLine();
if (ImGui::Button("Prim")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::PRIM);
}
ImGui::SameLine();
if (ImGui::Button("Draw")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::DRAW);
}
ImGui::SameLine();
if (ImGui::Button("Curve")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::CURVE);
}
ImGui::SameLine();
if (ImGui::Button("Single step")) {
GPUDebug::SetBreakNext(GPUDebug::BreakNext::OP);
}
// Let's display the current CLUT.
// First, let's list any active display lists.
ImGui::Text("Next list ID: %d", nextListID);
for (auto index : dlQueue) {
+5
View File
@@ -825,6 +825,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
}
if (ImGui::BeginMenu("Graphics")) {
ImGui::MenuItem("GE Debugger", nullptr, &cfg_.geDebuggerOpen);
ImGui::MenuItem("GE Registers", nullptr, &cfg_.geRegistersOpen);
ImGui::MenuItem("Display Output", nullptr, &cfg_.displayOpen);
ImGui::MenuItem("Textures", nullptr, &cfg_.texturesOpen);
ImGui::MenuItem("Framebuffers", nullptr, &cfg_.framebuffersOpen);
@@ -927,6 +928,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
if (cfg_.geDebuggerOpen) {
DrawGeDebuggerWindow(cfg_);
}
if (cfg_.geRegistersOpen) {
DrawGeRegistersWindow(cfg_);
}
}
void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, CoreState coreState) {
+1
View File
@@ -80,6 +80,7 @@ struct ImConfig {
bool audioChannelsOpen;
bool debugStatsOpen;
bool geDebuggerOpen;
bool geRegistersOpen;
// HLE explorer settings
// bool filterByUsed = true;
+24
View File
@@ -85,3 +85,27 @@ void DrawGeDebuggerWindow(ImConfig &cfg) {
ImGui::End();
}
// TODO: Separate window or merge into Ge debugger?
void DrawGeRegistersWindow(ImConfig &cfg) {
ImGui::SetNextWindowSize(ImVec2(300, 500), ImGuiCond_FirstUseEver);
if (!ImGui::Begin("Debug Stats", &cfg.geRegistersOpen)) {
ImGui::End();
return;
}
if (ImGui::BeginTabBar("GeRegs", ImGuiTabBarFlags_None)) {
if (ImGui::BeginTabItem("Control")) {
if (ImGui::BeginTable("fpr", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) {
ImGui::TableSetupColumn("bkpt", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("name", ImGuiTableColumnFlags_WidthFixed);
ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthStretch);
ImGui::EndTable();
}
ImGui::EndTabItem();
}
ImGui::EndTabBar();
}
ImGui::End();
}
+1
View File
@@ -12,6 +12,7 @@ void DrawTexturesWindow(ImConfig &cfg, TextureCacheCommon *textureCache);
void DrawDisplayWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);
void DrawDebugStatsWindow(ImConfig &cfg);
void DrawGeDebuggerWindow(ImConfig &cfg);
void DrawGeRegistersWindow(ImConfig &cfg);
class ImGeDebugger {
public:
+2
View File
@@ -151,6 +151,7 @@
<ClInclude Include="..\..\GPU\Debugger\Playback.h" />
<ClInclude Include="..\..\GPU\Debugger\Record.h" />
<ClInclude Include="..\..\GPU\Debugger\RecordFormat.h" />
<ClInclude Include="..\..\GPU\Debugger\Registers.h" />
<ClInclude Include="..\..\GPU\Debugger\Stepping.h" />
<ClInclude Include="..\..\GPU\GeDisasm.h" />
<ClInclude Include="..\..\GPU\ge_constants.h" />
@@ -219,6 +220,7 @@
<ClCompile Include="..\..\GPU\Debugger\GECommandTable.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Playback.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Record.cpp" />
<ClCompile Include="..\..\GPU\Debugger\State.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Stepping.cpp" />
<ClCompile Include="..\..\GPU\GeConstants.cpp" />
<ClCompile Include="..\..\GPU\GeDisasm.cpp" />
+50 -13
View File
@@ -31,12 +31,6 @@
<ClCompile Include="..\..\GPU\D3D11\ShaderManagerD3D11.cpp" />
<ClCompile Include="..\..\GPU\D3D11\StateMappingD3D11.cpp" />
<ClCompile Include="..\..\GPU\D3D11\TextureCacheD3D11.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Breakpoints.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Debugger.cpp" />
<ClCompile Include="..\..\GPU\Debugger\GECommandTable.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Playback.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Record.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Stepping.cpp" />
<ClCompile Include="..\..\GPU\GeConstants.cpp" />
<ClCompile Include="..\..\GPU\GeDisasm.cpp" />
<ClCompile Include="..\..\GPU\GPU.cpp" />
@@ -65,6 +59,27 @@
<ClCompile Include="..\..\GPU\GPUCommonHW.cpp" />
<ClCompile Include="..\..\GPU\Common\ReplacedTexture.cpp" />
<ClCompile Include="..\..\GPU\Common\TextureReplacer.cpp" />
<ClCompile Include="..\..\GPU\Debugger\Breakpoints.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\Debugger.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\State.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\Record.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\Playback.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\Stepping.cpp">
<Filter>Debugger</Filter>
</ClCompile>
<ClCompile Include="..\..\GPU\Debugger\GECommandTable.cpp">
<Filter>Debugger</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\GPU\Common\DepalettizeShaderCommon.h" />
@@ -95,13 +110,6 @@
<ClInclude Include="..\..\GPU\D3D11\ShaderManagerD3D11.h" />
<ClInclude Include="..\..\GPU\D3D11\StateMappingD3D11.h" />
<ClInclude Include="..\..\GPU\D3D11\TextureCacheD3D11.h" />
<ClInclude Include="..\..\GPU\Debugger\Breakpoints.h" />
<ClInclude Include="..\..\GPU\Debugger\Debugger.h" />
<ClInclude Include="..\..\GPU\Debugger\GECommandTable.h" />
<ClInclude Include="..\..\GPU\Debugger\Playback.h" />
<ClInclude Include="..\..\GPU\Debugger\Record.h" />
<ClInclude Include="..\..\GPU\Debugger\RecordFormat.h" />
<ClInclude Include="..\..\GPU\Debugger\Stepping.h" />
<ClInclude Include="..\..\GPU\GeDisasm.h" />
<ClInclude Include="..\..\GPU\ge_constants.h" />
<ClInclude Include="..\..\GPU\GPU.h" />
@@ -131,5 +139,34 @@
<ClInclude Include="..\..\GPU\GPUCommonHW.h" />
<ClInclude Include="..\..\GPU\Common\ReplacedTexture.h" />
<ClInclude Include="..\..\GPU\Common\TextureReplacer.h" />
<ClInclude Include="..\..\GPU\Debugger\Breakpoints.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\Debugger.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\Registers.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\Record.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\RecordFormat.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\Playback.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\Stepping.h">
<Filter>Debugger</Filter>
</ClInclude>
<ClInclude Include="..\..\GPU\Debugger\GECommandTable.h">
<Filter>Debugger</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Debugger">
<UniqueIdentifier>{49bcf7f6-518a-4ecd-af55-bda3a344efe7}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
+12 -16
View File
@@ -158,7 +158,7 @@ void CtrlThreadList::showMenu(int itemIndex, const POINT &pt)
}
}
void CtrlThreadList::GetColumnText(wchar_t* dest, int row, int col)
void CtrlThreadList::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
if (row < 0 || row >= (int)threads.size()) {
return;
@@ -457,7 +457,7 @@ int CtrlBreakpointList::getBreakpointIndex(int itemIndex, bool& isMemory)
return -1;
}
void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col)
void CtrlBreakpointList::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
if (!PSP_IsInited()) {
return;
@@ -512,10 +512,8 @@ void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col)
wsprintf(dest,L"0x%08X",mc.end-mc.start);
} else {
const std::string sym = g_symbolMap->GetLabelString(displayedBreakPoints_[index].addr);
if (!sym.empty())
{
std::wstring s = ConvertUTF8ToWString(sym);
wcscpy(dest,s.c_str());
if (!sym.empty()) {
ConvertUTF8ToWString(dest, destSize, sym);
} else {
wcscpy(dest,L"-");
}
@@ -529,8 +527,7 @@ void CtrlBreakpointList::GetColumnText(wchar_t* dest, int row, int col)
} else {
char temp[256];
disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp, sizeof(temp));
std::wstring s = ConvertUTF8ToWString(temp);
wcscpy(dest,s.c_str());
ConvertUTF8ToWString(dest, destSize, temp);
}
}
break;
@@ -669,7 +666,7 @@ bool CtrlStackTraceView::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, L
return false;
}
void CtrlStackTraceView::GetColumnText(wchar_t* dest, int row, int col)
void CtrlStackTraceView::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
// We should have emptied the list if g_symbolMap is nullptr, but apparently we don't,
// so let's have a sanity check here.
@@ -779,16 +776,15 @@ bool CtrlModuleList::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESU
return false;
}
void CtrlModuleList::GetColumnText(wchar_t* dest, int row, int col)
void CtrlModuleList::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
if (row < 0 || row >= (int)modules.size()) {
return;
}
switch (col)
{
switch (col) {
case ML_NAME:
wcscpy(dest,ConvertUTF8ToWString(modules[row].name).c_str());
ConvertUTF8ToWString(dest, destSize, modules[row].name);
break;
case ML_ADDRESS:
wsprintf(dest,L"%08X",modules[row].address);
@@ -887,7 +883,7 @@ bool CtrlWatchList::WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESUL
return false;
}
void CtrlWatchList::GetColumnText(wchar_t *dest, int row, int col) {
void CtrlWatchList::GetColumnText(wchar_t *dest, size_t destSize, int row, int col) {
const auto &watch = watches_[row];
switch (col) {
case WL_NAME:
@@ -913,12 +909,12 @@ void CtrlWatchList::GetColumnText(wchar_t *dest, int row, int col) {
break;
case WatchFormat::FLOAT:
memcpy(&valuef, &value, sizeof(valuef));
swprintf_s(dest, 255, L"%f", valuef);
swprintf_s(dest, destSize, L"%f", valuef);
break;
case WatchFormat::STR:
if (Memory::IsValidAddress(value)) {
uint32_t len = Memory::ValidSize(value, 255);
swprintf_s(dest, 255, L"%.*S", len, Memory::GetCharPointer(value));
swprintf_s(dest, destSize, L"%.*S", len, Memory::GetCharPointer(value));
} else {
wsprintf(dest, L"(0x%08X)", value);
}
+5 -5
View File
@@ -23,7 +23,7 @@ public:
const char* getCurrentThreadName();
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return (int) threads.size(); }
void OnDoubleClick(int itemIndex, int column) override;
void OnRightClick(int itemIndex, int column, const POINT &point) override;
@@ -40,7 +40,7 @@ public:
void reloadBreakpoints();
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return getTotalBreakpointCount(); }
void OnDoubleClick(int itemIndex, int column) override;
void OnRightClick(int itemIndex, int column, const POINT &point) override;
@@ -68,7 +68,7 @@ public:
void loadStackTrace();
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return (int)frames.size(); }
void OnDoubleClick(int itemIndex, int column) override;
private:
@@ -84,7 +84,7 @@ public:
void loadModules();
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return (int)modules.size(); }
void OnDoubleClick(int itemIndex, int column) override;
private:
@@ -99,7 +99,7 @@ public:
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return (int)watches_.size(); }
void OnRightClick(int itemIndex, int column, const POINT &point) override;
bool ListenRowPrePaint() override { return true; }
+2 -2
View File
@@ -34,7 +34,7 @@ CtrlDisplayListStack::CtrlDisplayListStack(HWND hwnd): GenericListControl(hwnd,d
Update();
}
void CtrlDisplayListStack::GetColumnText(wchar_t* dest, int row, int col)
void CtrlDisplayListStack::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
if (row < 0 || row >= (int)ARRAY_SIZE(list.stack)) {
return;
@@ -85,7 +85,7 @@ CtrlAllDisplayLists::CtrlAllDisplayLists(HWND hwnd): GenericListControl(hwnd,all
Update();
}
void CtrlAllDisplayLists::GetColumnText(wchar_t* dest, int row, int col)
void CtrlAllDisplayLists::GetColumnText(wchar_t* dest, size_t destSize, int row, int col)
{
if (row < 0 || row >= (int)lists.size()) {
return;
+2 -2
View File
@@ -18,7 +18,7 @@ public:
}
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override { return false; }
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return list.stackptr; }
void OnDoubleClick(int itemIndex, int column) override;
private:
@@ -35,7 +35,7 @@ public:
}
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override;
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return (int) lists.size(); }
void OnDoubleClick(int itemIndex, int column) override;
private:
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -36,7 +36,7 @@ protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) override {
return false;
}
void GetColumnText(wchar_t* dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override { return rowCount_; }
void OnDoubleClick(int row, int column) override;
void OnRightClick(int row, int column, const POINT& point) override;
+4 -4
View File
@@ -138,7 +138,7 @@ CtrlVertexList::~CtrlVertexList() {
delete decoder;
}
void CtrlVertexList::GetColumnText(wchar_t *dest, int row, int col) {
void CtrlVertexList::GetColumnText(wchar_t *dest, size_t destSize, int row, int col) {
if (row < 0 || row >= rowCount_ ) {
wcscpy(dest, L"Invalid");
return;
@@ -146,7 +146,7 @@ void CtrlVertexList::GetColumnText(wchar_t *dest, int row, int col) {
if (!indices.empty()) {
if (row >= (int)indices.size()) {
swprintf(dest, 255, L"Invalid indice %d", row);
swprintf(dest, destSize, L"Invalid indice %d", row);
return;
}
row = indices[row];
@@ -156,7 +156,7 @@ void CtrlVertexList::GetColumnText(wchar_t *dest, int row, int col) {
FormatVertColRaw(dest, row, col);
} else {
if (row >= (int)vertices.size()) {
swprintf(dest, 255, L"Invalid vertex %d", row);
swprintf(dest, destSize, L"Invalid vertex %d", row);
return;
}
@@ -461,7 +461,7 @@ bool CtrlMatrixList::GetValue(const GPUgstate &state, int row, int col, float &v
return true;
}
void CtrlMatrixList::GetColumnText(wchar_t *dest, int row, int col) {
void CtrlMatrixList::GetColumnText(wchar_t *dest, size_t destSize, int row, int col) {
if (col == MATRIXLIST_COL_BREAKPOINT) {
wcscpy(dest, L" ");
return;
+2 -2
View File
@@ -36,7 +36,7 @@ public:
protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override { return false; }
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override;
private:
@@ -78,7 +78,7 @@ protected:
bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT &returnValue) override {
return false;
}
void GetColumnText(wchar_t *dest, int row, int col) override;
void GetColumnText(wchar_t *dest, size_t destSize, int row, int col) override;
int GetRowCount() override;
void OnDoubleClick(int row, int column) override;
void OnRightClick(int row, int column, const POINT &point) override;
+3 -3
View File
@@ -352,7 +352,7 @@ int GenericListControl::HandleNotify(LPARAM lParam) {
NMLVDISPINFO* dispInfo = (NMLVDISPINFO*)lParam;
stringBuffer[0] = 0;
GetColumnText(stringBuffer,dispInfo->item.iItem,dispInfo->item.iSubItem);
GetColumnText(stringBuffer, ARRAY_SIZE(stringBuffer), dispInfo->item.iItem,dispInfo->item.iSubItem);
if (stringBuffer[0] == 0)
wcscat(stringBuffer,L"Invalid");
@@ -411,7 +411,7 @@ int GenericListControl::OnIncrementalSearch(int startRow, const wchar_t *str, bo
for (int i = 0; i < size; ++i) {
int r = (startRow + i) % size;
stringBuffer[0] = 0;
GetColumnText(stringBuffer, r, c);
GetColumnText(stringBuffer, ARRAY_SIZE(stringBuffer), r, c);
int difference = partial ? _wcsnicmp(str, stringBuffer, searchlen) : _wcsicmp(str, stringBuffer);
if (difference == 0)
return r;
@@ -591,7 +591,7 @@ void GenericListControl::CopyRows(int start, int size)
for (int c = 0; c < columnCount; ++c)
{
stringBuffer[0] = 0;
GetColumnText(stringBuffer, r, c);
GetColumnText(stringBuffer, ARRAY_SIZE(stringBuffer), r, c);
data.append(stringBuffer);
if (c < columnCount - 1)
data.append(L"\t");
+2 -2
View File
@@ -77,7 +77,7 @@ protected:
void SetItemState(int item, uint8_t state);
virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) = 0;
virtual void GetColumnText(wchar_t* dest, int row, int col) = 0;
virtual void GetColumnText(wchar_t* dest, size_t destSize, int row, int col) = 0;
virtual int GetRowCount() = 0;
virtual void OnDoubleClick(int itemIndex, int column) { };
virtual void OnRightClick(int itemIndex, int column, const POINT& point) { };
@@ -102,8 +102,8 @@ private:
WNDPROC oldProc;
void *images_ = nullptr;
const GenericListViewColumn* columns;
wchar_t stringBuffer[256]; // needs to survive slightly longer than the GetColumnText scope, so needs to be here.
int columnCount;
wchar_t stringBuffer[256];
bool valid;
bool sendInvalidRows;
// Used for hacky workaround to fix a rare hang (see issue #5184)
+1
View File
@@ -551,6 +551,7 @@ EXEC_AND_LIB_FILES := \
$(SRC)/GPU/Debugger/GECommandTable.cpp \
$(SRC)/GPU/Debugger/Playback.cpp \
$(SRC)/GPU/Debugger/Record.cpp \
$(SRC)/GPU/Debugger/State.cpp \
$(SRC)/GPU/Debugger/Stepping.cpp \
$(SRC)/GPU/GLES/FramebufferManagerGLES.cpp \
$(SRC)/GPU/GLES/StencilBufferGLES.cpp \