Disabling GLSL Shader Program targets independently

I wonder what is the most efficient way to disable a vertex, fragment or geometry shader contained into an GLSL Shader program ? (like what is allowed in Cg)
The only way I see is detaching the corresponding shader from the program and then relinking.
But won’t this cause the whole program to be recompiled (NVidia stating in it’s spec that shaders compilation really occurred when program link) ?

  1. You can make multiple programs with different linking.

  2. if the hardware supports branching you can switch on and of different parts of the shader by using uniforms.

OK so there is nothing better… :frowning:
Using multiple programs is not very practical, it force to multiply program for each configuration (with geometry, with vertex and without fragment shader or without geometry, with fragment and with vertex etc…). It also multiply parameters update code for instance.
And using dynamic branching is not efficient at all…

Using multiple programs is not very practical
Why not?

It’s not like shader programs are massive resource hogs or anything. It’s merely a matter of knowing what you need and building it.

About detaching shaders - does anybody know if the following issue on Radeons is fixet yet? :
-attach shader objects
-link program
-detach shader objects <- damages program

you have this keyword that could help you:


The discard keyword can only be used in fragment shaders. It causes the termination of the shader for the current fragment without writing to the frame buffer, or depth.

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