nVidia GLSL compiler bug?

I have come across an unusual problem with the following two shaders (Vertex and Geometry) which fail to link on nVidia h/w.

With AMD’s GPU ShaderAnaylyser, I change the GLSL version number to 150 (becuase it does not support 330 or higher) and can successfully compile both the Vertex and Geometry Shaders:


#version 330 compatibility

#extension GL_EXT_gpu_shader4 : enable
#define texture_buffer_object


/*
Grass shader - Transform feedback Vertex shader


Grass[n] instance data is uploaded to TBO as 2 * RGBA 32-bit floats

  Position: Tvertex3f	//32-bit positions
  scale: glfloat;
  Color: TColor3f;	//alpha is calulated
  Frame: glfloat;
*/


out vec4 emit_position;		//vertex data
flat out vec4 emit_color;	//vertex color
flat out float emit_alpha;	//transparency

uniform samplerBuffer instancedatabuffer;
uniform usamplerBuffer renderlistbuffer;
uniform vec4 cameraposition;	//xyz = camera position; w=Grass Camera Cull Range



void main()
{
//instance data are indexed as 2 blocks of 4 RGBA floats
   int batchindex = 2 * int(texelFetchBuffer( renderlistbuffer, gl_InstanceID).r);	//get the real batch instance from the render list (supplied as an integer texture buffer)
   emit_position = texelFetchBuffer( instancedatabuffer, batchindex);			//vertex position, scale

   emit_color = texelFetchBuffer( instancedatabuffer, batchindex+1);		//2nd block of RGBA = color, frame
   float distancefromcamera = distance (cameraposition.xyz, emit_position.rgb);
   float alpha = clamp (distancefromcamera / cameraposition.w, 0.0, 1.0);
   emit_alpha = 1.0 - alpha;

}

which is linked to the following Geometry shader (there is no Fragment Shader to be linked):


/*
Grass Transform Feedback Geometry shader
*/
#version 330 compatibility

layout(points) in;
layout(points, max_vertices = 1) out;


in vec4 emit_position[1];		//vertex data
flat in vec4 emit_color[1];
flat in float emit_alpha[1];

out vec4 vtx_out;		//vertex data  - stream #1
flat out vec4 color_out;	//color - stream #2
flat out float alpha_out;	//transparency - stream #3


void main() {
      vtx_out = emit_position[0];
      color_out = emit_color[0];
      alpha_out = emit_alpha[0];
      EmitVertex();
      EndPrimitive();
}


However, when running my engine and letting the nVidia drivers compile the same Vertex shader, I get the following error:

Program link info:
Varying (named position_out) specified but not present in the program object.

Does anyone have a clue with the error - I don’t use any varyings with the name ‘position_out’ so it must be a driver/GLSL compiler bug. I have tried to use the name position_out as one of the in/out varyings, but that did not solve the problem either.

nVidia Geforce 8600GT (mobile)
OpenGL 3.30 compatible profile
Drivers packages 280.26 and 285.62, Windows Vista 32-bit.

Thanks you for sharing

Perhaps the compiler doesn’t like the fact that gl_Position isn’t being written to. If you change emit_position to gl_Position, does your link error go away?

thanks for your reply.
No, adding gl_Position to the Veretx Shader has made no difference.

I have written other VS and GS shader pairs in the past and these don’t suffer from this problem.
The only thing I can see which is perhaps unusual (but not against the spec) is the VS is truly attribute-less - i.e. no per-vertex input.
I don’t need any per-vertex attributes as all the data I need I source from the buffer objects in the shader. I can’t see anything wrong with that.

In the GS, write to gl_Position.

in the GS I wrote to the gl_Position - still fails to link (same error as before).

I just got the same error with 290.10 and a Quadro 4000, while debugging one of my own shaders. It happens if you call glTransformFeedbackVaryings() with a varying name that doesn’t exist in the program.

I just got the same error with 290.10 and a Quadro 4000, while debugging one of my own shaders. It happens if you call glTransformFeedbackVaryings() with a varying name that doesn’t exist in the program.

Yes that was it!
Thanks for that. The TransformFeedBackVaring names I was supplying was not correct. Where I was tweeking the shader I had forgotten to check which variable names were being transformed.

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