Jump to content
  • Advertisement
Sign in to follow this  
d000hg

GetTexture()

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

Since I believe calling SetTexture is a bit slow, I wondered if comparing the desired texture against the result of GetTexture() is worthwhile. I don't currently have a central texture manager - maybe I should but that's beside the point right now - so is GetTexture also slow?

Share this post


Link to post
Share on other sites
Advertisement
I assume you are using D3D. A basic texture manager is fairly easy to make, you should consider creating one if you feel that SetTexture is too slow. I believe GetTexture is equaly as slow as it has to transfer the texture accross the bus just like SetTexture.

Share this post


Link to post
Share on other sites
I've noticed a lot about texture managers, but I have not really found a way that this can be implemented on your own. Is there a tutorial or a guide somewhere I can look at? ( I also believe that DirectX's built in methods of sending textures can be cumbersome and redundant )

Share this post


Link to post
Share on other sites
It's not so much that SetTexture is expensive as it is that changing the texture is expensive. Organizing your scene so you can draw groups together is the best way to reduce this cost. If your scene has 5 objects that use texture A and 5 that use Texture B:
SetTexture(A)
Draw all objects using texture A
SetTexture(B)
Draw all objects using texture B

It can get more complicated than that, but it's the basic idea.

Share this post


Link to post
Share on other sites
ok, for a while I didn't realize that after drawing the object, the texture information stays in GPU memory. With that said, I can probably find a few methods on my own to optimize the texture transferring traffic to and from the GPU. Is there anything else worth knowing when talking about texture management?

Share this post


Link to post
Share on other sites
I'm aware that grouping by texture is generally a good move, but sometimes this can be a bit of work to implement. I have a render/texture - state manager but since I'm working for 4E4 any non-critical things don't make the cut! I guess I could just save the pointer to the IDirect3DTexture8 interface for the current textures for stage 0,1,... and check them against the texture I want to draw with. At least then I only set the texture when required!

Share this post


Link to post
Share on other sites
Using texture coordinates to combine what would otherwise be separate textures can yield tremendous speed gains because you avoid SetTexture calls.

Share this post


Link to post
Share on other sites
Quote:
Original post by d000hg
I'm aware that grouping by texture is generally a good move, but sometimes this can be a bit of work to implement. I have a render/texture - state manager but since I'm working for 4E4 any non-critical things don't make the cut! I guess I could just save the pointer to the IDirect3DTexture8 interface for the current textures for stage 0,1,... and check them against the texture I want to draw with. At least then I only set the texture when required!


Setting a texture that is already set is not that expensive.

Share this post


Link to post
Share on other sites
Quote:
Original post by DrunkenHyena
Quote:
Original post by d000hg
I'm aware that grouping by texture is generally a good move, but sometimes this can be a bit of work to implement. I have a render/texture - state manager but since I'm working for 4E4 any non-critical things don't make the cut! I guess I could just save the pointer to the IDirect3DTexture8 interface for the current textures for stage 0,1,... and check them against the texture I want to draw with. At least then I only set the texture when required!


Setting a texture that is already set is not that expensive.

Indeed. The Direct3D runtime will filter this redundant state change, even with a pure device.

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!