Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vsync functionality doesn't work in Aero Basic
#1
I'd like to thank whoever it was that implemented the Vsync code for PCSX2 as it is the only program that I know of that Vsyncs well with Aero enabled under Windows 7. Unfortunately the Vsync implementation seems to not work when using Aero Basic (tons of screen tearing).

I have enabled the Vsync setting for the emulator (Wait for vsync on Refresh), and am using the DirectX 11 version of GSDx.

Code:
Vsync functionality and most software (My computer):

Windows XP
Works Fine - Windowed
Works Fine - Non-Exclusive Fullscreen
Works Fine - Exclusive Fullscreen

Windows 7                - Aero Basic
Does not function at all - Windowed
Does not function at all - Non-Exclusive Fullscreen
Works fine               - Exclusive Fullscreen

Windows 7           - Aero
frequently stutters - Windowed
Frequently stutters - Non-Exclusive Fullscreen
Works Fine          - Exclusive Fullscreen

Code:
Vsync functionality and some software:

Windows XP
Works Fine - Windowed
Works Fine - Non-Exclusive Fullscreen
Works Fine - Exclusive Fullscreen

Windows 7  - Aero Basic
Works fine - Windowed
Works fine - Non-Exclusive Fullscreen
Works fine - Exclusive Fullscreen

Windows 7           - Aero
frequently stutters - Windowed
Frequently stutters - Non-Exclusive Fullscreen
Works Fine          - Exclusive Fullscreen

Code:
Vsync functionality and PCSX2 (Does this even have a exclusive fullscreen display mode?)

Windows XP
Works Fine - Windowed
Works Fine - Non-Exclusive Fullscreen
Works Fine - Exclusive Fullscreen

Windows 7                - Aero Basic
Does not function at all - Windowed
Does not function at all - Non-Exclusive Fullscreen
Works fine               - Exclusive Fullscreen

Windows 7  - Aero
Works fine - Windowed
Works Fine - Non-Exclusive Fullscreen
Works Fine - Exclusive Fullscreen

Before you ask, yes Vsync is forcefully enabled in the display drivers and I regularly update them from Nvidia's website.
Computer specifications:
Windows 10 x64 | Intel Core i7 @ 2.66GHZ | ASUS P6T | Gigabyte Windforce x3 Geforce  760 4GB | 8GB DDR3 1600MHZ RAM | Integrated Audio
Reply

Sponsored links

#2
Thank you for making it's own thread.

Interesting, I don't really know what to make of this though.
[Image: vwah44]
Gaming: Intel i7 3770k @ 4.2Ghz | R9 290 | 16GB RAM | 480GB(240GB+240GB RAID0) SSD | 3 TB HDD | 1 TB HDD | 500GB HDD
Server: AMD FX 6300 @ 4.4Ghz | GTX 670 | 16GB RAM | 240GB SSD | 320GB HDD
PCSX2 General Troubleshooting FAQ
Reply
#3
Forcing Vsync via NVCP does not work for any game using Windows/Windowed (fullscreen) which is what GDSX uses. not in VISTA and up OS anyway might worked in XP but i have not had xp in such long time i dont remeber

There is no Aero Basic there is Basic theme and High contrast themes. Which disabled Aero which disabled Desktop composition which disabled the Vsync. for ALL windowed windowed(fullscreen) games.

There for there is no Vsync enabled in PCSX2 you want Vsync you need to.

A. Put Aero theme back on and dont disable Desktop composition in properties of the shortcut/exe file.
B. Enabled Vsync within PCSX2 options

Honestly thought not using Aero theme which disabled vsync for windowed and windowed (fullscreen) tends to break Vsync even when your force it via the game that useing Windowed/windowed (fullscreen)
You will get FPS cap at your refresh rate but you will still get tearing. I not sure why it does it I not sure if Nvidia broke something or if it always was like this and Disabling Aero which disables vsync is forceable disabling vsync purposely.

I noticed this 6+ drivers revision back when I disabled Aero/ desktop composition in window7 for ALL windowed/windowed (fullscreen)games but never really cared as I only use Aero and i wont disable vsync either. when i was testing Swtor i windowed(fullscren) with Disabled desktop composition to see it it ran better forcing Vsync via the game resulted in refresh rate cap for fps with screen tearing. I then tested this with Skyrim and few other games including pcsx2 same thing refresh rate fps cap and screen tear. but seeing as i never tested any this before this i cant confirm or deny it it NVidia that broke something.

So basicly Just use Aero and there wont be tearing. (Basic and high contrast theme have no Aero) and disabling desktop compistion inthe shortcuts/exe properties>compatibility tab will have same effect.
Reply
#4
You've pretty much summarized what I've already said, in a much longer, lengthier and wordier post. I didn't explicitly state it but I did come to the assumption that Aero basic breaks vsync in most software. My use of the term Aero Basic likely stems from the various reviews of the operating system (Or vista) from several years ago, I think they used the term when referring to Windows Vista Home Basic which had Aero disabled or whatever.

