PDA

View Full Version : Attribute binding bug on ATI?



Bl00drav3n
01-30-2013, 07:02 PM
Hi,

I have a problem with my OpenGL program on my Radeon HD6950. I tried to render a square with a simple vertex shader (only one attribute: position). I am explicitly binding my vertex attributes to specific indices via glBindAttribLocation prior to glLinkProgram. In this case I bound 'in vec3 VertexPosition' to index 1 and enabled it in my vertexarray object.

glBindAttribLocation(programId, 1, "VertexPosition");
glLinkProgram(programId);

...

glBindVertexArray(vertexArrayId);
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, ...);

But when I use an index of 0, the geometry gets drawn! This made me wanting to know if it was my fault for thinking that I could use any index from 0 to MAX_ATTRIBS or if it was a driver bug, so I sent the test program to a friend of mine, who uses an NVidia graphics card. He told me that both versions, with index 0 and 1, worked for him. That made me curious and through Google I found a closed thread in this forum that explained that it is a driver bug (I can't link it here?).

My question now is: Is this bug still not fixed, or is it a problem on my side? I am using an OpenGL 3.0 context at the moment (because of compatibility and SDL and stuff), maybe it will fix if I move on to a 3.2 core context?

aqnuep
01-30-2013, 07:35 PM
If you use a compatibility context (which you probably do) then vertex attribute index 0 is mandatory. Switching to a core context should fix your issue.

Alfonse Reinheart
01-30-2013, 08:15 PM
I am using an OpenGL 3.0 context at the moment (because of compatibility and SDL and stuff)

I rather doubt that. Odds are good that your driver is giving you whatever version it wants, just using the compatibility profile. So you're probably getting 3.3 or 4.2, assuming recent drivers.

In any case, yes, this is a long-standing AMD driver bug; the core profile should allow you to not need attribute 0. Both NVIDIA and AMD violate the spec on this. NVIDIA allows you to not use attribute 0 even on compatibility (where that's not legal, but see below), and AMD requires you to use it even in core.

The workaround is to always use attribute 0. I wouldn't expect AMD to fix this anytime soon.


If you use a compatibility context (which you probably do) then vertex attribute index 0 is mandatory. Switching to a core context should fix your issue.

Actually, that's no longer true for 4.3 compatibility. Because of the way they redefined how rendering works in compatibility, core and compatibility are defined to operate in the same way.

Bl00drav3n
01-30-2013, 09:17 PM
Thanks for the quick replies! I updated my code to be compatible with 3.2 core and set attribute 0, everything is working now.

Edit:

I rather doubt that. Odds are good that your driver is giving you whatever version it wants, just using the compatibility profile. So you're probably getting 3.3 or 4.2, assuming recent drivers.
I checked the GL version for my updated program:

Vendor: ATI Technologies Inc.
Renderer: AMD Radeon HD 6900 Series
Version: 3.2.12002 Core Profile Context 9.12.0.0
GLSL Version: 4.20