Are OpenGL Compute Shaders async given multiple programs?

Discussion in 'Beginners Zone' started by K.I.L.E.R, Jul 11, 2016.

  1. K.I.L.E.R

    K.I.L.E.R Retarded moron
    Veteran

    Joined:
    Jun 17, 2002
    Messages:
    2,952
    Likes Received:
    49
    Location:
    Australia, Melbourne
    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)?
     
  2. sebbbi

    Veteran

    Joined:
    Nov 14, 2007
    Messages:
    2,924
    Likes Received:
    5,280
    Location:
    Helsinki, Finland
    +
    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).
     
    K.I.L.E.R and BRiT like this.
  3. K.I.L.E.R

    K.I.L.E.R Retarded moron
    Veteran

    Joined:
    Jun 17, 2002
    Messages:
    2,952
    Likes Received:
    49
    Location:
    Australia, Melbourne
    Thanks.

    Will move to Vulkan.
     

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...