Uniform buffers and the std140 layout

Discussion created by Shrinker on Feb 8, 2011
Latest reply on Jul 25, 2012 by gsellers
Something's wrong after loading a binary program

Hey there. I have a problem that I will only describe and then try to answer questions because there is too much proprietary code attached to "quickly" recreate the issue.

I have a pretty complex shader in which I used uniforms for everything, including passing the modelview and the projection matrices. The shader is loaded and compiled by my program, and then the binary is saved to disk, as a cache for later (using the standardized binary program thingo from OpenGL 4 for which ATI driver support was only added recently).

Now I have changed it so that the two matrices are not passed as uniforms anymore, but through a uniform buffer. On my Nvidia system, this works fine, just like on the ATI system, but when restarting the application (so that it uses its binary shader cache file saved with standard OpenGL means), the ATI system behaves strange. The Nvidia system just displays everything as usual, but the ATI system seems to zero out things somehow. The uniform block has the std140 layout modifier set, which, according to the OpenGL specification, defines a fixed data layout you can depend on, with precise rules (all in the spec).

I have a hunch that this layout is disregarded when the shader is loaded from the binary cache. Could anyone with access to the driver codebase please check out on that? :/

Note: All location values are confirmed valid, no invalid uniform locations are returned by any commands on the go.