Saturday, July 30, 2016

What's Your Ios Game Loop?

What's Your Ios Game Loop?

Just looking at what other people have done, what's been successful, and what pitfalls to avoid (specifically, CPU/GPU synchronization).

 

Current Prototype:

  • Game update is variable update time
  • Game update and rendering done in CADisplayLink callback running on main thread.
  • Audio update occurs on separate thread controlled by AudioUnit.
  • (Game-specific context): Game update takes ~5ms to complete

 

Thoughts:

  • I feel like variable-time game update might be OK on mobile given we don't have to worry about being preempted as much.
  • Don't know if this is how CADisplayLink is designed to work - perhaps should run game logic on background thread and only render in CADisplayLink callback? Not sure what synchronization issues arise here. Game logic could be allowed to update as fast as possible - or could cap to screen refresh rate.
  • Similarly, could push rendering into same background thread as game update. Again, not sure what synchronization issues arise here.

Goals (The same as everyone else?):

  1. Minimize input -> display latency
  2. Every screen refresh, the device should have an new/updated frame buffer to display.

No comments:

Post a Comment