Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: what is 'indirect' in glDispatchComputeIndirect?

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    13

    what is 'indirect' in glDispatchComputeIndirect?

    I am not getting how to assign value to 'indirect' to use it in glDispatchComputeIndirect().

    As per my understanding, when a buffer is bound using GL_DISPATCH_INDIRECT_BUFFER, that data can be altered in compute shader using the work group size using offset provided in this indirect ptr.

    But not getting should indirect be a struct ptr with 3 uint variables having value for x, y, z dimensions or an integer ptr?

    Can anyone please help in understanding it.

    Thanks.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    You pass the offset into the buffer to glDispatchComputeIndirect(). At the address that is computed with this offset, the GL expects 3, tighly packed uints. That's it.

    What the GL does under the hood is effectively equivalent to:

    Code :
    typedef  struct {
      uint  num_groups_x;
      uint  num_groups_y;
      uint  num_groups_z;
    } DispatchIndirectCommand;
     
    void glDispatchComputeIndirect(GLintptr indirect)
    {        
      cmd = (const DispatchIndirectCommand  *)(bufferBaseAddress + indirect);
      glDispatchCompute(cmd->num_groups_x,  cmd->num_groups_y,  cmd->num_groups_z);
    }

    As long as you're not pointing to some invalid adress and as long as your parameter pack is valid, there shouldn't be any problems.
    Last edited by thokra; 09-23-2013 at 08:08 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    3
    Quote Originally Posted by thokra View Post
    You pass the offset into the buffer to glDispatchComputeIndirect(). At the address that is computed with this offset, the GL expects 3, tighly packed uints. That's it.

    What the GL does under the hood is effectively equivalent to:

    Code :
    typedef  struct {
      uint  num_groups_x;
      uint  num_groups_y;
      uint  num_groups_z;
    } DispatchIndirectCommand;
     
    void glDispatchComputeIndirect(GLintptr indirect)
    {        
      cmd = (const DispatchIndirectCommand  *)(bufferBaseAddress + indirect);
      glDispatchCompute(cmd->num_groups_x,  cmd->num_groups_y,  cmd->num_groups_z);
    }

    As long as you're not pointing to some invalid adress and as long as your parameter pack is valid, there shouldn't be any problems.

    Hi thokra,

    Does this mean doing something like :

    struct __attribute__ ((packed)){
    GLuint x, y,z;
    }s;
    struct s obj;

    obj.x=1;
    obj.y=1;
    obj.z =1;

    glGenBuffers(1, &buffer_obj)
    glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer_obj);
    glBufferData(GL_DISPATCH_INDIRECT_BUFFER, sizeof(s), obj, GL_STREAN_READ );
    glDispatchComputeIndirect(0);

    Else can you give any example?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,129
    That should do it. Only it would make more sense to write the values of x,y and z from inside a shader. In essence, what you absolutely need to do is allocate enough space for at least one group of uints in the buffer object's data store. Otherwise, indirect dispatch doesn't make much sense. Note that the attribute specifier is GCC specific.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •