I think I’ve just encountered AMD driver bug.
Compiling following shaders is fine. However, when calling glLinkProgram on program with attached shaders I get unexpected error and linking fails.
// main procedure, the original name was main
void main()
{
COL0 = _inVU1._mColor;
} // main end
What is even more surprising is the fact that program links correctly on AMD if I remove uniform struct in fragment shader - just declare uniform vec4 _mColor; and use it directly.
However, when calling glLinkProgram on program with attached shaders I get unexpected error and linking fails.
What error do you get specifically.
On Nvidia everything works correctly.
That’s not surprising, since this looks like something that NVIDIA’s Cg-to-GLSL compiler coughed up. That’s not to say that it is wrong, but it does do a lot of unusual things (structs with one member, pretending that a matrix is 4 vec4’s for no particular reason, etc).
Have you considered writing the GLSL by hand? You’ll be less likely to hit corner cases that drivers may not handle correctly.
The problem with glLinkProgram error is that it is actually a string : ‘unexpected error’ . Nothing more in the log.
And yeas actually this code is from cg to glsl compilation. Unfortunately we’ve got the whole shading node based workflow setup in cg including shader builder, therefore rewriting the whole thing to pure glsl is somewhat non preferable atm.
However, this code should actually still compile according to glsl specification.
My uniform in Vertex shader was having the same name as the uniform in Fragment shader.
I thought that should be distinguished by shader domain. Apparently it is not.
I would assume that two uniforms with different struct types, but same names in two different domains should compile without a problem as they should have different resources and different actual names because of flattening of struct.
However, it is understandable that this is not the proper clear code. Lack of error code was a bit misleading.
I will rewrite the rules for our uniforms.