Frozenreflex / Thundagun

Lightning fast performance mod for Resonite
GNU General Public License v3.0
6 stars 5 forks source link

Async #2

Closed DoubleStyx closed 3 weeks ago

DoubleStyx commented 3 weeks ago

Adds async support. Basically it changes the regular task queue to a batch queue, which has an IsCompleted flag and its own queue internally. Also added conditionals to the locking logic; if you switch to sync, it will break out of the occasional thread wakeup, so no deadlocks. If you switch to async, then it never enters the waiting pattern.

DoubleStyx commented 3 weeks ago

Please look over the code carefully and test it a few times. It looks pretty good in vr with minimal choppiness. In desktop it kinda looks ugly; too much frame stutter.

DoubleStyx commented 3 weeks ago

ok, so async does absolutely nothing over sync mode in desktop. In desktop, your camera is driven by FrooxEngine moving your player head. It's only OpenXR that handles the perspective shift. Async desktop throughput: max(game,renderer) Async VR throughput: renderer Sync desktop/VR throughput: max(game,renderer) Unity default: game + renderer So async VR is the only true defense against hitching

DoubleStyx commented 3 weeks ago

another issue with async is that it throws away vr/desktop input on each renderer loop, so maybe we'd want to queue that somehow. Might be less of an issue for VR, but I'd need to test more. At least in sync mode your input is buffered and not wasted So I think async should be considered experimental

DoubleStyx commented 3 weeks ago

Lastly, the player movement (except for noclip) seems to jitter somewhat in this mode. My hypothesis is that it's related to Unity's charactercontroller not being synced with Resonite, though I haven't checked