What takes most cpu cycles when doing swapbuffers?

Started by Mickelukas, March 29, 2011, 13:21:05

Previous topic - Next topic

Mickelukas

Hi gurus,

I just did lots of performance testing on my game and currently the fps is cpu bottlenecked. When analyzing the time spent it's in the nswapbuffers method called by Display.update().

I doubt you can do anything about that in lwjgl (I searched for it first ;))

Now to my question, how can I improve the cpu usage on swapbuffers? I'm already using VBO's for most objects (and when turning the non VBO things off I still get the same fps). I'm using Triangle strips to lower the number of vertices sent. I did notice some slowdowns when using Quads with alpha test so I'm sticking to triangles/triangle strips for now.

What is it that causes cpu cycles on swap buffers? lights? textures?

I'm currently drawing like 6000 vertices and getting about 500fps on my laptop, but it's quite powerful and I don't want it to be choppy on older computers.

Any clarification will help.

Kind regards,
Mike

avm1979

Hmm.  If you're using VBOs for just about everything, you're hardly doing anything in the main loop aside from telling OpenGL to draw those and then do a Display.update(), right?  I'm guessing that the update doesn't take very much time but the results you're getting are skewed because you're basically not doing anything else in the loop.


500 fps is a LOT.  You could go almost 10x slower and still have it be very smooth - is there really any reason to be concerned about lower end hardware?  Is your laptop *that* good?

CodeBunny

Agreed, 6000 vertices at 500 fps is quite good, you probably just have a very efficient program everywhere else. :)

Mickelukas

Well, it's a corei7 thing so it's quite nice. My stationary is a E8500 from 2 years ago and it gets about 1500-2000fps with the same ~6000 vertices.

I guess I should be happy with the 2ms loop time and focus my time somewhere else :)

Thanks guys,
Mike

Fool Running

Quote from: Mickelukas on March 29, 2011, 13:21:05
I just did lots of performance testing on my game and currently the fps is cpu bottlenecked. When analyzing the time spent it's in the nswapbuffers method called by Display.update().
I think (someone can correct me if I'm wrong), that you are actually GPU bottlenecked if the CPU time is in swapBuffers(). SwapBuffers blocks until the GPU is finished rendering. If you were CPU bottlenecked, then the time would be spent in your rendering code, not in swapBuffers().
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

Mickelukas

Oh, that was a really nice piece of information, saves me from tuning too much on cpu level.

Mike