Skip to content

Commit

Permalink
Oops, forgot the world matrix too.
Browse files Browse the repository at this point in the history
VerySleepy is telling me that time is spent in WORLDMATRIXDATA in games,
but I didn't check the perf impact exactly.  It's probably small, but may
help some games.
  • Loading branch information
unknownbrackets committed Mar 4, 2014
1 parent 349c207 commit b1acde2
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion GPU/GLES/GLES_GPU.cpp
Expand Up @@ -1326,11 +1326,37 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
break;

case GE_CMD_WORLDMATRIXNUMBER:
gstate.worldmtxnum &= 0xFF00000F;
{
// This is almost always followed by GE_CMD_WORLDMATRIXDATA.
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
u32 *dst = (u32 *)(gstate.worldMatrix + (data & 0xF));
const int end = 12 - (data & 0xF);
int i = 0;

while ((src[i] >> 24) == GE_CMD_WORLDMATRIXDATA) {
const u32 newVal = src[i] << 8;
if (dst[i] != newVal) {
Flush();
dst[i] = newVal;
shaderManager_->DirtyUniform(DIRTY_WORLDMATRIX);
}
if (++i > end) {
break;
}
}

const int count = i;
gstate.worldmtxnum = (GE_CMD_WORLDMATRIXNUMBER << 24) | ((data + count) & 0xF);

// Skip over the loaded data, it's done now.
UpdatePC(currentList->pc, currentList->pc + count * 4);
currentList->pc += count * 4;
}
break;

case GE_CMD_WORLDMATRIXDATA:
{
// Note: it's uncommon to get here now, see above.
int num = gstate.worldmtxnum & 0xF;
u32 newVal = data << 8;
if (num < 12 && newVal != ((const u32 *)gstate.worldMatrix)[num]) {
Expand Down

4 comments on commit b1acde2

@hrydgard
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't explain why, but this exact commit causes a few weird glitches per second in-game in Star Soldier, where something is drawn warped over parts or the whole screen.

@unknownbrackets
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I don't have that game. Does it maybe do more than 12 world matrix data cmds in a row or something?

-[Unknown]

@unknownbrackets
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found an off-by-one mistake, might be it: 743854a

-[Unknown]

@hrydgard
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems to be it. Nice catch.

Please sign in to comment.