State sorting order

What is the best order to sort state changes in for maximum performance? Is sorting by texture more important than sorting by state?

Is there a list anywhere of expensive changes vs. inexpensive changes?

I know that this question has been being posted/answered frequently lately, and I just wanted a reference for everyone to go to.

Thank you for your bandwidth.
– Succinct

[This message has been edited by Succinct (edited 05-25-2001).]

It all depends on your hardware, but generally, textures are by far the most expensive, probably followed by material and lighting changes.

  • Tom

I was thinking of sorting by geometry type is well, I have a mixture of tris, quads, and polygons (>4 verts). The triangles and quads would be a lot faster with just the single call, in my test this would usualy double the frame rate. I have changing texture not too expensive but worth sorting, especialy if you have more textures than video memory.

In the list of things to sort by, people often forget “distance from viewer”, which is getting more useful, now that chips have special Z culling hardware (HyperZ,…).

I knew that as well but I don’t think it will speed things up as much as sorting my geometry, but it is probably better than sorting out most state changes (most data will be in a `normal’ state i.e opaque etc.) maybe not on non hyper z cards

True about the geometry sorting. Although even without sorting, I got a 50% increase in frame rate just replacing the GL_POLYGON code that was used in the code before I received it with a test that starts and ends GL_TRIANGLES or GL_QUADS or GL_POLYGON as necessary.