my video card:
“OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: Quadro FX 4500/PCI/SSE2
OpenGL version string: 2.1.2 NVIDIA 165.33.08”,
I believe it is good enough to support high level shader language.
Unfortunately looks it is not supporting dynamic branch with my application. Is there anyway I can have it support those kind of features? Does openGL has any variable setting to control over it?
The 4500 is based on the G70 core, so it should have support for dynamic branching in fragment shaders. You can’t turn it on or off, it should just work. How did you reach your conclusion that it does not work?
I have some code like:
vec4 color = vec4(0.0);
if( p_flag == 0 )
// multiple level convolution A, heavy
// set color value
//multiple level convolution B, heavy
// set color value
// Combine with the regular color to pick up brightness
// and transparency.
vec4 base = gl_FrontMaterial.diffuse;
color = color *base;
gl_FragColor = color;
it runs very slow, but if I separate the if/else into two shaders. the performance is improved a lot.
check back to my original post for more details: Post229362.
also, one of my colleague found the similar problem too.
It is very probable that compiler desides to implement this shader as a conditional assignment. If this happens, you can do nothing about it. Still, if p_flag is a uniform, you should use two different shaders and switch them when needed.
yes, p_flag is a uniform passed from opengl api.
unfortunately, not all the switches can be separated to different shades.
Then use #ifdefs and prepend the appropriate #defines to the shader source. =)
The G70 has rather poor dynamic branching performance. For this reason, the driver may decide to flatten the branch, or if it doesn’t the branching performance may simply be this poor. What’s the exact performance difference?
Also, do you have any regular texture lookups in the branches? That could affect whether the driver decides to flatten the branch or not.
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.