[Mesa-dev] Anonymous structure in uniform question

f.josef at email.cz f.josef at email.cz
Thu Nov 21 12:50:56 PST 2013

just recently I encountered a problem when linking shaders, containing 
uniform consisting of anonymous structure.
Here is the code of shaders, triggering the problem:
//vertex shader
uniform struct {vec3 a; vec3 b;} a;
void main()
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

//fragment shader
uniform struct {vec3 a; vec3 b;} a;
void main()
  gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);

The error message pops up when linking is performed:
error: uniform `a' declared as type `#anon_struct_0002' and type `#anon_

The problem is, that each anonymous structure gets its own unique type, 
without checking if such type already exists. It seems to me, that such code
is somewhat in the gray area - the rest of OpenGL implementations doesn't 
seem to have a problem with this code (Intel on Win, OSX, Nvidia and AMD 
drivers in Win, OSX and Linux), which of course doesn't mean such a behavior
is correct.

I'd like to ask you, what is your take on this? Should anonymous structs be 
checked against ones seen already and the type name reused when suitable one
is found?
Thank you,

Michal Navratil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20131121/7027a990/attachment.html>

More information about the mesa-dev mailing list