Page 1 of 2

Stutter after using Turbo hotkey (OpenGL, Windows 10 v1809)

Posted: Sat Feb 16, 2019 1:15 pm
by franpa
If I'm using OpenGL for the display output, pressing the Turbo button (Tab) and then releasing it to return to normal speed will result in the game (Zelda: A Link to the Past) becoming very choppy. The choppiness stops if I toggle the Menu Bar on and/or off with Escape.

I'd use Direct3D but seemingly that doesn't synch as well with the audio, causing audible audio crackle (maybe it works better in fullscreen exclusive/without DWM influence, haven't tested).

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon Feb 18, 2019 7:53 pm
by BearOso
Probably because of the compositor/DWM. We don’t have an actual fullscreen exclusive mode. Emulate fullscreen only doesn’t change the screen resolution. OpenGL behavior is very driver-specific. The nvidia driver doesn’t detect a screen-covering window and switch to page flipping, while the Intel and AMD drivers do.

I added a hidden option to the Windows Snes9x config file for the next release. Turning that on tells the DWM that it’s going to be receiving regular updates and might fix the race. The audio output will also be changed significantly and hopefully clear any crackling.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Fri Mar 01, 2019 2:31 pm
by franpa
Why is there no support for a Fullscreen Exclusive display mode? It'd be great to completely avoid the DWM in Windows Vista, 7, 8 and 10... can the UI not render in that kind of display mode?

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Fri Mar 01, 2019 5:53 pm
by OV2
D3D switches to fullscreen mode when the emulate fullscreen checkbox is not set. OGL creates a topmost window that spans the whole screen (and changes the display resolution before that) - I don't know of any other way to switch to exclusive fullscreen with opengl.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Fri Mar 01, 2019 8:19 pm
by BearOso
OV2 wrote:D3D switches to fullscreen mode when the emulate fullscreen checkbox is not set. OGL creates a topmost window that spans the whole screen (and changes the display resolution before that) - I don't know of any other way to switch to exclusive fullscreen with opengl.
There isn’t any other way to do it with OpenGL. That’s why, as I mentioned, on my AMD RX 580, the drivers detect the fullscreen OpenGL window and use page-flipping, making it semi-exclusive. With my nvidia cards, the drivers don’t seem to do this.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Sat Mar 02, 2019 5:27 am
by franpa
OV2 wrote:D3D switches to fullscreen mode when the emulate fullscreen checkbox is not set. OGL creates a topmost window that spans the whole screen (and changes the display resolution before that) - I don't know of any other way to switch to exclusive fullscreen with opengl.
Ah okay, thanks both of you for explaining how fullscreen behaves for both API's. In the current release of Snes9x I've found that DirectDraw is the most stable for Windowed mode, it has the best frame pacing and least audio crackle. I look forward to seeing how the next release will behave.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Sat Mar 02, 2019 8:12 pm
by BearOso
If you have the 1.59.2 release, open up your snes9x.conf file and look for a line called “DWMTweaks”. Change this from false to true. This toggles a setting that is supposed to improve frame pacing.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Sun Mar 03, 2019 12:40 pm
by franpa
v159.2, with and without that DWM setting enabled:
Direct Draw: Works perfectly and so does the audio.
Direct 3D: Works perfectly and so does the audio.

This is a big improvement over v1.58 and older.

OpenGL however, remains busted in the Frame Pacing department. The same behaviour of frame pacing issues occurring after Turboing is still present, and if you wait long enough without toggling the Menu Bar visibility it will eventually develop frame pacing issues without touching the Turbo hotkey. Toggling the Menu Bar visibility resets the behaviour, causing good frame pacing for a while before it again starts exhibiting problems.

Here's a video of OpenGL with DWMTweaks set to ENABLED: https://youtu.be/UsJs6_sDvwk (stutter begins at around 40 seconds)

Code: Select all

                DWMTweaks            = TRUE   # true to try and avoid DWM stutter

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon Mar 04, 2019 2:50 am
by BearOso
franpa wrote: Here's a video of OpenGL with DWMTweaks set to ENABLED: https://youtu.be/UsJs6_sDvwk (stutter begins at around 40 seconds)
I think if I add an option to run DWMFlush after every frame it'll decouple the OpenGL vsync from the compositor. I'll work on this and get a test build for you to try.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon Mar 04, 2019 10:11 am
by franpa
BearOso wrote:
franpa wrote: Here's a video of OpenGL with DWMTweaks set to ENABLED: https://youtu.be/UsJs6_sDvwk (stutter begins at around 40 seconds)
I think if I add an option to run DWMFlush after every frame it'll decouple the OpenGL vsync from the compositor. I'll work on this and get a test build for you to try.
That's what Verduga Greeneyes did in a custom build of BSNES for me a couple years ago to resolve anomalous frame pacing issues with the DWM. This is the code example he gave when I questioned how he resolved it (he also gave a longer description but I don't think I need to include it here):