The term has stuck with me, I know it is just a Basic desktop theme and is not related to Aero at all.

Some software works fine with a Basic desktop theme under Vista and newer operating systems but most won't. I wouldn't mind Aero if it didn't exhibit periodic, frequently occurring stutter. Someone explained to me that my system is hitting a race condition with the DWM, here's a quote of their lengthy explanation:

Ver Greeneyes Wrote:Okay, well what happens is actually pretty simple, but I'll give it some context.

During each screen refresh (VDraw), a monitor draws the data that's stored in a buffer. If this buffer is updated mid-VDraw, you can get tearing if the new data is significantly different because a part of the screen was refreshed using the old data and another part gets the new data. To avoid this, the buffer should only be updated when the monitor isn't drawing, i.e. in VBlank (during this time, old CRT monitors were moving the electron gun back up to the top, but LCDs maintain the same behavior).

But how do you detect a VBlank? Well, monitors send a VBlank interrupt when they stop drawing, but unfortunately no operating system I know of allows this to trickle down to user mode (where programs run) code - so instead of having it trigger your presenting code at precisely the right time, you have to poll for it. You can either do this in a tight loop, which the OS won't like because it has other stuff to do, or poll it every millisecond or so and hope for the best (VBlank only lasts 0.5ms) - or come up with some elaborate hybrid. Even Direct3D, as far as I know, internally does the latter, and that can make it miss VBlanks and Present slightly late. Maybe OpenGl, being tied into your display driver, can actually do a better job and use the interrupt instead (at least internally). But this has lead to a situation where many people don't trust Direct3D to catch VBlanks for them, and use an elaborate polling system instead.

Enter the compositor. The compositor sits on top of all these interfaces, has access to the VBlank interrupts and so can take all the Present requests of the various programs running on the system and send them at that right time, that is, during VBlank - and thus avoid the tearing. This works great, but it doesn't play too well with code that tries to detect VBlank on its own, for one simple reason: by the time this code detects a VBlank has started, the compositor may have already rounded up all the Present requests and done its thing because it has access to the interrupt.

And this is where the stuttering happens: the program tries to display a frame roughly every VBlank, and without a compositor this works fine. Maybe it skips a frame every now and then, or maybe it drops one, but this will happen infrequently if the frame rate is close to the refresh rate. But now you've got the compositor taking care of VSync, and every now and then you detect the VBlank too late (even with your tight polling, if the OS interrupts your thread) and you miss the composition event, so the screen doesn't get updated. Then the next frame, you already have a frame queued up for presenting and you add another one, so that the previous frame gets skipped altogether. Now instead of presenting a single frame 99% of the time, maybe you only present a frame 67% of the time, based on how well your polling does (the more inconsistent your polling, the more likely you are to miss composition - in the worst case, you'll only present half your frames!).

This is the stutter you see, because the difference between 60fps and 30fps is pretty obvious when they randomly alternate. The solution is to let the compositor handle presenting, and wait for it to return - in the case of Windows' DWM, this means calling FlushDWM() which blocks until composition has happened. The difference in your code is actually pretty small: instead of polling for VBlank and presenting when it happens, you Present right away and then call FlushDWM(), letting the compositor take care of it. Note that Direct3D may be internally tied into the compositor in Windows and can probably do a better job when the compositor is enabled than when it isn't - but the aforementioned solution works just as well.

TL;DR: there's a race condition between the polling code and composition, so some frames end up missing the composition band wagon and getting skipped, causing other frames to be displayed for twice as long.

Anyway, I hope that helped you to understand the problem Smile

Your software must be doing that "present immediately, then call FlushDWM()" thing as it works great with Aero on my system and is the only non-exclusive fullscreen program to do so that I know of. Programs which utilize a exclusive fullscreen display mode avoid the DWM entirely (I think the DWM turns off when such a program is in focus?) and typically depend entirely on their own vsync code, hence why they seem to work fine on my system.

Firefox may have started doing it too, but I'm not sure about it. I do know in the last year or so the stutter when scrolling webpages has been drastically reduced, Flash software like Youtube videos however are just as bad as they've always been under Windows 7 on my system.

Edit: I forgot about this until just now, the author of Gambatte (Extremely accurate Gameboy Colour emulator) implemented Verduga Greeneyes suggestion shortly after he explained how to get Vsync working well with the DWM! So there's 2 programs that work well on my PC in windowed mode while Aero is active.
Computer specifications:
Windows 10 x64 | Intel Core i7 @ 2.66GHZ | ASUS P6T | Gigabyte Windforce x3 Geforce  760 4GB | 8GB DDR3 1600MHZ RAM | Integrated Audio
Reply




Users browsing this thread: 1 Guest(s)