Original Post
I have a question about the performance of some commands in the GLSL fragment programs. Essentially, if I add an "if" statement to the fragment program I get a drop from about 128 FPS to 108 FPS. So my question is, should an if statement create such a large drop in FPS? The hardware I am using for this particular test is a Radeon9800 Pro, and it was run at full_screen on a 1600x1200 display. Here is the sample code from my fragment program that I used to see the difference This one does 108 FPS This does 128 FPS - doesn't make much sense as a fragment program. But I had to make sure all the same multiplies etc were being performed as the last one After typing this all up and making sure the fragment programs were performing essentially the same operations, (minus the if statement) I guess I'm not as surprised to see the frame hit with a single if statment. The point of this whole post was to try to discover a way to speed up my fragment program. I recently switched to FrameBufferObjects from PBuffers, and VBO'd some of my geometry. In the end I gained no noticeable increase in the FPS. So I'm assuming I am fill rate limited at this point. The current frag program I use is the 108fps one. I am also doing a sanity check here in the forums to see if a Radeon9800 may be limited in some of its functionality, thus causing some of the loss in performance. Thanks for any tips or help :)
//The images from the two seperate RenderChannels
uniform sampler2D leftside;
uniform sampler2D rightside;
//Passed in uniforms to figure out which render channel to sample from
uniform vec4 user_pos;
uniform vec3 plane_vec;
//The pixel positions in each of the render channel's eye space, and the world space
varying vec4 left_vert_position;
varying vec4 right_vert_position;
//World space pixel position
varying vec4 vert_position;
void main()
{
vec4 out_color;
vec3 pos_vec = vert_position.xyz - user_pos.xyz;
//Channel Testing
float plane_check = dot(pos_vec, plane_vec);
if (plane_check <= 0.0) //Sample from the Left Render Channel
{
out_color = texture2DProj(leftside, left_vert_position);
}
else //Sample from the Right Render Channel
{
out_color = texture2DProj(rightside, right_vert_position);
}
gl_FragColor = out_color;
}
//The images from the two seperate RenderChannels
uniform sampler2D leftside;
uniform sampler2D rightside;
//Passed in uniforms to figure out which render channel to sample from
uniform vec4 user_pos;
uniform vec3 plane_vec;
//The pixel positions in each of the render channel's eye space, and the world space
varying vec4 left_vert_position;
varying vec4 right_vert_position;
//World space pixel position
varying vec4 vert_position;
void main()
{
vec4 out_color;
vec3 pos_vec = vert_position.xyz - user_pos.xyz;
//Channel Testing
float plane_check = dot(pos_vec, plane_vec);
out_color = texture2DProj(leftside, left_vert_position) * texture2DProj(rightside, right_vert_position) * plane_check;
gl_FragColor = out_color;
}