c - WinAPI - Synchronizing SwapBuffers -


is possible synchronize swapbuffers in many threads? when try turn on vertical synchronization (wglswapintervalext), stops threads, until doesn't tick (ex. when open 3 windows, every window has approximately 20 frames [60/3] ) every window has separate thread, , of course every thread has own swapbuffer function.

swap control per-window in wgl (when set it, applied window current render context tied to). association between render context , window tied device context (see wglmakecurrent (...)). need vsync 1 of 3 windows if reliably hitting < ~5.6 ms frame time in each.

what should consider here having 1 of contexts set swap interval 1 , remaining 2 use 0. context syncrhonized vblank (swap interval = 1) lead other 2 threads. say, have other 2 threads call glflush (...) , busy wait until first thread stops blocking vsync before calling swapbuffers (...). reason glflush (...) other 2 threads accomplish useful rendering tasks while wait first (synchronized) swap finish.

it sounds funny - recipe tearing - given nature of windows vista/7/8's compositing window manager, vsync not prevent tearing anymore. window manager compositing asynchronously, performs triple buffering. vsync will, however, allow (when done correctly) have 3 of windows update contents each refresh (avoid late frames).

if did not bother starting series of buffer swaps @ beginning of vblank, run situation compositing window manager displays old frame 2 frames because swapping buffers in middle of vblank. granted, can still run situation if draw excessively long frame, solves case short frame unfortunately swapped close vertical retrace deadline finish in time.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -