Jump to content
  • Advertisement
Sign in to follow this  
PDX_Catalyst

XNA setting same texture over and over... slow!

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

I was checking out PIX to see what my program was doing and I noticed SetTexture over and over again, as expected really. I also noticed it's time consuming, verifying something I already knew. Before I started using XNA I called SetTexture myself, so if I was going to use the same texture over and over I would only set it once. When drawing the tree models, however, XNA seems to set it every time. It even sets one texture 3 times for each model since 3 meshes use it... all in a row. Is there some kind of solution to this? ~ C

Share this post


Link to post
Share on other sites
Advertisement
BTW... when drawing 300 trees in a row it's doing several things over and over that it shouldn't need to since they don't change. Every mesh has its own copy of the effect. Seems like I should be able to set up the effect and then draw 300 trees without doing it again 299 extra times.

These things over and over seem horribly redundant and wasteful...

SetTexture(0, 0x05D4B400)
SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE)
SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE)
SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE)
SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR)
SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_MIRROR)
SetVertexDeclaration(0x0A400708)

Share this post


Link to post
Share on other sites
Are you using the default Model class? If so that could be why. The default Model class is set up to be independently used; not for batching. There was a new tutorial released showing custom model classes at the creators.xna.com site. My suggestion would be to create a custom model class that takes into account texture sharing and effect sharing.

The default Model class was designed to be very basic and the overall structure was just put there to give a jump-start for beginners. It's rather easy to create a custom model class and then you could easily batch together rendering models and parts of models without switching all those states.

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!