View Full Version : SwapBuffers on XP vs Vista/Win 7
05-31-2009, 01:44 AM
For synchronizing certain things in my application I moved Swapbuffers that refreshes my windows from the thread that handles opengl to another thread.
On XP, it works perfectly, however, on Vista/win 7, it slows the whole application down horribly.
Is there any reason for that?
05-31-2009, 03:18 PM
It is impossible to tell without more information. Please provide your measured frame time on each OS, whether you are using windowed or fullscreen modes, whether Aero is enabled and, most importantly, whether vsync mode is enabled/disabled on each case.
My guess is that vsync is enabled on Vista and disabled on XP, hence the discrepancy.
05-31-2009, 11:43 PM
Thanks for the answer. I am using windowed mode, no Aero. Vsync - I think - should be on, because I do not do anything with it. I don't think there is any point in measuring the frame times, the difference is so huge. In XP, playback of the scene is smooth, so FPS is at least 30, in the newer OSs it is not more than 2-3 FPS, CPU load is off the scale in task manager.
It really looks like that for some reason unknown to me, Swapbuffers cannot be used in threads other than the opengl calling thread. At least in Vista and Win 7.
06-01-2009, 06:32 AM
I admit that it never crossed my mind that you could issue SwapBuffers from a different thread.
Msdn reads (http://msdn.microsoft.com/en-us/library/dd369060(VS.85).aspx): "With multithread applications, flush the drawing commands in any other threads drawing to the same window before calling SwapBuffers."
Other than that, I cannot help you, sorry. Maybe someone from the resident OpenGL gurus has some idea?
06-02-2009, 05:12 AM
Never crossed my mind either. Why would you want to do such a thing? *strokes beard in reflection*
06-02-2009, 12:09 PM
OK, I will try to make a long story short. The whole application is based on broadcast video output (I support various cards). To output to these cards, I have to use a separate thread (let's call it video thread), and all other stuff is synced to this thread (even the one with the opengl render), ie. it signals to the others to do their jobs.
I have a preview window on the VGA monitor that is refreshed with Swapbuffer, but since PAL video is 50Hz and VGA is anything but, playback on this preview output is understandably not smooth.
If there is not broadcast video card in the system, the VGA preview is the only output, but unless I rewrite all of my threads just for the VGA-only setup, there is still a video thread calling all others. But this video thread has no idea about Vsync, it can signal the opengl thread to render the next frame, but playback will not be smooth.
At least it wasn't until I tried to put the Swapbuffers call to the video thread. Now I get smooth playback on the preview window, but only in XP. The newer OSs do not tolerate this at all. If you think that it is not even expected to work in any other thread but the opengl rendering one, and I am only lucky with XP, then I will drop the idea altogether.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.