PDA

View Full Version : Sorting by buffers, textures, or programs?



Verdagon
03-30-2011, 03:19 AM
So... right now I do a pass for all normal objects, and then another pass for any part of any object that's bloomed. Inbetween I set the glDrawBuffers to the right targets so the bloomed stuff goes to a different buffer than the normal stuff. This is to avoid having to do glDrawBuffers too many times. In a way, you could say I'm... "sorting by destination buffer".

But there's other things I could sort by, such as which shader I'm using, or which textures I'm using...

Choosing between which method to sort by requires some sort of estimate on how much time I'll save with each method. So I'm wondering, which do you think is the slowest:

A. glDrawBuffers calls roughly once every three objects, as opposed to once or twice per frame (i only have two targets)
B. glBindTexture calls roughly once every object, as opposed to twenty times a frame (ill have twenty textures)
C. glUseProgram calls roughly once every object, as opposed to eight times a frame (ive got eight shaders)

I'm about to try experimenting, but this experiment will take a few hours, so I was hoping you had an idea to save me that time...

Thoughts would be much appreciated =)

Ilian Dinev
04-02-2011, 08:02 AM
fbo, programs, textures. fbo/drawbuffers is slowest.