In our Simple Engine, we have two major systems that are prime candidates for asynchronous compute: the Physics System (physics_system.cpp) and the Audio HRTF System (audio_system.cpp).
The PhysicsSystem performs complex simulation tasks like integration and collision detection using GPU-accelerated compute shaders (shaders/physics.slang). Similarly, the AudioSystem uses a compute shader (shaders/hrtf.slang) to process audio spatialization (Head-Related Transfer Function) on the GPU.
Currently, both systems follow a sequential, blocking pattern. For example, the physics simulation is submitted to the GPU, and the CPU immediately stalls at a fence:
// Sequential Physics Dispatch (Current Engine)
physicsSystem->Update(deltaTime); // Internally calls SimulatePhysicsOnGPU
// Inside PhysicsSystem::SimulatePhysicsOnGPU:
// 1. Submit compute commands to computeQueue
// 2. ReadbackGPUPhysicsData: blocks on a fence (CPU STALL!)
This CPU-side stall is a missed opportunity for overlap. To maximize throughput, we can re-architect this flow to be asynchronous by utilizing the engine’s dedicated Compute Queue (obtained via renderer→GetComputeQueue()). By submitting these tasks early in the frame and only synchronizing when the data is strictly necessary, we can keep both the graphics and compute hardware units fully occupied.
Beyond physics and audio, the engine’s Forward+ Rendering path (see ForwardPlus_Rendering.adoc) is another prime candidate for overlap. The Forward+ compute pass (forward_plus_cull.slang) builds light lists for each tile on the screen. While this compute pass does require the depth buffer from the current frame to perform effective Z-culling, it doesn’t need to wait for the entire geometry pass to finish.
If we use Timeline Semaphores, we can tell the compute queue to wait only until the Depth Pre-pass is complete. While the graphics queue continues with the main Opaque Geometry rendering, the compute queue can simultaneously be culling lights for those same pixels, perfectly overlapping the compute-heavy light assignment with the raster-heavy geometry processing.