Sign in to follow this  

cgGLBindProgram performance issue

This topic is 3935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I've been experimenting with Cg shaders in my engine for quite some time now, but I've mostly been using them on a limited amount of objects (boxes etc...) When I modified my program to apply a Cg shader to each object, I get an AMAZING performance drop from 200FPS --> 20FPS. I narrowed the problem down to the cgGLBindProgram() function that get's called for every object. Why does this happen? PS: another problem --> Why don't my shaders work in display lists? Is this impossible? System Specs: Geforce 7800GS and Windows Vista Thanx for helping me out, Jeroen

Share this post


Link to post
Share on other sites
Binding a shader is by far the most time-consuming thing you can do to a GPU. It forces the GPU to completely flush its pipeline, vertex cache, and texture cache. You only do it when you absolutely have to. You certainly do NOT call it for every object; you sort them so that all the objects which use the same program are drawn at once.

And shaders work fine with display lists, as long as you aren't actually trying to put CG calls in the display list.

Share this post


Link to post
Share on other sites
Thanx for the quick replies! I think sorting the objects will have a significant impact on performance, but having 10 kinds of different materials will still have a large performance drop. (10 calls to cgGLBindProgram drop the framerate from 200FPS--> 110FPS) These cgGL function calls are really heavy on resources. Using the fixed function pipeline is always at least 25% faster than using basic shaders that emulate the FFP.
Is there really nothing I can do about this?

Jeroen

Share this post


Link to post
Share on other sites

This topic is 3935 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this