Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Changing texture stages mid loop

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

How fast is it to change texture stages 0 and 1 in midpoint game? I was always under the impression that you should set your stages at the beginning of the app, and leave them the way they are throughout the life of the app. Just curious what you all do!

Share this post

Link to post
Share on other sites
Changing rendering state is usually unavoidable. The key is to not change it when you don''t need to. Try to keep all state changes together so that all of the state changes required to render something are set near to each other.

Underneath the surface, the graphics chip has a bunch of states and registers which are DIFFERENT to the "ideal" model D3D (or OpenGL) presents. For example changing a single renderstate in D3D might change 4 internal states. And vice versa - the affect of 4 D3D render states might all just be flags in a single hardware state.

This means that the device driver has to translate from D3D states into internal hardware states. Changing one texture stage state may require ALL internal hardware states to be re-computed on some devices. This is why you shouldn''t change when you don''t need to.

A more expensive change is for the texture itself - sometimes that might mean D3D uploading a new texture from system memory to video memory.

Even more expensive to change is vertex or pixel shader.


- It''s OK to change states, textures and shaders during a frame.

- But don''t do it excessively (e.g. keep texture changes below say 100, keep shader changes below say 50)

- Sort your rendering first by shader, then by texture, finally by render states

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!