View Full Version : NV: gl_PrimitiveID unavailable in TC shader

Chris Lux
11-16-2010, 04:31 PM
i just ran into the same problem described here:

I am trying to use the gl_PrimitiveID variable to access a texture buffer in the tessellation control shader and the compiler complains that the variable is not defined and i should enable the EXT_gpu_shader_4 extension:

error C7531: global variable gl_PrimitiveID requires "#extension GL_EXT_gpu_shader4 : enable" before use

This is on a OpenGL 4.1 core context in a version 410 tessellation control shader. I am using a GTX 480 on ForceWare 260.93 (also tried 261.00 and 262.99).

This just stopped me cold here.

Just some shader snippets to illustrate the problem:

#version 410 core

// input/output definitions ///////////////////////////////////////////////////////////////////////
in per_vertex {
smooth vec2 texcoord;
} vertex_in[];

out per_vertex {
smooth vec2 texcoord;
} vertex_out[];

// uniform input definitions //////////////////////////////////////////////////////////////////////
uniform samplerBuffer edge_densities;

// output layout definitions //////////////////////////////////////////////////////////////////////
layout(vertices = 3) out;


vec4 tess_outer = texelFetch(edge_densities, gl_PrimitiveID * 2);
vec4 tess_inner = texelFetch(edge_densities, gl_PrimitiveID * 2 + 1);

gl_TessLevelOuter[0] = tess_outer.x;
gl_TessLevelOuter[1] = tess_outer.y;
gl_TessLevelOuter[2] = tess_outer.z;
gl_TessLevelInner[0] = tess_inner.x;

gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;


11-17-2010, 06:57 AM
As I see it is a bug in the NVIDIA driver. I ended up with the same conclusion regarding to the other topic you've mentioned.

Chris Lux
11-17-2010, 08:51 AM
I am aware that it is a driver bug. This is the reason for posting it here.