With Mesa 9.1.5 Cogl has started failing most of the conformance tests when using the GLSL backend. I have bisected it down to this commit in Mesa:
I think the problem has something to do with glGetAttribLocation returning the wrong values.
I am attaching a standalone test case which uses three attributes and calls glGetAttribLocation on all of them. One of the attributes is the vertex position, and the other two are colours. The ‘color’ attribute is red for the vertices on the left and green for the vertices on the right. The ‘other_color’ attribute is set to a constant blue colour. These two attributes are added together to get the final colour.
Before that commit in Mesa, the rectangle has a gradient from magenta to cyan as you would expect. After that commit it is just red to green as if the other_color attribute isn't being added.
If you reorder the attributes it also fixes it.
Created attachment 83311 [details]
I think this doesn't actually have anything to do with the bisected change. I think this is a pre-existing bug. Note the output before the change:
[idr@mumford-wire ~]$ ./a.out
glGetAttribLocation("pos") = 1
glGetAttribLocation("color") = 0
glGetAttribLocation("other_color") = 2
and the output after the change:
[idr@mumford-wire ~]$ mesa installed ./a.out
glGetAttribLocation("pos") = 1
glGetAttribLocation("color") = 2
glGetAttribLocation("other_color") = 0
This matches my expectations of the shader: other_color is listed first, then pos, then color. Of the bunch, only other_color doesn't have an array associated. In desktop GL, attribute 0 is special... it's the attribute that provokes the vertex for normal drawing commands. I suspect a single vertex gets provoked when glVertexAttrib4f is called, but nothing happens in glDrawArrays.
To confirm this, I added the following line before the call to glLinkProgram. With that change, the test fails on Mesa 9.1.4 (which does not include e8af057).
glBindAttribLocation(glsl_program, 0, "other_color");
I'm also not 100% sure this is Mesa's bug. I'll need to dig through the GL specs. I'm somewhat sure the spec used to say this behavior was intended, but I always have trouble remembering the exact rules.
Does this test work (with my change) on other implementations? What output does it produce?
the issue and symptoms here matches with bug #66292
This reminds me of a bug I filed last year relating to broken attribute locations: https://bugs.freedesktop.org/show_bug.cgi?id=55503
I wonder if there is any interaction with this issue.
We tried the experiment from comment #2 on NVIDIA and AMD. On NVIDIA, it draws as it would on OpenGL ES. On AMD, nothing is drawn. Since no vertices should be provoked, I actually think AMD's behavior is technically correct.
I'm going to leave this bug open for now, but I'm going to take it off the release tracker. I'm mostly convinced that Cogl is relying on ES behavior that is different in desktop GL. I want to be completely convinced before closing the bug.
(In reply to comment #6)
> I'm going to leave this bug open for now, but I'm going to take it off the
> release tracker. I'm mostly convinced that Cogl is relying on ES behavior
> that is different in desktop GL. I want to be completely convinced before
> closing the bug.
I can confirm that Cogl wasn't binding the position attribute to generic attribute location 0 and doing so fixes our current conformance test failures.
For reference the relevant part of the GL 3.0 spec that covers these semantics is Section 2.7 "Vertex Specification" pg 27
on Jun 27, 2016 at 13:01:14.
(provided by the Example extension).