When playing games such as The Witcher and Mirror's Edge under wine, forcing VSync in the control panel does not work. The issue occurs with wine-1.3.15 and later, but the wine developers claim it is not a regression. Using the Nouveau driver with GLXVblank=1 results in VSync working within these games. I am using a GTX275 and have tested with these nvidia-driver versions:

BTW I tried with TripleBuffer and/or Page Flipping both on and off, and it made no difference. Neither did forcing the vsync settings with __GL_SYNC_TO_VBLANK=1

EDIT: Also, VSync does work if it's selected in game (e.g with Mirror's Edge) but not when forced by the driver. Driver forcing vsync is required for The Witcher, as it does not have an ingame vsync option.

I've had some mixed results with OpenGL vsync in Wine. Some games seem to respond to the nvidia-settings and environment variable setting, while some graphics demos actually require the opposite settings in order to sync (I have to set vsync to 0 to get vsync!)

Quote:

Also, VSync does work if it's selected in game (e.g with Mirror's Edge) but not when forced by the driver.

That's basically the issue with the graphics demos, they usually have a check box for vsync, so I check the box in the demo and set the nvidia driver to not vsync.

That's basically the issue with the graphics demos, they usually have a check box for vsync, so I check the box in the demo and set the nvidia driver to not vsync.

Yeah, it's weird. The older versions of wine do work with vsync forced, but those versions won't let you force it in game (most of the time). Some games don't have an inbuilt vsync option, though, so it's not a universal solution.

In addition, I've been having tearing issues with Adobe Flash 10/11 but I don't know if they were always there and I just didn't notice it before.

In more recent Wine versions, we use some more modern GLX calls to handle vsync. The override in nvidia-settings doesn't override those calls (glXSwapIntervalEXT / glXSwapIntervalSGI). (This assumes no composition manager is running else nvidia-settings may not do anything)

I just tried with the sims 3 and and wine 1.3.27; vsync option is just ignored with no composite extension loaded and with just a blank x screen with xterm.
with wine 1.11.x it worked fine; can't say if it is an nvidia issue; but it just doesn't work anymore.

If you can't replicate the issue,
* just download and unpack this little d3d demo: http://dl.dropbox.com/u/5116567/rthdribl_1_2.zip
* Force vsync in nvidia-settings
* disable compositing
* run it with wine (tested under 1.3.30 + nvidia drivers 285.05.09)

Observe that:
* fps are not multiple of the current refresh rate (but this can be caused by wrong calculations)
* occasional tearing appears (use the mouse to drag the image and pan faster to make it more evident)

Setting *_one or *_default lead to the rendering synced to the display resolution, but choosing d3d_PresentInterval_immediate lead to display being unsynced, and there is nothing which can be done; nvidia-settings is unable to force vsync in that case.
Using an older wine version (i used 1.1.44) works (nvidia-settings is able to force vsync in all of the three cases),
This is exactly the issue we're discussing.

(PS: as expected, thesims3, which won't let you configure any vsync and leave it off, still tears with latest wine, while is ok with olders).

I can confirm that for this demo there's no offect in ticking "Sync to VBlank" checkbox in nVIDIA X Server settings in case the demo runs in windowed mode. You can control VSync behavior through app configuration menu (accessed using F2 key) by changing D3D presentation interval setting. Switching app into using fullscreen mode makes vsync behave as expected (i.e. there's no tearing and FPS almost matched screen refresh rate).

The code is pretty simple. It is clear that Wine's d3d9 implementation defines it's own "default swap interval" to be D3DPRESENT_INTERVAL_ONE in case app specify is as D3DPRESENT_INTERVAL_DEFAULT. The default value for swap_interval when using wine OpenGL is assumed to be 1 as this is what GLX_SGI_swap_control specs explicitly define.

Now, back to the problem with controling vsync using nVIDIA driver CP. "Sync to VBlank" setting at "OpenGL Settings" page doesn't explicitly mention that it would force vsync to be always on. I suspect that the only real effect it has it setting the default internal value the driver uses as swap_interval. As a result we get that Wine app that uses d3d to do rendering would always set swap_interval value basing on the app supplied D3DPRESENT_INTERVAL and/or on built-in wined3d defaults.

What should be done here by nVIDIA devteam:

a) nVIDIA should document if setting "SyncToVBlank" nvcontrol attribute to be 1 really forces swap_interval to be at least 1.

b) nVIDIA should fix __GL_SYNC_TO_VBLANK so it sets default OpenGL swap_interval to be 1 and any attempts to reset it back to 0 using GLX_EXT_swap_control extension should fail with an error (or maybe should be silently ignored). GLX_SGI_swap_control should be OK in its current form as the specs state that it is impossible to disable vsync once it had been enabled usign this extension (glXSwapIntervalSGI should do nothing and fail with an error if receives 0 as input). This behavior should be consistent no matter is the target drawable attached to the fullscreen X11 window or to an ordinary X11 window.

As a side note, Wine should be extended to use GLX_EXT_swap_control if it's available instead of much older and less capable GLX_SGI_swap_control extension. I would implement a patch and send it to Wine devteam as soon as would have a spare time for it.Upd. Actually Wine currently relies on an assumption that calls to glXSwapIntervalSGI() are mapped to the glXSwapIntervalEXT() internally in the driver if latter advertises support for "GLX_EXT_swap_control". Thus there's no urgent need in patching Wine to directly use GLX_EXT_swap_control - it would be of a much benefit.