FPS increase when switching between shaders

I made a simple JOGL application where you can switch between the shaders I made. I thought I would introduce some FPS stats just to see how efficient the shaders were. I am just rather puzzled why the FPS would increase instead of stay the same when I switch between shaders.

I first run the program going through each shader starting with Shader1 and get the average FPS:
Shader1 Avg. FPS = 75
Shader2 Avg. FPS =150
Shader3 Avg. FPS =115
Shader4 Avg. FPS =300

Then I got back to shader 1 and read the average FPS again:
Shader1 Avg. FPS = 220
Shader2 Avg. FPS = 450
Shader3 Avg. FPS = 120
Shader4 Avg. FPS = 350

I am simply using gl.glUseProgram(shaderProgram) to switch between the shaders nothing else.

Any ideas why I am getting this behaviour?
Thanks

Edit: I am currently double checking my code to make sure I am not doing something silly otherwise would there be any other reason that this would happen?

I’ve heard of some drivers recompiling shaders based on the values of uniforms. The driver might be recompiling shaders when they’re used for the first time. That would give you one slow frame in the beginning, but that hitch might be enough to drag down your overall average frame rate for each of these tests the on first time around.

Kevin B

Thanks for the reply,
I decided to try it on a computer with different drivers but I still got to same result. After a further look into my code it turns out although I was changing the shader I wasn’t removing the GLEventListener properly so the FPS calculations were essentially being done twice.

Thanks again for your suggestion sadly it was just silly programming at fault here.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.