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?
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.
That makes perfect sense (and more importantly works). Thanks again.