Cost of glUseProgramObjectARB

Thanks in advance for any response…

How expensive is switching between ProgramObjects?

glUseProgramObjectARB( MyProg );
DrawTest();
glUseProgramObjectARB( 0 );

costs about 2-3 fps compared to just
DrawTest();

MyProg is a pair of trivial Vert/Frag shaders.

This is on an ATI Mobility Radeon 9800.

Does this sound correct?

Depends on how many fps you had before. 2-3fps is a neglectible cost if you were running at 1000fps, while it would be considered a major loss if you were running at 10fps.

Anyway, switching shaders is expected to come at a cost. It’s one of the most expensive state changes.

Thanks for the reply Humus -

I was running at around 100 fps and dropped to around 98 fps.

I just tried:
glUseProgramObjectARB( MyProg );
DrawTest();
glUseProgramObjectARB( 0 );
glUseProgramObjectARB( MyProg );
DrawTest();
glUseProgramObjectARB( 0 );
glUseProgramObjectARB( MyProg );
DrawTest();
glUseProgramObjectARB( 0 );

and this drops to about 88 fps.

DrawTest is trivial:
void DrawTest()
{
glMaterialfv(GL_FRONT,GL_AMBIENT,mat_black);
glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_green);
glMaterialfv(GL_FRONT,GL_SPECULAR,mat_white);
glMaterialfv(GL_FRONT, GL_EMISSION, mat_zero);
glMaterialfv(GL_FRONT,GL_SHININESS,low_shininess);
glDisable( GL_TEXTURE_2D );
glPushMatrix();
glTranslatef(getAvatar()->getX(),getAvatar()->getY()+5,getAvatar()->getZ());
glutSolidSphere(1,30,30);
glPopMatrix();
}

I just didn’t think enabling/disabling ProgramObjects was so expensive. I am planning to test on a nvidia 6800 later tonight.

BTW - Are you the Humus from http://esprit.campus.luth.se/~humus?

That site has been unavailible for a few days - and I appreciated some of the code that was there…I hope the site isn’t gone.

:frowning:

Interestingly enough, on a different machine with a Geforce 6800 GT, there is almost no discernible cost.

I get about 160 FPS with or without the series of glUseProgramObjectARB calls.

Well, that drop looks quite a bit more than expected. It may be that it’s dropping back and forth between fixed function and GLSL shader. Try switching between two different shaders instead and see if that makes as large difference.

My website will be back up soon I hope.

I believe the drop in performance is more likely tied to the change of the Material properties rather than the binding and unbinding of the shader itself.
I attended an openGL tweaking tutorial in the latest Siggraph and they mentioned something about how costly changing Material properties could get.
Try turning omitting the code where you specify the material specs and benchmark again, that might come up with a better performance. That and you can always pass the object attributes using uniforms :stuck_out_tongue:

Thanks for the reply Java Cool Dude -

But it was a driver issue. I upgraded the drivers and there is virtually no discernible cost to switching multiple ProgramObjects. GLSL here I come full-speed ahead…

BTW - I used the ati omega drivers at omegadrivers.net. Those of you with Laptops know that Catalyst drivers from ATI won’t work with the mobility chipsets. Instead, one must wait eons for the vendor to role out updates. Anyway, the Omegas still aren’t the latest Catalysts but at least they fixed the slowness. It looks like www.driverheavan.net/patje also has mobility ebnablers for Catalyst, but doesn’t support my 9800 chipset yet… :frowning:

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