Minor cleanup in Prim()

This commit is contained in:
Henrik Rydgård 2023-10-01 13:57:41 +02:00
parent db805cc4cc
commit 52ad0d0335

View file

@ -896,14 +896,10 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
PROFILE_THIS_SCOPE("execprim"); PROFILE_THIS_SCOPE("execprim");
u32 data = op & 0xFFFFFF;
u32 count = data & 0xFFFF;
if (count == 0)
return;
FlushImm(); FlushImm();
// Upper bits are ignored. // Upper bits are ignored.
GEPrimitiveType prim = static_cast<GEPrimitiveType>((data >> 16) & 7); GEPrimitiveType prim = static_cast<GEPrimitiveType>((op >> 16) & 7);
SetDrawType(DRAW_PRIM, prim); SetDrawType(DRAW_PRIM, prim);
// Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though.
@ -952,6 +948,10 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
vfb->usageFlags |= FB_USAGE_BLUE_TO_ALPHA; vfb->usageFlags |= FB_USAGE_BLUE_TO_ALPHA;
} }
u32 count = op & 0xFFFF;
if (count == 0)
return;
// Must check this after SetRenderFrameBuffer so we know SKIPDRAW_NON_DISPLAYED_FB. // Must check this after SetRenderFrameBuffer so we know SKIPDRAW_NON_DISPLAYED_FB.
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) { if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
// Rough estimate, not sure what's correct. // Rough estimate, not sure what's correct.
@ -995,9 +995,9 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
int totalVertCount = count; int totalVertCount = count;
// PRIMs are often followed by more PRIMs. Save some work and submit them immediately. // PRIMs are often followed by more PRIMs. Save some work and submit them immediately.
const u32_le *src = (const u32_le *)Memory::GetPointerUnchecked(currentList->pc + 4); const u32_le *start = (const u32_le *)Memory::GetPointerUnchecked(currentList->pc + 4);
const u32_le *src = start;
const u32_le *stall = currentList->stall ? (const u32_le *)Memory::GetPointerUnchecked(currentList->stall) : 0; const u32_le *stall = currentList->stall ? (const u32_le *)Memory::GetPointerUnchecked(currentList->stall) : 0;
int cmdCount = 0;
// Optimized submission of sequences of PRIM. Allows us to avoid going through all the mess // Optimized submission of sequences of PRIM. Allows us to avoid going through all the mess
// above for each one. This can be expanded to support additional games that intersperse // above for each one. This can be expanded to support additional games that intersperse
@ -1130,12 +1130,12 @@ void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
// All other commands might need a flush or something, stop this inner loop. // All other commands might need a flush or something, stop this inner loop.
goto bail; goto bail;
} }
cmdCount++;
src++; src++;
} }
bail: bail:
gstate.cmdmem[GE_CMD_VERTEXTYPE] = vertexType; gstate.cmdmem[GE_CMD_VERTEXTYPE] = vertexType;
int cmdCount = src - start;
// Skip over the commands we just read out manually. // Skip over the commands we just read out manually.
if (cmdCount > 0) { if (cmdCount > 0) {
UpdatePC(currentList->pc, currentList->pc + cmdCount * 4); UpdatePC(currentList->pc, currentList->pc + cmdCount * 4);