This is how I understood the game loop, and I wanted to know if I'm correct or not:

1) Draw/render -> input
CPU    |    GPU
Update |
Draw   |
Input  | Rendering

2) Input -> Draw/render
CPU        |    GPU
Input      |
Update     |
Draw       |
(nothing?) | Rendering

By rendering I mean updating the actual frame. What happens in the second case? Is the CPU doing nothing or is it checking input for the next frame already? Are there any differences from checking input before or after the update/draw part?


2 Answers 2


Whether you input, update, render or render, input, update is irrelevant. The loop will restart, so there is no difference. Same with whether you input, update, draw or update, draw, input(which becomes input, update, draw under the same logic). Now, if your blocking at the end for a swap or frame-sync, then you may have input lag to rendering if you receive input before the waiting.

Hence, I always input, update, and then render.

  • \$\begingroup\$ Well, that was my point, at the end there is a swap (see GPU rendering part), so based on this I was wondering if there were any differences... \$\endgroup\$
    – Xriuk
    Commented May 17, 2016 at 15:48
  • \$\begingroup\$ @Xriuk Yes, you could end up with input lag, if you receive input only before waiting. \$\endgroup\$ Commented May 17, 2016 at 16:24
  • \$\begingroup\$ Does the swap wait until GPU has finished? \$\endgroup\$
    – Xriuk
    Commented May 18, 2016 at 12:34
  • 1
    \$\begingroup\$ @Xriuk SwapBuffers literally swaps the buffers. The GPU has been rendering asynchronously, into a non-visible buffer(assuming your using double-buffers), which will be swapped to the screen. Since the GPU is rendering asynchronously, if it's not complete, SwapBuffers will wait for the GPU. \$\endgroup\$ Commented May 18, 2016 at 13:55

If i was you, i should multithread the whole thing, having a renderthreat and a enginethreat or whatever you want to call it

  • \$\begingroup\$ In my opinion that would be useless. Since every step is directly linked to the following. \$\endgroup\$
    – Xriuk
    Commented May 25, 2016 at 16:42
  • \$\begingroup\$ If you want to have a high framerate, i shouldn't include the input in a frame \$\endgroup\$
    – Maxim DC
    Commented May 25, 2016 at 19:38
  • \$\begingroup\$ I have input in my engine being part of everything and sequentially blocking, and I still reach 4000+ fps with many triangles on the screen. You will not notice the input at all unless you're doing something very wrong. \$\endgroup\$
    – Water
    Commented Mar 15, 2019 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .