View Full Version : Disabling GLSL Shader Program targets independently

01-08-2007, 07:49 AM
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) ?

01-08-2007, 09:51 AM
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.

01-08-2007, 10:17 AM
OK so there is nothing better... :(
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...

01-08-2007, 11:42 AM
Using multiple programs is not very practicalWhy 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.

01-08-2007, 12:41 PM
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

01-11-2007, 01:50 AM
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.