Closed DoubleStyx closed 3 weeks ago
So here, if 1:1 state-frame consistency is always the priority, just use sync. If you always want to maximize state/frame recency, just use async. If you want to keep things 1:1 by default but essentially detach during large stalls, use the auto mode.
To determine what the actual ratio is, we need some time-weighted average. Exponential moving average should work here. We could also expose the exponent multiplier if people want to react to hitching faster, or maybe we'll find a good default that works in almost all situations.
Once this gets done, we'll need to update the README accordingly.
Actually, now that I think about it, we don't even need options for auto mode or manual mode anymore (in theory). For sync mode, you could set the threshold below 0 so there's no ratio that could trigger async. For async mode, you could set the threshold to between 0 and 1, which is always true. For auto mode, choose something between 1 and infinity.
Though for user friendliness, maybe having those other options is more intuitive?
I have an idea for auto-switching between the sync/async modes. Have an config boolean for enabling auto-switch to async based on a config float ratio threshold.
Make it bidirectional, so if the ratio of Resonite to Unity is greater than x or Unity to Resonite is greater than x, enable async.
This essentially handles stall cases. If you get something crazy like Resonite to Unity 10:1, then Unity is stalling. 10:1 in the other direction means Resonite is stalling. Either way, you want to manage this by either using the latest Resonite frame for state recency or drawing the frame again for frame recency.