expensive states and sorting?

is setting shaders more epxensive than setting textures? some 1 told me setting a shader reset the whole pipleline, making it more expensive.

I’m currently working on some tree/graph system to try to sort my rendering states, and need to know the most expensive to least expensive
(if any 1 has any good references, i’d like to know :] )

my gues:

  1. shaders
  2. textures
  3. fixed function materials /lighting/ blending modes etc…

Switching shaders is really expensive, because there’s only very limited instruction space on the cards, so you have to potentially stall the pipeline, and shuffle new data into the execution slots, before you can start the next batch.

On any card where textures actually fit in VRAM, I wouldn’t think switching textures is any more expensive than, say, switching texgen mode.

In fact, I wouldn’t be surprised if any kind of per-batch data was directly proportional to the size of the data, i e how long it takes to send across the bus. Perhaps there’s a difference between vertex-only data versus rasterization data, because the vertex affecting data can overlap with rasterization of the last poly of the previous batch, but rasterization data typically can’t.

If there are specific states on specific cards you worry about, I would benchmark on the particular card using actual data.