'ftransform()' and custom vertex attributes

Hi everyone,

I recently stumbled upon a problem on <s>ATI</s> AMD Catalyst 9.4 + Radeon HD 2600.

My shaders use the ‘gl_Position = ftransform()’ construct, and only custom vertex attributes - passed using glVertexAttribPointer.

I have the following error :


Fragment shader(s) linked,  vertex shader(s) failed to link.

If I replace ‘ftransform()’ to have ‘gl_Position = gl_ModelViewProjectionMatrix * my_vertex’, the error goes away.

If I stop using custom attributes, revert to glVertexPointer usage, and especially remove the call to ‘glBindAttribLocationARB( programID, 0, “my_vertex” )’, the error also goes away.

I could not find any clear indication in specs about using ‘ftransform()’ and custom attributes. Is it ‘legal’ behaviour ? I suppose so as the error is not explicit, and it works fine on NVidia (which is not a strong warrant about GLSL ‘legality’).

Does anyone have met this problem before ? Is there any know workaround (except for patching the shader) ?

Cheers,

Nicolas.

EDIT :: It seems that on simpler shaders, I can have ‘ftransform()’ work as expected on the same platform. It looks more and more like a driver bug to me.

EDIT :: The problem also exists with Catalyst 9.5 - the simpler shaders that reproduce the problem are :


attribute vec4 my_vertex;
varying vec4 vertex;
  
void main()
{
  // this causes the error, if my_vertex is replaced by gl_Vertex, the error goes away
  vertex = my_vertex;             
  gl_Position = ftransform();
}


void main()
{
  gl_FragColor = vec4( 1.0 );
}


Fragment shader(s) linked,  vertex shader(s) failed to link.

AFAIK, a vertex or fragment shader does not link but a shader program links. This output is really weird to me.

Are you sure that your vertex shader has been successfully compiled?

“If I stop using custom attributes, revert to glVertexPointer usage, and especially remove the call to ‘glBindAttribLocationARB( programID, 0, “my_vertex” )’, the error also goes away.”
“I could not find any clear indication in specs about using ‘ftransform()’ and custom attributes”

ftransform is same as gl_ModelViewProjectionMatrix * gl_Vertex with some guarantee that on multiple passes rasterization matchs. seems as long as you dont use glVertexPointer the gl_Vertex is undefined but i dont get if you need to compile a shader program in the first place no matter if using glVertexPointer somewhere or own attributes? Shader program doesnt know that.

It seems to me, that if you provide your own custom vertex attribute 0, GLSL can’t assume that you actually provide the vertex position in attribute 0. ftransform() cannot be performed, because GLSL doesn’t know where to get the vertex position from.

Are you sure that your vertex shader has been successfully compiled?

Yes, I have no error coming from ‘glCompileShader’, but the error I gave come from ‘glLinkProgram’.

… glVertexPointer … Shader program doesnt know that.

In fact, the error appears if I call ‘glBindAttribLocation(program, 0, “my_vertex”)’ before ‘glLinkProgram’ - I mentioned glVertexPointer, but, indeed, it has nothing to do with the link error.

GLSL can’t assume that you actually provide the vertex position in attribute 0

My understanding of GL<3 spec (after that I don’t know) is, on the contrary, that ‘generic attribute zero’ is an alias for the ‘conventional vertex position (gl Vertex)’. To quote the OpenGL2 spec ::


Setting generic vertex attribute zero specifies a vertex; the four vertex coordinates
are taken from the values of attribute zero. A Vertex2, Vertex3, or Vertex4
command is completely equivalent to the corresponding VertexAttrib* command
with an index of zero.

This seems to be the cause of the problem, using both ‘my_vertex’ and ‘gl_Vertex’ (implicitly via ftransform()) in the vertex shader…

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