I have the following shader, everything works fine when setting the value of one of the matrices but I've discovered that getting a value back is incorrect for View and Projection, they are in reverse order.

#version 430

precision highp float;

layout (location = 0) uniform mat4 Model;
layout (location = 1) uniform mat4 View;
layout (location = 2) uniform mat4 Projection;

layout (location = 0) in vec3 in_position;
layout (location = 1) in vec4 in_color;
out vec4 out_color;

void main(void)
    gl_Position = Projection * View * Model * vec4(in_position, 1.0);
    out_color = in_color;

When querying their location they are effectively reversed, I did a small test by renaming View to Piew which puts it before Projection if sorted alphabetically and the order is correct.

Now if I do remove layout (location = ...) from the uniforms, the problem disappears !?

I am starting to think that this is a driver bug as explained in the wiki.

Do you know why the order of the uniforms is changed whenever the shader is compiled ?

(using an AMD HD7850)


1 Answer 1


When you specify layout (location = x), the compiler is supposed to respect that absolutely. It should not be changing the uniform locations as long as your specified layout is valid.

If you're absolutely sure it's not your fault (double-check you're not re-using any locations across all active shader stages, for instance), then it does sound like a driver bug. Make sure you're using the latest drivers, then if it persists, it would be good to report it to AMD.

  • \$\begingroup\$ Well, I've checked many times and everything is indeed correct, while it's not a major issue it is quite annoying to say the least. I've just opened a discussion at their forum (devgurus.amd.com/message/1304383), still waiting for moderation so you might not be able to see it yet. \$\endgroup\$
    – aybe
    Commented Jun 1, 2014 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .