Try to load view and model matrices a bit faster.

This commit is contained in:
Unknown W. Brackets 2014-03-04 00:37:28 -08:00
parent a8f9635e28
commit 9e35822d16

View File

@ -1344,11 +1344,37 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
break;
case GE_CMD_VIEWMATRIXNUMBER:
gstate.viewmtxnum &= 0xFF00000F;
{
// This is almost always followed by GE_CMD_VIEWMATRIXDATA.
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
u32 *dst = (u32 *)(gstate.viewMatrix + (data & 0xF));
const int end = 12 - (data & 0xF);
int i = 0;
while ((src[i] >> 24) == GE_CMD_VIEWMATRIXDATA) {
const u32 newVal = src[i] << 8;
if (dst[i] != newVal) {
Flush();
dst[i] = newVal;
shaderManager_->DirtyUniform(DIRTY_VIEWMATRIX);
}
if (++i > end) {
break;
}
}
const int count = i;
gstate.viewmtxnum = (GE_CMD_VIEWMATRIXNUMBER << 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_VIEWMATRIXDATA:
{
// Note: it's uncommon to get here now, see above.
int num = gstate.viewmtxnum & 0xF;
u32 newVal = data << 8;
if (num < 12 && newVal != ((const u32 *)gstate.viewMatrix)[num]) {
@ -1362,11 +1388,37 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
break;
case GE_CMD_PROJMATRIXNUMBER:
gstate.projmtxnum &= 0xFF00000F;
{
// This is almost always followed by GE_CMD_PROJMATRIXDATA.
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
u32 *dst = (u32 *)(gstate.projMatrix + (data & 0xF));
const int end = 16 - (data & 0xF);
int i = 0;
while ((src[i] >> 24) == GE_CMD_PROJMATRIXDATA) {
const u32 newVal = src[i] << 8;
if (dst[i] != newVal) {
Flush();
dst[i] = newVal;
shaderManager_->DirtyUniform(DIRTY_VIEWMATRIX);
}
if (++i > end) {
break;
}
}
const int count = i;
gstate.projmtxnum = (GE_CMD_PROJMATRIXNUMBER << 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_PROJMATRIXDATA:
{
// Note: it's uncommon to get here now, see above.
int num = gstate.projmtxnum & 0xF;
u32 newVal = data << 8;
if (newVal != ((const u32 *)gstate.projMatrix)[num]) {
@ -1388,7 +1440,7 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
int i = 0;
while ((src[i] >> 24) == GE_CMD_TGENMATRIXDATA) {
u32 newVal = src[i] << 8;
const u32 newVal = src[i] << 8;
if (dst[i] != newVal) {
Flush();
dst[i] = newVal;
@ -1434,7 +1486,7 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
// If we can't use software skinning, we have to flush and dirty.
if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
while ((src[i] >> 24) == GE_CMD_BONEMATRIXDATA) {
u32 newVal = src[i] << 8;
const u32 newVal = src[i] << 8;
if (dst[i] != newVal) {
Flush();
dst[i] = newVal;