GE Debugger: Show imm prim flag detail in disasm.

This commit is contained in:
Unknown W. Brackets 2022-09-06 22:18:55 -07:00
parent 880f6f8d49
commit 402492a958
5 changed files with 40 additions and 6 deletions

View File

@ -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 },

View File

@ -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 {

View File

@ -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;

View File

@ -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:

View File

@ -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