GetTexture()

Started by
7 comments, last by Muhammad Haggag 18 years, 8 months ago
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?
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.
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 )
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.
Stay Casual,KenDrunken Hyena
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?
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!
Using texture coordinates to combine what would otherwise be separate textures can yield tremendous speed gains because you avoid SetTexture calls.
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.
Stay Casual,KenDrunken Hyena
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.

This topic is closed to new replies.

Advertisement