ATI: bug in automatic attrib index assignment?

Is there a known bug in the automatic attrib index assignment for (certain) ATI drivers?

If I compile and link this two simple vertex and fragment shaders:

// vertex shader:
attribute vec4 position;
attribute vec4 color;
varying vec4 myColor;
void main() {
    gl_Position = position;
    myColor = color;
// fragment shader:
varying vec4 myColor;
void main() {
    gl_FragColor = vec4(1.0) - myColor;

and query the active attribs after (succesfull) linkage, I get the following assignments: “position -> 1” and “color -> 2”. Using these attrib slots (glVertexAttribPointer() and glEnableVertexAttribArray()) nothing is rendered.

If I do an explicit assignment of “position -> 0” and “color -> 1” with glBindAttribLocation() prior to the program linkage call, the expected result is rendered.

Note: without the explicit assignment everything is working correctly on NVidia hardware/drivers…

You are required to explicitly assign some attribute to slot 0. Other slots are optional.
With NVIDIA you were just lucky. Don’t count on it in the future forceware releases.

But I would think, that the automatic attrib index assignment should take care about that.

What is the point about having an automatism but not for all active attribs?

The automatic assignment would have to guess which attribute should be the 0 attribute. This makes a semantic difference, so it should not be done automatically.

The nvidia driver does it automatically anyways. Of course it can do it, but your application may break when a future driver will for example choose the other attribute as being 0. So it’s still best to choose yourself.

IMHO the ATI driver is doing better here. At least you have a guaranteed bug here, instead of the nVidia driver that may generate a bug, but only sometimes and then one that is hard to find. But of course the behaviour of the nVidia driver is legal, too.

I can’t find a note about the need to specify an attrib location of 0 in the OpenGL 2.1 specs…

And what semantic difference would it make if color has been assigned to location 0 and position to location 1? The vertex shader does the assignment of the attrib values to the corresponding varying variables for the communication with the fragment shader.

Note: I do not use the fixed function pipeline at all, so there should no implicit semantics for my attribs…

The difference is the following:

Sending the attrib 0 data triggers the submission of a vertex. So for immediate mode it makes a difference which attribute has 0. So you always have to submit attribute 0 last.

With vertex arrays, you have to make sure that attribute 0 is an array. If you use pseudo-instancing with the immediate mode calls, you can’t use the attribute 0 for that, as this is the attribute that generates the individual vertices.

It’s like the old glVertex command. It’s meaning is not only “set this attribute”, but also “submit a vertex”.

Of course this also implies that if you don’t have an attribute 0 at all, no vertices will be submitted and nothing will be drawn.

I agree that this implicit semantics is not good, but as long as we’re stuck with the immediate mode calls, we are stuck with this “special behaviour” of attribute 0 as well.

But there is a light at the end of the tunnel. The new API is coming, and I’m almost sure there will be no such special casing anymore :wink:

In the case of using only VBOs: could I additionally activate attrib index 0 with the same settings of another arbitrarily choose active attrib index.

E.g.; if the automatic index assignments generates (position -> 1; color -> 2), I add an additional mapping (position -> 0; position -> 1; color -> 2) or (color -> 0; position -> 1; color ->2)?

What about performance?

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.