PDA

View Full Version : SwapBuffers blocks for multiple windows



markr
09-01-2008, 01:46 AM
Hello,

I have several double-buffered windows, and I display them by calling the corresponding SwapBuffers() one after another. I observe that starting from the second window, the SwapBuffers() call blocks, although it displays each time a different window!

How can I overcome this?

Should WGL_NV_swap_group extension enable doing this?

Thanks.

Dark Photon
09-01-2008, 06:46 AM
I have several double-buffered windows, and I display them by calling the corresponding SwapBuffers() one after another. I observe that starting from the second window, the SwapBuffers() call blocks, although it displays each time a different window! How can I overcome this? Should WGL_NV_swap_group extension enable doing this?
Couple methods.

1) Disable sync to vblank and do your own sync. This is undesirable since it can result in tearing.

2) Or as you suggest, put the windows in the same swap group. Potential con: NVidia specific, and potentially NVidia-Quadro with GSync specific. Not sure.

3) Or Use SwapInterval if supported (SGI_swap_control/EXT_swap_control). Note sure but may be able to trick the driver to swap/noswap/swap/noswap/etc. Haven't used it myself.

4) Also I wonder about using multiple threads, one per window, and having each sync-to-vblank. Yeah, you've got the thread/context swap overhead, but maybe the driver syncs for each thread/context separately.

markr
09-02-2008, 04:03 AM
Thanks for the reply.
Can you please elaborate about option 3 ?

ZbuffeR
09-02-2008, 11:13 AM
3 is prbably something like :

set interval to 0 (=no vsync)
draw window 1
swap
draw window 2
swap
set interval to 1 (=vsync)
draw window 2
swap

markr
09-02-2008, 10:21 PM
Thanks. But how this may help (improve swap time without tearing)?

Ilian Dinev
09-03-2008, 01:25 PM
This will (hopefully always) do the following:
quickly draw to windows 1-2-3 for 2ms, wait for vsync (16ms). Every next time, we'll be sure to have enough spare time (14ms) till update of front-buffer, and also properly wait for vsync. Thus, no tearing.


But make 10+ windows, and your app will crawl. I'm kinda in the same boat as you, and temporarily chose to make virtual windowing, with heavy clipping (using early-z)

markr
09-03-2008, 09:58 PM
Swap groups extension will not work: I was told by nVidia that currently only 1 window per a graphic card can be a part of a group, because the main purpose of this extension is to synchronize windows on several graphic cards (possibly on different computers).