Sign in to follow this  
deavik

Display lists and material state changes

Recommended Posts

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)?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
@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]).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this