PDA

View Full Version : glutSwapBuffers: How to execute that in plan GL ?



Marcio Braga
08-10-2008, 09:41 AM
Hello, (new to openGL)

I'm finding glutSwapBuffers() function a bit slow in some circumstances. I would like to try with equivalent commands in plain GL but I could not find them.

Can someone give me some help/directions on that ?
(I'm using Ruby just in case language implementation became important).

Thank you.

ZbuffeR
08-10-2008, 01:37 PM
swapping buffers is not slow, check doing a glFlush right before.

Marcio Braga
08-11-2008, 10:57 AM
Well, glFlush() before glutSwapBuffers() did not improved.

Let me explain my scenario:

1. The model is a simple 35500 vertex rendered as GL_POINTS.
2. My machine needs 30 ms to render those points in a non-buffered view (GLUT_SINGLE) using just the CPU.
3. Needs only 0.15 ms in a non-buffered view but now using the GPU (via glNewList(x, GL_COMPILE).
4. 30 ms in a buffered view (GLUT_DOUBLE) with CPU.
5. 17 ms buffered view with GPU.
6. 17 ms to render nothing in a buffered view (just simple execution of the glutSwapBuffers).

And doing a glFlush right before does not change these numbers.
Am I missing something or doing something wrong ?

Thank you
Marcio

ZbuffeR
08-11-2008, 03:25 PM
The actual cost of swapping buffers is negligible.
What you see is probably an effect of vsync. Before doing benchmarks, disable it, otherwise you only measure your display refresh rate.
ie : 1 s /60 Hz = 16.667 ms

Marcio Braga
08-11-2008, 06:49 PM
Bingo! Thank you very much.

Turning off vsync resolved my "issue".

mikau
08-19-2008, 04:47 PM
"swapping buffers is not slow, check doing a glFlush right before"

Yeah, but doesn't glutSwapBuffers() block until all previously sent data flows out of the rendering pipeline and into the frame buffer before swapping?

ZbuffeR
08-20-2008, 01:31 AM
My mistake, I meant glFinish().
Normally swapbuffers implies glFlush(), not a glFinish(). Of course the implementation can do a glFinish() instead.
What happens is that the card can buffer a bunch of GL commands before blocking, so you can already have submitted multiple frames without blocking, and before they are actually drawn.