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: (GL 4.6) How to write parameter buffer from shaders?

  1. #1
    Junior Member Newbie Asylum's Avatar
    Join Date
    Aug 2017
    Location
    Hungary
    Posts
    9

    (GL 4.6) How to write parameter buffer from shaders?

    Khronos recently released the OpenGL 4.6 spec which incorporates the ARB_indirect_parameters extension.
    While it's rather obvious how to use the new functions (f.e. glMultiDrawElementsCount) it is not clear how one can fill the parameter buffer in a shader as glBindBufferBase doesn't accept the GL_PARAMETER_BUFFER enum (according to the spec.).

    So my questions are:
    • how do I write this buffer from a shader
    • how do I write this buffer with transform feedback

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    5,932
    Buffer objects are not typed. There is no such thing as a "parameter buffer," "vertex buffer," "pixel buffer," or anything. There are just buffer objects, and the various ways in which they can be used. Any buffer object can be used with any of the buffer object usages.

    So if you have a buffer, you can write to it from a shader using any of the ways of doing so. Atomic counters, image load/store to buffer textures, SSBOs, etc. After that's done, bind it to the `GL_PARAMETER_BUFFER` bind point and render.

    ... that being said, I just realized something. The ARB neglected to add a `glMemoryBarrier` bit for parameter buffer usage. So you actually can't use image load/store or SSBOs to write, since there's no barrier to make those writes visible.

  3. #3
    Junior Member Newbie Asylum's Avatar
    Join Date
    Aug 2017
    Location
    Hungary
    Posts
    9
    Thanks, that was my first thought too, I just wanted confirmation. The GL standard is a little confusing in this regard, with all its buffer bindings etc.
    In Metal for example you really have just one general-purpose buffer concept, and you can use it for whatever you want to.

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,167
    Quote Originally Posted by Asylum View Post
    In Metal for example you really have just one general-purpose buffer concept, and you can use it for whatever you want to.
    That's what you have in OpenGL too.

    The difference is that instead of always passing in these buffer objects as parameters to functions that use them (e.g. glVertexAttribPointer), you sometimes bind them to context-provided buffer bind targets first, and then those API calls read the buffer handles from there. The bind targets behave as implicit parameters to those functions.

Tags for this Thread

Posting Permissions

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