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

If you're having problems with Snes9x, or think you've found a bug, this is the place to be.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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).
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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?
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
OV2
Official Win32 Porter/Dev
Posts: 679
Joined: Thu Aug 30, 2007 10:15 pm

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

Post 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.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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.
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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();
}
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post by franpa »

Yep, that does seem to be the best implementation for OpenGL.
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

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

Post 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
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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.
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
mopa9000
Snes9x White Belt
Posts: 2
Joined: Mon May 27, 2019 8:34 pm

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

Post 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).
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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.
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
franpa
Snes9x Yellow Belt
Posts: 150
Joined: Mon Apr 30, 2007 10:18 am

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

Post 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.
Windows 10 x64, Ryzen 3700X, ASUS Crosshair Hero VIII WiFi Motherboard, 16GB 3600MHz RAM, MSI Gamer 1070Ti, Integrated Audio, Corsair AX760 power supply.
Post Reply