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 3 of 3

Thread: Clearing SSBO

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    16

    Clearing SSBO

    My current project ran into a small issue. I have a shader storage buffer i'm using to transfer information from one shader to another. The first shade writes to the buffer using += on the elements (as it runs once per light source and frame and I want the total light) and then i read these points in the second shader and after each element was read it was set to 0. Which worked fine as each element was only read once. Now however I've started clustering my data to decrease the size.

    This does not cause any problems for the first shader that will still be writing to the buffer in the same way as each invocation of the compute shader is the only one in that pass to write to the same element. However the second shader will have more then one invocation reading each element. So my current solution will not work after this change.

    I've looked at glClearBufferData. But apart from being somewhat lost about the information it wants me to provide it seems to lack any way of specifying which shader storage buffer I want to clear (I'm using a total of 7 at the moment). I could simply add a third compute shader after the second one to clear the data and this is currently my horrible hack fallback plan. But I assume there is a better way of doing this. Any one have any ideas?

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    You remember how you specified which buffer object to create back when you called glBufferData? That's how you specify it. You bind a buffer to the context with glBindBuffer, and then you clear it with glClearBufferData.

    There's no such thing as an "SSBO"; it's just a buffer object. How it gets used is based on what you bind it to. All buffers are ultimately the same.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2013
    Posts
    16
    That makes perfect sense (and more importantly works). Thanks again.

Posting Permissions

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