Jump to content
  • Advertisement
Sign in to follow this  
godmodder

cgGLBindProgram performance issue

This topic is 4293 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
Advertisement
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
In addition to binding the program, cgGLBindProgram also sets up parameters and textures. So it's definately a function you want to minimize calling.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!