Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Optimizing Window->Display() - SwapBuffers  (Read 5628 times)

0 Members and 1 Guest are viewing this topic.

golgoth

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Optimizing Window->Display() - SwapBuffers
« on: February 04, 2011, 06:01:48 am »
Greetings,

To make a long story short, I’m working on a video player using SFML and I found what appears to be the bottle neck of rendering HD video. So far, I found that the problem reside within Swapping OpenGL buffers.

My application does its work on time, no delay, without using Window->Display(). But when turned on, I’m getting about 10%-30% latency when playing 1080p video, which is unacceptable. I’ve tried about any combinations of Window->EnableVerticalSync() and Window->SetFramerateLimit():

EnableVerticalSync(true) and SetFramerateLimit(30): (60hz LCD monitor) seams to give de best result. Playing fullscreen also helps. But still need optimization.

My first concern is the OpenGL context. ContextSettings offers very limited tweaking and I’m wondering what’s under the hood. Maybe someone can help clear a few questions:

How can we turn off double buffering?

How is the SwapBuffers handled? Are the buffers being swap or the back buffer is being copied to the front buffer? I’d like to test which one offers the best performance. (In Windows, this means setting the dwFlags in the PIXELFORMATDESCRIPTOR to PFD_SWAP_COPY.) I’m guessing it is a copy because playing 720p is very smooth.

Is there a way to optimize and/or synchronize the SwapBuffers to get minimal pipe blocking?

EDIT: Using SFML 2.0 on windows 7 x64 + GForce 8800

Thx,

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Optimizing Window->Display() - SwapBuffers
« Reply #1 on: February 04, 2011, 07:34:20 am »
Hi

You don't want to disable double-buffering, really. This is the best option, you won't get better performances by changing this. The buffers are swapped, not copied. Same thing here: you won't get better performances by changing it to a copy.

My guess is that SwapBuffers has nothing to do with your performance drop. When using OpenGL, the rendering commands are queued in the GPU and executed later, so that it doesn't block the CPU. "Later" often means "when things need to be displayed", aka "SwapBuffers" ;)
That would explain why you see the performance drop in this function. To be sure, you can put a glFlush() somewhere before Display(), and see if it takes all the CPU time.
Laurent Gomila - SFML developer

 

anything