How to do an expensive game update in the eventloop, without introducing hitches in the rendering? #4091
Replies: 1 comment
-
It really depends what you're doing, if what you do is just run some compute which is really slow, you should have a dedicated thread for it to run, to free up the polling of events on the main thread, so it's not that laggy. In general, nothing special to winit, really, you have the same issue with anything else and you'd have the same issue with any other library if your renderer is really slow. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a game, where the logic update can routinely take up to the full 16.6 ms per frame (for 60fps), or potentially slightly more than that. What is the correct way to run this update, to avoid impacting the redrawing of the window? (Of course if the updates take 20ms then 50fps is the most redraws that still make sense.)
I currently redraw in
RedrawRequested
and callrequest_redraw
at the end of the handling. In the winit event_loop implementation for bevy i saw them updating inabout_to_wait
but from my testing, this lead to stuttery frametimes. Since my game uses a fixed timestep for its update, it is important for them to be at a consistent 60 updates per second. Does running the update in the event_loop, like I am trying, make sense here, or am I better off updating in another thread and try and somehow synchronize rendering and updating?Beta Was this translation helpful? Give feedback.
All reactions