Going from

Code: Select all

{
waitForVBlank();
present();
}
to

Code: Select all

if (DWM.isEnabled()) {
present();
DWM.DwmFlush();
} else {
waitForVBlank();
present();
}

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon Mar 04, 2019 9:16 pm
by BearOso
I've added a hidden DWMSync option in the config file to replace the DWMTweaks option. To enable, set this to TRUE in snes9x.conf like you did DWMTweaks. You can get a build from here:
https://ci.appveyor.com/project/snes9x/ ... /artifacts

This will wait on the DWM compositor to output the current frame. If you leave vsync on and the compositor is controlling the output, you should get a 50% slowdown. On the opposite end, if the compositor isn't responsible for output and vsync is off you'll get tearing. You'll have to try it to see whether the compositor gets control in fullscreen mode.

I'm going to try something else that might work, too.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon Mar 04, 2019 9:58 pm
by BearOso
Ok, I just changed the regular fullscreen mode (Emulate Fullscreen option turned off) to use the flags that should get the nvidia driver to recognize the window and skip the compositor. Try this with the regular vsync option without the DWMSync option. Use this build:
https://ci.appveyor.com/project/snes9x/ ... /artifacts

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Tue Mar 05, 2019 5:58 am
by franpa
Tested using this version: viewtopic.php?p=59140#p59140

OpenGL with DWMSync enabled and Vsync enabled:
Windowed = Good.
Fullscreen = 50% gameplay speed.

OpenGL with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = 100% gameplay speed but the screen tears.

OpenGL with DWMSync disabled and Vsync enabled:
Windowed = Stutters with frame pacing issues.
Fullscreen = Good.

OpenGL with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame pacing issues.
Fullscreen = whole screen exhibits shuddering when in motion.

---------- ---------- ---------- ---------- ---------- ---------- ----------

Direct Draw with DWMSync enabled and Vsync enabled:
Windowed = 50% gameplay speed.
Fullscreen = 50% gameplay speed.

Direct Draw with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = Stutters with frame Pacing issues.

Direct Draw with DWMSync disabled and Vsync enabled:
Windowed = Good.
Fullscreen = Stutters with frame Pacing issues.

Direct Draw with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame Pacing issues.
Fullscreen = Stutters with frame Pacing issues.

---------- ---------- ---------- ---------- ---------- ---------- ----------

Direct3D with DWMSync enabled and Vsync enabled:
Windowed = Good.
Fullscreen = Good.

Direct3D with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = 100% speed but the screen tears.

Direct3D with DWMSync disabled and Vsync enabled:
Windowed = Good.
Fullscreen = Good.

Direct3D with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame Pacing issues.
Fullscreen = Screen exhibits rolling shudder from the top of the screen down to the bottom.

1 problem with Direct3D Fullscreen: Stuff rendered in the black side bars (4:3 aspect) doesn't clear when it should. For example see the green bar in the top right corner? That's the Geforce Experience availability notification after it attempts to disappear https://imgur.com/a/tB4DKhz

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Tue Mar 05, 2019 4:52 pm
by BearOso
It seems like I got the nvidia driver to redirect fullscreen windows. That means if we just have the DWMSync option automatically turn off vsync temporarily and sync to the compositor in window mode while using regular vsync in fullscreen exclusive mode it should be perfect with OpenGL. Looks like D3D works fine with them in conjunction, and DirectDraw I'm not too concerned about.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Tue Mar 05, 2019 6:20 pm
by franpa
Yep, that does seem to be the best implementation for OpenGL.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Tue Mar 05, 2019 8:36 pm
by BearOso
Ok, the DWMSync option will now only operate in windowed and emulated fullscreen modes. It will shut off regular vsync in those cases. In fullscreen exclusive mode it will turn regular vsync on and DWMSync off. This is only for OpenGL.

