diff options
author | StapleButter <thetotalworm@gmail.com> | 2018-11-24 04:27:27 +0100 |
---|---|---|
committer | StapleButter <thetotalworm@gmail.com> | 2018-11-24 04:27:27 +0100 |
commit | 391c8d43b02fe459d12338d462a0c50f0d9e0232 (patch) | |
tree | 5dfab96a56ae495390f24b5ba5ebe7ebb757282d | |
parent | 7b48ce5b75150f9e0d8b1f0c35d244d65d36ee6c (diff) |
drain GX pipelines when there's nothing else running. fixes some weird bugs, apparently.
-rw-r--r-- | src/GPU3D.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index d1753f0..bdf53a5 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -1663,9 +1663,6 @@ void ExecuteCommand() ExecParamCount = 0; - if (CycleCount > 0) - GXStat |= (1<<27); - switch (entry.Command) { case 0x10: // matrix mode @@ -2180,6 +2177,9 @@ void ExecuteCommand() break; } } + + if (CycleCount > 0) + GXStat |= (1<<27); } s32 CyclesToRunFor() @@ -2188,11 +2188,28 @@ s32 CyclesToRunFor() return CycleCount; } +void FinishWork(s32 cycles) +{ + AddCycles(cycles); + if (NormalPipeline) + NormalPipeline -= std::min(NormalPipeline, cycles); + + CycleCount = 0; + + if (VertexPipeline || NormalPipeline || PolygonPipeline) + return; + + GXStat &= ~(1<<27); + + if (NumPushPopCommands == 0) GXStat &= ~(1<<14); + if (NumTestCommands == 0) GXStat &= ~(1<<0); +} + void Run(s32 cycles) { if (FlushRequest) return; - if (CycleCount <= 0 && CmdPIPE->IsEmpty()) + if (CmdPIPE->IsEmpty() && !(GXStat & (1<<27))) return; CycleCount -= cycles; @@ -2210,13 +2227,7 @@ void Run(s32 cycles) if (CycleCount <= 0 && CmdPIPE->IsEmpty()) { - // todo: advance remaining pipeline shit here - - CycleCount = 0; - GXStat &= ~(1<<27); - - if (NumPushPopCommands == 0) GXStat &= ~(1<<14); - if (NumTestCommands == 0) GXStat &= ~(1<<0); + if (GXStat & (1<<27)) FinishWork(-CycleCount); } } |