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.