Jump to content
  • Advertisement
Sign in to follow this  
eDuDe

Switching Shaders: Expensive?

This topic is 3818 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

Been working on a graphics engine (Direct X) for a game project that I'll be working on sometime in the future, and just got everything up and running. Can do the basics. Working on a 3D Drawable component, and it was fairly basic, but it contained a pointer to the shader and had a "draw self" function. The problem is that by organizing it this way is that I'll be constantly switching shaders as I draw all my objects (so far they're not sorted by shader). I heard through the grape vine that switching shaders was pretty expensive, and it would be best to render everything that uses one shader, then switch to the next. Any truth to this? Is it worth keeping a draw list sorted by shader?

Share this post


Link to post
Share on other sites
Advertisement
I've heard the same thing, even with other objects like textures and vertex buffers. It's kind of an irritating phenomenon since most games used a lot of different materials and having to program certain aspects around slow 'switching' of objects must add a bit salt to the equation.

Share this post


Link to post
Share on other sites
Apart from render target changes and Present, shader changes are the most expensive thing you can do. So yeah, you should strive to avoid them.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!