My fragment shader was significantly slowed down by a recent change, and I've been trying to understand why.
I isolated the main slow-down to accessing a single particular uniform float. If I include this line:
float not_used = my_uniform;
then the shader runs more than twice as slowly as it does without this line. The not_used
float is never referenced again.
Why would this be happening? I hope to understand it so that I can try to come up with a workaround that runs more quickly.
I'm running this on a mac with Intel HD Graphics 3000. I'm measuring the performance by making OpenGL timestamp queries before and after executing my glDraw
calls and looking at the ms intervals. I can provide more specs / details if it would be helpful in diagnosing the problem.
glFinish()
or your buffer swapping functions, so the code actually gets executed. Also a decent glsl compiler should remove any unused uniforms from your code. \$\endgroup\$gl{Begin,End}Query
withGL_TIME_ELAPSED
as the metric. This setup is designed to take into account the way OpenGL commands are executed asynchronously with the CPU. See opengl.org/registry/specs/ARB/timer_query.txt \$\endgroup\$