Ok that doesn’t sound like much but when you’re calling it 100,000 times a frame it is
I know what you’re thinking, use vertex arrays. I can’t in this app because I need to change projection/modelview every few polys, also I have to change scissor tests. So I think I’m stuck with immediate mode. The matrix loading and scissor code is not the bottleneck, its the glBegins and to a lesser extent glEnable/Disable of blending. (I already have coded it to make sure I do these a few times as possible).
So my question is why does it take so long. There seems to be no code checking whether any of the setup is relevent since it takes the same time if you call it twice with no state changes in between. I suppose checking might in a few cases slow it down further. It all depends what is taking the time, if it is a variety of small things then it’s impossible to optimise but if it were doing a lot of processing because of one possible state change then maybe it can be. (I’m sure if it was this obvious it would have been done already)
Here are some benchmarks. The numbers are milliseconds to perform an begin/end/enable/disable 1000 times. I overclocked/underclocked my FSB and GPU to determine where the bottleneck lay. It mostly seems to be dependent on the FSB/CPU.
-33% FSB +10% GPU
glBegin/glEnd
GL_QUADS WO FINISH 123
GL_QUADS W FINISH 5816
glEnable/glDisable
GL_BLEND WO FINISH 181
GL_BLEND W FINISH 5754
glEnable/glDisable
GL_TEXTURE_2D WO FINISH 94
GL_TEXTURE_2D W FINISH 248
-33% FSB -10% GPU
GL_QUADS WO FINISH 125
GL_QUADS W FINISH 5799
GL_BLEND WO FINISH 197
GL_BLEND W FINISH 5845
GL_TEXTURE_2D WO FINISH 94
GL_TEXTURE_2D W FINISH 236
+5% FSB +0% GPU
GL_QUADS WO FINISH 93
GL_QUADS W FINISH 4777
GL_BLEND WO FINISH 162
GL_BLEND W FINISH 4715
GL_TEXTURE_2D WO FINISH 68
GL_TEXTURE_2D W FINISH 183
So if you have any information as to why it takes the time it does I’d be interested to hear. Or if you know how I can get around this.
btw, those benches were on a XP2000 GF4.
[This message has been edited by Adrian (edited 01-09-2003).]
[This message has been edited by Adrian (edited 01-09-2003).]