From 402492a95842cb7cb4a7872098c64d64d6f1b234 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 6 Sep 2022 22:18:55 -0700 Subject: [PATCH] GE Debugger: Show imm prim flag detail in disasm. --- GPU/Debugger/GECommandTable.cpp | 2 -- GPU/Debugger/GECommandTable.h | 2 +- GPU/GPUCommon.cpp | 12 +++++++++++- GPU/GeDisasm.cpp | 29 +++++++++++++++++++++++++++-- GPU/ge_constants.h | 1 + 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/GPU/Debugger/GECommandTable.cpp b/GPU/Debugger/GECommandTable.cpp index 95e77f1bb6..16304b9d75 100644 --- a/GPU/Debugger/GECommandTable.cpp +++ b/GPU/Debugger/GECommandTable.cpp @@ -275,9 +275,7 @@ static constexpr GECmdInfo geCmdInfo[] = { { GE_CMD_VTCT, "immt", GECmdFormat::FLOAT }, { GE_CMD_VTCQ, "immq", GECmdFormat::FLOAT }, { GE_CMD_VCV, "immrgb", GECmdFormat::RGB }, - // TODO: Confirm if any other bits are used? { GE_CMD_VAP, "imma_prim", GECmdFormat::ALPHA_PRIM }, - // TODO: Confirm it's 8 bit? { GE_CMD_VFC, "immfog", GECmdFormat::DATA8 }, { GE_CMD_VSCV, "immrgb1", GECmdFormat::RGB }, { GE_CMD_UNKNOWN_FA, "unknownfa", GECmdFormat::NONE }, diff --git a/GPU/Debugger/GECommandTable.h b/GPU/Debugger/GECommandTable.h index 9abe0f7c6d..95b4eddf0f 100644 --- a/GPU/Debugger/GECommandTable.h +++ b/GPU/Debugger/GECommandTable.h @@ -66,7 +66,7 @@ enum class GECmdFormat { BLEND_MODE, // 4 bits srcfactor, 4 bits dstfactor, 3 bits equation. DITHER_ROW, // 4 s.3.0 fixed point dither offsets. LOGIC_OP, // 4 bits logic operation. - ALPHA_PRIM, // 8 bits alpha, 3 bits primitive type. + ALPHA_PRIM, // 8 bits alpha, 3 bits primitive type, 1 bit antialias, 6 bit clip?, 1 bit shading, 1 bit cullenable, 1 bit cullface, 1 bit tex enable, 1 bit fog, 1 bit dither. }; struct GECmdInfo { diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 0d4d8cf2fd..107398b7c8 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2449,6 +2449,7 @@ void GPUCommon::FlushImm() { float xyz[3]; }; ImmVertex temp[MAX_IMMBUFFER_SIZE]; + uint32_t color1Used = 0; for (int i = 0; i < immCount_; i++) { // Since we're sending through, scale back up to w/h. temp[i].uv[0] = immBuffer_[i].u * gstate.getTextureWidth(0); @@ -2457,6 +2458,7 @@ void GPUCommon::FlushImm() { temp[i].xyz[0] = immBuffer_[i].pos[0]; temp[i].xyz[1] = immBuffer_[i].pos[1]; temp[i].xyz[2] = immBuffer_[i].pos[2]; + color1Used |= immBuffer_[i].color1_32; } int vtype = GE_VTYPE_TC_FLOAT | GE_VTYPE_POS_FLOAT | GE_VTYPE_COL_8888 | GE_VTYPE_THROUGH; @@ -2474,6 +2476,14 @@ void GPUCommon::FlushImm() { bool dither = (immFlags_ & GE_IMM_DITHER) != 0; bool prevDither = gstate.isDitherEnabled(); + if ((immFlags_ & GE_IMM_CLIPMASK) != 0) { + WARN_LOG_REPORT_ONCE(geimmclipvalue, G3D, "Imm vertex used clip value, flags=%06x", immFlags_); + } else if ((immFlags_ & GE_IMM_FOG) != 0) { + WARN_LOG_REPORT_ONCE(geimmfog, G3D, "Imm vertex used fog, flags=%06x", immFlags_); + } else if (color1Used != 0 && gstate.isUsingSecondaryColor()) { + WARN_LOG_REPORT_ONCE(geimmcolor1, G3D, "Imm vertex used secondary color, flags=%06x", immFlags_); + } + if (texturing != prevTexturing || cullEnable != prevCullEnable || dither != prevDither || prevShading != shading) { DispatchFlush(); gstate.antiAliasEnable = (GE_CMD_ANTIALIASENABLE << 24) | (int)antialias; @@ -2487,7 +2497,7 @@ void GPUCommon::FlushImm() { int bytesRead; uint32_t vertTypeID = GetVertTypeID(vtype, 0); drawEngineCommon_->DispatchSubmitImm(temp, nullptr, immPrim_, immCount_, vertTypeID, cullMode, &bytesRead); - // TOOD: In the future, make a special path for these. + // TODO: In the future, make a special path for these. // drawEngineCommon_->DispatchSubmitImm(immBuffer_, immCount_); immCount_ = 0; diff --git a/GPU/GeDisasm.cpp b/GPU/GeDisasm.cpp index c3098f5706..f1f1293255 100644 --- a/GPU/GeDisasm.cpp +++ b/GPU/GeDisasm.cpp @@ -1354,11 +1354,36 @@ void GeDisassembleOp(u32 pc, u32 op, u32 prev, char *buffer, int bufsize) { break; case GE_CMD_VAP: - snprintf(buffer, bufsize, "Vertex draw: alpha=%02x, prim=%s, other=%06x", data & 0xFF, primTypes[(data >> 8) & 7], data & ~0x0007FF); + { + bool antialias = (data & GE_IMM_ANTIALIAS) != 0; + int clip = (data & GE_IMM_CLIPMASK) >> 12; + bool shading = (data & GE_IMM_SHADING) != 0; + bool cullEnable = (data & GE_IMM_CULLENABLE) != 0; + int cullMode = (data & GE_IMM_CULLFACE) != 0 ? 1 : 0; + bool texturing = (data & GE_IMM_TEXTURE) != 0; + bool dither = (data & GE_IMM_DITHER) != 0; + char *p = buffer; + p += snprintf(p, bufsize - (p - buffer), "Vertex draw: alpha=%02x, prim=%s", data & 0xFF, primTypes[(data >> 8) & 7]); + if (antialias) + p += snprintf(p, bufsize - (p - buffer), ", antialias"); + if (clip != 0) + p += snprintf(p, bufsize - (p - buffer), ", clip=%02x", clip); + if (shading) + p += snprintf(p, bufsize - (p - buffer), ", shading"); + if (cullEnable) + p += snprintf(p, bufsize - (p - buffer), ", cull=%s", cullMode == 1 ? "back (CCW)" : "front (CW)"); + if (texturing) + p += snprintf(p, bufsize - (p - buffer), ", texturing"); + if (dither) + p += snprintf(p, bufsize - (p - buffer), ", dither"); + } break; case GE_CMD_VFC: - snprintf(buffer, bufsize, "Vertex fog: %06x", data); + if (data & ~0xFF) + snprintf(buffer, bufsize, "Vertex fog: %02x / %f (extra %04x)", data & 0xFF, (data & 0xFF) / 255.0f, data >> 8); + else + snprintf(buffer, bufsize, "Vertex fog: %02x / %f", data & 0xFF, (data & 0xFF) / 255.0f); break; case GE_CMD_VSCV: diff --git a/GPU/ge_constants.h b/GPU/ge_constants.h index 3c47a5781e..19a51ae5ab 100644 --- a/GPU/ge_constants.h +++ b/GPU/ge_constants.h @@ -351,6 +351,7 @@ inline bool IsGeBufferFormat16BitColor(GEBufferFormat fmt) { #define GE_CLEARMODE_ALL (GE_CLEARMODE_COLOR|GE_CLEARMODE_ALPHA|GE_CLEARMODE_Z) #define GE_IMM_ANTIALIAS 0x00000800 +#define GE_IMM_CLIPMASK 0x0003F000 #define GE_IMM_SHADING 0x00040000 #define GE_IMM_CULLENABLE 0x00080000 #define GE_IMM_CULLFACE 0x00100000