Archived

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

Cel

cost of texturing

Recommended Posts

Hi, I am wondering how expensive it is to change the current texture being used by OpenGL via the glBindTexture command? Would it be worthwhile organizing a mesh ordering it by which texture it uses (like grouping by texture type)? I haven''t had a chance to test the performance hit properly of changing the texture rapidly.... Thanks, Cel

Share this post


Link to post
Share on other sites
That''s like asking, "is it worth is to organize my data do that i access my arrays in a cache-friendly manner?"

Pretend you were making hardware to rasterize triangles...how expensive do you think it would be to stall the pipeline, flush all the pixels through, and wait for everything to be written into the depth & color buffers before swapping textures?

To sum this up, yes, it does make a difference, especially since it takes about 2 lines of code to sort a mesh by texture(use std::sort and overload operator< on your data structures).

Share this post


Link to post
Share on other sites
On software: not realy much diffrence, though, depends on the driver. It is useful to do as many calculations durig setup as posible.

On hardware: You can have several texture binds per frame, and still be cool. If you sorted them, it is a great idea. I wouldn''t go so far as to sort ever poly that you are about to draw in the world (a couple per object is acceptable)

A better idea would be to use only one texture per object if you can manage it.


ANDREW RUSSELL STUDIOS
Resist nes8bit :: Bow Down to Linux Communisum

Share this post


Link to post
Share on other sites
> how expensive do you think it would be to stall the pipeline, flush all the pixels through, and wait for everything to be written into the depth & color buffers before swapping textures?

The hardware doesn''t flush any buffers, not even the fifo, if a texture state has changed. Performance would be terrible. Although state change is expensive (since lots of internal GPU registers and pointers have to be changed) you can safely use 40+ texture state changes per frame. But sort your data, if possible, it can only be beneficial. It might not always be possible, though (transparent objects, here you have to depth sort, so clustering all same textures isn''t possible).

Share this post


Link to post
Share on other sites