In general, branching in shaders is not a good idea. But now I have a shader with a condition that is constant with respect to the entire draw call. So the branch that is executed is always the same for one draw call.
Is such kind of branching still more costly than having multiple shaders without these branches and switch between them?
if (true) { ... }
around the entire program would measurably alter the performance (assuming it's not optimized it out, which it would be). – jozxyqk Aug 18 '15 at 09:02if (false) { ... }
but yes. :) – Martin Ender Aug 18 '15 at 09:04Is condition anyway will be executed every time?
Are you asking whether the condition is calculated for each pixel/vertex/fragment, or whether the condition is recalculated each time the shader is applied? – trichoplax is on Codidact now Aug 18 '15 at 13:31