The build will be here: https://ci.appveyor.com/project/snes9x/ ... /artifacts

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Wed Mar 06, 2019 7:40 am
by franpa
Yep, only thing left to do is default the DWMSync option to True (or add a GUI option for it).
1 problem with Direct3D Fullscreen: Stuff rendered in the black side bars (4:3 aspect) doesn't clear when it should. For example see the green bar in the top right corner? That's the Geforce Experience availability notification after it attempts to disappear https://imgur.com/a/tB4DKhz
is still an issue.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Mon May 27, 2019 8:40 pm
by mopa9000
franpa wrote: Tue Mar 05, 2019 5:58 am Tested using this version: viewtopic.php?p=59140#p59140

OpenGL with DWMSync enabled and Vsync enabled:
Windowed = Good.
Fullscreen = 50% gameplay speed.

OpenGL with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = 100% gameplay speed but the screen tears.

OpenGL with DWMSync disabled and Vsync enabled:
Windowed = Stutters with frame pacing issues.
Fullscreen = Good.

OpenGL with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame pacing issues.
Fullscreen = whole screen exhibits shuddering when in motion.

---------- ---------- ---------- ---------- ---------- ---------- ----------

Direct Draw with DWMSync enabled and Vsync enabled:
Windowed = 50% gameplay speed.
Fullscreen = 50% gameplay speed.

Direct Draw with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = Stutters with frame Pacing issues.

Direct Draw with DWMSync disabled and Vsync enabled:
Windowed = Good.
Fullscreen = Stutters with frame Pacing issues.

Direct Draw with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame Pacing issues.
Fullscreen = Stutters with frame Pacing issues.

---------- ---------- ---------- ---------- ---------- ---------- ----------

Direct3D with DWMSync enabled and Vsync enabled:
Windowed = Good.
Fullscreen = Good.

Direct3D with DWMSync enabled and Vsync disabled:
Windowed = Good.
Fullscreen = 100% speed but the screen tears.

Direct3D with DWMSync disabled and Vsync enabled:
Windowed = Good.
Fullscreen = Good.

Direct3D with DWMSync disabled and Vsync disabled:
Windowed = Stutters with frame Pacing issues.
Fullscreen = Screen exhibits rolling shudder from the top of the screen down to the bottom.

1 problem with Direct3D Fullscreen: Stuff rendered in the black side bars (4:3 aspect) doesn't clear when it should. For example see the green bar in the top right corner? That's the Geforce Experience availability notification after it attempts to disappear https://imgur.com/a/tB4DKhz
If I'm using OpenGL for the display output, pressing the Turbo button (Tab) and then releasing it to return to normal speed will result in the game (Zelda: A Link to the Past) becoming very choppy. The choppiness stops if I toggle the Menu Bar on and/or off with Escape.

I'd use Direct3D but seemingly that doesn't synch as well with the audio, causing audible audio crackle (maybe it works better in fullscreen exclusive/without DWM influence, haven't tested).

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v18

Posted: Thu May 30, 2019 3:01 pm
by franpa
mopa9000 wrote: Mon May 27, 2019 8:40 pmIf I'm using OpenGL for the display output, pressing the Turbo button (Tab) and then releasing it to return to normal speed will result in the game (Zelda: A Link to the Past) becoming very choppy. The choppiness stops if I toggle the Menu Bar on and/or off with Escape.

I'd use Direct3D but seemingly that doesn't synch as well with the audio, causing audible audio crackle (maybe it works better in fullscreen exclusive/without DWM influence, haven't tested).
Go in to the configuration file (snes9x.conf) for Snes9x and look for DWMSync. Set this to True and then test OpenGL and Direct3D.

Re: Stutter after using Turbo hotkey (OpenGL, Windows 10 v1809)

Posted: Sun Jan 10, 2021 8:03 pm
by franpa
I'd just like to re-affirm that DWMSync continues to be a gargantuan help on my system in regards to frame pacing.

Programs + DWM tend to result in terrible frame pacing on my system and since the release of Vista I've yet to figure out "why", I also get the impression no one else has this issue. Software can be updated to work well with the DWM on my system but that requires the developers of the software to make changes to resolve an issue that may not affect many/anyone else (and requires me to convince them to make changes...) and many programs no longer even get updates. As far as I can tell it's either the computer monitor or a software specific issue... because I've literally replaced all storage devices, motherboard, CPU, Soundcard, Video Card and Gamepads since the release of Vista with no discernible improvement to the situation (I now have a Ryzen 3700X CPU and Asus Crosshair Hero VIII [WiFi] motherboard).

It's a little scary at the moment with some game devs starting to shun Fullscreen Exclusive mode, which bypasses the DWM.