Are OpenGL Compute Shaders async given multiple programs?

K.I.L.E.R

Retarded moron
Veteran
Basically I have two programs, one which has rendering ops inside of it, and another with nothing more than a compute shader calculating simulation state.

Both run at different times, I schedule draw calls according to whatever display framerate I want, and the compute shader dispatch is also controlled by a simulation timer, which is independent of draw fps. Both run on the same thread, but dispatching time differs.

Upon reading the other thread my Maxwell 2.0 card will do one thing at a time, however my upcoming (within a couple of days) 1070 GTX will allow both slices of code to be executed together, and so the longest running time for that frame would be the max(renderingShader, computeShader)?
 
+
Basically I have two programs, one which has rendering ops inside of it, and another with nothing more than a compute shader calculating simulation state.

Both run at different times, I schedule draw calls according to whatever display framerate I want, and the compute shader dispatch is also controlled by a simulation timer, which is independent of draw fps. Both run on the same thread, but dispatching time differs.

Upon reading the other thread my Maxwell 2.0 card will do one thing at a time, however my upcoming (within a couple of days) 1070 GTX will allow both slices of code to be executed together, and so the longest running time for that frame would be the max(renderingShader, computeShader)?
As you are using OpenGL (similar to DirectX 11) all compute dispatches will be submitted to a single queue and synchronized similarly as draw calls. The frame will not end until all the queued draws/dispatches are ready. There might be some execution overlap between the draws and dispatches (depending on the driver and resources used). You don't have much control over it.

OpenCL, CUDA, Vulkan and DirectX 12 support multiple queues. As your simulation step rate and your render frame rate are independent, you have no 1:1 mapping between rendered frames and simulation steps. Your program might execute multiple simulation steps per one rendered frame, or render multiple rendered frames per simulation step. Also simulation compute shader could still be left running when a frame render ends (= a simulation step starts during frame N and ends during frame N+1). Simulation might also be running while the render queue is waiting for vsync. You could also have two (or more) CPU threads. One submits simulation tasks to a (high priority) compute queue and one submits draw calls to the rendering queue.

The biggest advantage of a separate (high priority) compute queue is the reduced latency. The compute shader is executed soon after submission, and you get results back possibly during the same frame. If you put your compute tasks to a render queue (the only thing you can do in OpenGL and DX11), you need to wait until the render queue executes everything before that. Games usually buffer at least one frame of rendering, meaning that you get the result back in the next frame (or possibly even later).
 
Back
Top