I’m trying to go through all of the new OpenGL 4.3 additions. I have looking at shader storage buffers and compute shaders. I gotten a lot to work. However I would like to use the atomic_uint with a shader storage buffer. I was trying to use the example from Mike Bailey: http://web.engr.oregonstate.edu/~mjb/sig12/compute.shader.1pp.pdf. But I’m getting a compile error in my compute shader at this line:
It seems the compiler really wants a name after the buffer keyword. If I put one there it then gives me a new error about specifying a layout for the atomic_uint.
Any thoughts would be appreciated. The basic idea is that I should be able to bind an atomic to a GL_ATOMIC_COUNTER_BUFFER to set value and then read them using:
It seems the compiler really wants a name after the buffer keyword.
GLSL isn’t C; the name of a uniform block is not optional. Even if you don’t plan to use it from the API because you’re using in-shader binding, you still need to name it.
If I put one there it then gives me a new error about specifying a layout for the atomic_uint.
Atomic counters are like image and sampler types: you cannot put them in interface blocks. They’re opaque types (GLSL 4.3 section 4.1.7), which are expressly forbidden from going in those kinds of constructs.
It’s likely the author simply got carried away with shader storage buffers, since his atomic binding OpenGL code is exactly what you would use if particleCount were properly declared as a uniform.