Display lists and material state changes

Started by
7 comments, last by deavik 18 years, 5 months ago
I read somewhere, in the red book I think, that when material state changes are put in a display list, they are optimized so that they don't matter (performance-wise) as much as if I did them in immediate mode drawing. I have a model format (ac3d) in which each surface, as I run through them, maybe assigned a different material, like: surface0 -> material1 surface1 -> material5 surface2 -> material0 Will it be OK to execute all these material changes in a display list, or should I still loop through the surfaces, sort them by material and then put them in a display list (with less material state changes)?
Advertisement
Quote:Will it be OK to execute all these material changes in a display list

no
Quote:
, or should I still loop through the surfaces, sort them by material and then put them in a display list (with less material state changes)?

DLs do help (i believe doom3 uses them for state changes im not 100% sure though ) but they wont magically make an inefficent design efficent
I believe that was enabling GL_COLOR_MATERIAL, not putting the textures in a display list. I believe all it said about putting them in a display list was basically that it made it easy to switch. I could well be wrong, but it might be worth checking whether what you remember reading was in fact what you read.
Keys to success: Ability, ambition and opportunity.
@zedzeek, thanks for the input. I am going to be making a few material state changes anyway (with the least being the number of materials I have), I was just wondering if the number of chanegs I make matters (because if it does I will have to sort the geometry before hand so that surfaces with 1 material go together). What do you think an 'efficient' design is in this case, and what I am I losing with what I am planning?

LilBudyWizer, I am going to quote the Red Book here:
Quote:When you draw a scene with complex lighting conditions, you might change the materials for each item in the scene. Setting the materials can be slow, since it might involve significant calculations. If you put the material definitions in display lists, these calculations don't have to be done each time you switch materials, since only the results of the calculations need to be stored; as a result, rendering lit scenes might be faster.

The impression I got from this was that since I am precalculating the material changes anyway, it would not matter if there were 5 or 50 state changes inside the display list - but of course I might be completely wrong (which is why I started this thread [smile]).
Quote:Original post by deavik

The impression I got from this was that since I am precalculating the material changes anyway, it would not matter if there were 5 or 50 state changes inside the display list - but of course I might be completely wrong (which is why I started this thread [smile]).


That is correct. As the changes itself are compiled into the display list it doesn't matter. But as the display list is compiled into memory, the executeable size could get larger I think. Plus state changes are expensive operations anyway so you want to do it to a minimum so I would assume its best to sort by material.

Plus chances are you will be using the same material more than once.

The more applications I write, more I find out how less I know
Quote:Original post by CRACK123
That is correct. As the changes itself are compiled into the display list it doesn't matter. But as the display list is compiled into memory, the executeable size could get larger I think. Plus state changes are expensive operations anyway so you want to do it to a minimum so I would assume its best to sort by material.

Plus chances are you will be using the same material more than once.

Thanks for the nice answer, Crack. I will be doing the compile-display-list operation only once - during loading so I'm not really bothered about it being expensive then.

But it's back to the testing boards regarding the 'do-state-changes-really-matter-in-a-display-list' question, I guess (unless someone can please confirm it for me!). I may do some benchmarking when I get my loader working, I'll be sure to let you know how it comes along.

Nice to see someone from ol' India up here in Gamedev!
Quote:it would not matter if there were 5 or 50 state changes inside the display list

a DL is not magical ie a DL with 50statechanges will still be far more expensive than one with 5 statechanges
I could find the actual passage when I was posting so that was why I suggested reviewing what you read. Personally, I take might as a qualified won't or at least if it does it is so slight it doesn't matter.
Keys to success: Ability, ambition and opportunity.
Great, thanks for the confirmation, zedzeek and LilBudyWizer!

This topic is closed to new replies.

Advertisement