diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 9a9906c819..e155c7ce4b 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -882,7 +882,8 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) { if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK)) shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET); } else { - if (diff & ~GE_VTYPE_WEIGHTCOUNT_MASK) { + // Don't flush when weight count changes, unless morph is enabled. + if ((diff & ~GE_VTYPE_WEIGHTCOUNT_MASK) || (data & GE_VTYPE_MORPHCOUNT_MASK) != 0) { // Restore and flush gstate.vertType ^= diff; Flush(); @@ -1406,8 +1407,7 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) { u32 newVal = data << 8; if (num < 96 && newVal != ((const u32 *)gstate.boneMatrix)[num]) { // Bone matrices should NOT flush when software skinning is enabled! - // TODO: Also check for morph... - if (!g_Config.bSoftwareSkinning) { + if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) { Flush(); shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12)); } @@ -1509,6 +1509,18 @@ void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) { } } +void GLES_GPU::FastLoadBoneMatrix(u32 target) { + if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) { + Flush(); + const int num = gstate.boneMatrixNumber & 0x7F; + shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12)); + if ((num % 12) != 0) { + shaderManager_->DirtyUniform((DIRTY_BONEMATRIX0 << (num / 12)) + 1); + } + } + gstate.FastLoadBoneMatrix(target); +} + void GLES_GPU::UpdateStats() { gpuStats.numVertexShaders = shaderManager_->NumVertexShaders(); gpuStats.numFragmentShaders = shaderManager_->NumFragmentShaders(); diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index 6746e77770..5742741f89 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -78,6 +78,7 @@ public: protected: virtual void FastRunLoop(DisplayList &list); virtual void ProcessEvent(GPUEvent ev); + virtual void FastLoadBoneMatrix(u32 target); private: void Flush() { diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 83ad905dc8..9647de36bf 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -736,12 +736,12 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) { u32 target = gstate_c.getRelativeAddress(data); // Bone matrix optimization - many games will CALL a bone matrix (!). - if (g_Config.bSoftwareSkinning && (Memory::ReadUnchecked_U32(target) >> 24) == GE_CMD_BONEMATRIXDATA) { + if ((Memory::ReadUnchecked_U32(target) >> 24) == GE_CMD_BONEMATRIXDATA) { // Check for the end if ((Memory::ReadUnchecked_U32(target + 11 * 4) >> 24) == GE_CMD_BONEMATRIXDATA && (Memory::ReadUnchecked_U32(target + 12 * 4) >> 24) == GE_CMD_RET) { // Yep, pretty sure this is a bone matrix call. - gstate.FastLoadBoneMatrix(target); + FastLoadBoneMatrix(target); break; } } @@ -933,6 +933,10 @@ void GPUCommon::ExecuteOp(u32 op, u32 diff) { } } +void GPUCommon::FastLoadBoneMatrix(u32 target) { + gstate.FastLoadBoneMatrix(target); +} + struct DisplayListOld { int id; u32 startpc; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 769df0c94e..7ddbd39b53 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -88,6 +88,7 @@ protected: int GetNextListIndex(); void ProcessDLQueueInternal(); void ReapplyGfxStateInternal(); + virtual void FastLoadBoneMatrix(u32 target); virtual void ProcessEvent(GPUEvent ev); virtual bool ShouldExitEventLoop() { return coreState != CORE_RUNNING;