Advertisement

cost of texturing

Started by February 18, 2002 09:49 PM
2 comments, last by Cel 23 years ago
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
Cel aka Razehttp://chopper2k.qgl.org
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).
Advertisement
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
> 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).

This topic is closed to new replies.

Advertisement