I'm not sure which structure layout is most suited for my application: shared, packed,std140, std430. I'm not asking for an explanation of each, that information is easy to find, it's just hard to figure out the impact each will have on vendor compatibility/performance. If shared is the default, I'm suspecting that's a good starting point.
From what I can gather, I have to query the alignment/offsets when using shared or packed, because it's implementation specific.
What's the API for for querying it? Is there some parameter I pass to glGetShaderiv while the compute shader is bound, that lets me figure out the alignments?
Use
glGetProgramInterfacewith the parameterGL_SHADER_STORAGE_BLOCKto get the number of the Shader Storage Buffer Objects and the maximum name length.The maximum name length of the buffer variables can be get from the program interface
GL_BUFFER_VARIABLE:The name of the SSBO can be get by
glGetProgramResourceNameand a resource index byglGetProgramResourceIndex:Data of the shader storage block can be retrieved by
glGetProgramResource. See also Program Introspection.Get the number of of buffer variables and its indices from program interface and
GL_SHADER_STORAGE_BLOCKand the shader storage block resourceresInx:Get the offsets of the buffer variables, in basic machine units, relative to the base of buffer and its names from the program interface
GL_BUFFER_VARIABLEand the resource indicesvars[]:See also
ARB_shader_storage_buffer_object