PCSX2 / pcsx2

PCSX2 - The Playstation 2 Emulator
https://pcsx2.net
GNU General Public License v3.0
11.42k stars 1.59k forks source link

Stuttering (seems to be due to WS_POPUP removal?) #2307

Closed thatsage closed 2 years ago

thatsage commented 6 years ago

Build 1.5.0-dev-2285-gc23241c (latest as of today)

Settings OpenGL issue doesn't happen in DX11 Safe Preset /w vsync off or on (in pcsx2) Software or Hardware

Issue Games stutters every 15-20 seconds or so, for a few seconds, despite running in 60fps and exhibiting no slowdowns or issues with sound etc.

Fix After looking around I found issue https://github.com/PCSX2/pcsx2/issues/1437 and using the specific GS plugin provided there which from my understanding added a flag called 'WS_POPUP' seems to completely resolve the issue.

PC specifications: WINDOWS 10 64bit build 1709 NVIDIA GTX 970 driver version 390.77 8GB RAM i5-4690k

Note this issue persisted for me across truly many versions of drivers and windows 10 builds, until literally today when I stumbled upon that fix.

mirh commented 6 years ago

Yes.. It must be that commit And we are back to square one...

What renderer did you use? @thatsage said dx was stuttering even on 1.4.0 And turtleli reported tearing not so much ago.

mirh commented 5 years ago

I was told forceware 4xx-something would be super duper gold. Anybody that could test this?

(and I wonder if this isn't the same issue libretro has)

mirh commented 5 years ago

Bump for people that should actually get out testing this Link dump for developers with time to spare https://bitbucket.org/pyglet/pyglet/issues/169/windows-windowflip-too-slow https://stackoverflow.com/questions/45676892/reliable-windowed-vsync-with-opengl-on-windows https://github.com/glfw/glfw/issues/649

OCRBonk commented 5 years ago

FWIW I am able to get basically stutter free video by using RTSS Scanline Sync in Windows 7 with Aero disabled in OGL Hardware.

Vsync and the internal Frame Limiter have to be disabled. Otherwise you cannot get a stable tearline hidden and you will get a rolling tearline instead. Scanline Sync will act as limiter instead. I use CRU to create a custom refresh rate of 59.94, use TestUFO.com and the display overclocking test and the Refresh Rate detector to ensure everything is working correctly.

Scanline Sync is set to the appropriate line. (In my case a 1080p display, line 1124). And Sync Time Out is set to 16.683ms (written as 16683 in the config) 1000/59.94=16.683xxxx Using 1:1 SS seems to even work stable here for 30hz interlaced games like Front Misison 4. No stutter. (Aside from loading here and there)

After quite a bit of trial and error this seems to finally, be pretty much stable. I decided to test this after buying a few games I already own for the PS4 emulated versions on PSN and was highly disappointed at the performance in several games having drops or heavy recurrent stuttering (Star Ocean 3 , Arc the lad for example)

This same set-up is also exactly applicable to PPSSPP using DX9 but i'm sure it works in others too. Why use DX9? So you can force Anti Aliasing from the driver for Nvidia cards No AA https://abload.de/img/ppssppwindows64_2019_p9kd5.png 8xSGSSAA forced using 0x084012C1 in Nvidia Profile Inspector https://abload.de/img/ppssppwindows64_2019_qbjm4.png (Texture aliasing begone!) There are zero visual glitches i've encountered thus far because of this other than having Vertex Cache enabled causes a few polygons to become sporadically invisible in Metal Gear Ac!d. Disabling it fixes the problem with no performance hit.

This gets stutter free 30hz Vsync (except you use 1/2 Scanline Sync.) Unless it's a mixed framerate game that does menus at 60hz, then the 30hz elements aren't quite as stable. But this has been the biggest issue for using PPSSPP for me for years. No exclusive fullscreen, horrible frame pacing. PPSSPP on android runs a lot of games i'd like to play on a Droid 2 turbo at 1440p internal resolution. But even there the frame pacing is bad.

Using the RA PPSSPP core can be hit and miss but you can also get perfect 30hz sync in that as well by using Vsync interval =2, which will give you 1/2 refresh sync. (But not on android)

My hardware for reference. R5 2600x 4.2Ghz RTX 2080 16GB DDR3 W7/10 dualboot Buncha HDDs/NVM/SSDs, PCSX2/PPSSPP running off a mechanical drive though.

mirh commented 5 years ago

So... I don't doubt that the most smooth, performant solution is having your screen refresh match the emulation one and all, see #2059

But as already said 999 times in this thread, and the problem we are trying to address, is that users with damn nvidia cards shouldn't have to do anything at all to have a "decent enough" experience. Instead, we have this special window flag with still no rationale about its reasons to exist.

OCRBonk commented 5 years ago

I only set the refresh rate to that to cover all my bases. Even with the refresh rate set to 60.000 it seems to work pretty much just fine too as long as I disable the framelimiter and let SS limit instead.

For me without a Full Screen Exclusive mode, the only acceptable way to get vsync is to use Aero in W7 and that causes massive input lag and horrible frame pacing. (Where as in emulators with a FSE mode, like the RA core of PPSSPP and the ability to set 1/2 refresh rate Vsync fixes the problem too in that emulator. Just as you have to do in order to get proper 30hz Vsync in any modern PC game on a 60hz display without stutter/frame pacing problems. And that applies to any GPU vendor. )

PPSSPP has the same problem.(No FSE available) Scanline Sync fixes these issues. I'm used to having to tweak a ton of stuff for PC games on Nvidia so it doesn't bother me as much. But in the decade i've been following off and on development of PCSX2 this is the first time i've ever been able to get an ideal Vsync/ Input lag/Frame pacing scenario without huge issues. And that alone makes me pretty happy.

mirh commented 5 years ago

For me without a Full Screen Exclusive mode, the only acceptable way to get vsync is to use Aero in W7 and that causes massive input lag and horrible frame pacing.

And this entire thread is about telling you there must be something really concerning going on with the nvidia driver. Because for as much as "normal 60hz aero" may not be perfect, it's anything but horrible and outrageous on my normal humble amd card. *Even with PAL games*

And I'd like to underline you again that you seem to have missed the fact that FSE can be very easily enabled with EnableVsyncWindowFlag=enabled ini option.

BParks21 commented 5 years ago

Can we get a gui option to enable EnableVsyncWindowFlag=enabled from the settings menu. I just did a clean install of PCSX2 and completely forgot about this setting needing to be set in the .ini file and was going mad trying to remember why my games were stuttering again and what i had to find to fix it.

mirh commented 5 years ago

I'm almost happy nvidia users have to go through the hassle. Perhaps one day it may be enough for somebody to bother so much to help investigating it. After 3 years, it feels like I'm the person having cared more about this.. And I don't even own the affected hardware.

Also, as a fun fact, it seems like there might be another "principle of stuttering" somewhere between W10 or nvidia drivers.

BParks21 commented 5 years ago

FWIW I am able to get basically stutter free video by using RTSS Scanline Sync in Windows 7 with Aero disabled in OGL Hardware.

Vsync and the internal Frame Limiter have to be disabled. Otherwise you cannot get a stable tearline hidden and you will get a rolling tearline instead. Scanline Sync will act as limiter instead. I use CRU to create a custom refresh rate of 59.94, use TestUFO.com and the display overclocking test and the Refresh Rate detector to ensure everything is working correctly.

Scanline Sync is set to the appropriate line. (In my case a 1080p display, line 1124). And Sync Time Out is set to 16.683ms (written as 16683 in the config) 1000/59.94=16.683xxxx Using 1:1 SS seems to even work stable here for 30hz interlaced games like Front Misison 4. No stutter. (Aside from loading here and there)

After quite a bit of trial and error this seems to finally, be pretty much stable. I decided to test this after buying a few games I already own for the PS4 emulated versions on PSN and was highly disappointed at the performance in several games having drops or heavy recurrent stuttering (Star Ocean 3 , Arc the lad for example)

This same set-up is also exactly applicable to PPSSPP using DX9 but i'm sure it works in others too. Why use DX9? So you can force Anti Aliasing from the driver for Nvidia cards No AA https://abload.de/img/ppssppwindows64_2019_p9kd5.png 8xSGSSAA forced using 0x084012C1 in Nvidia Profile Inspector https://abload.de/img/ppssppwindows64_2019_qbjm4.png (Texture aliasing begone!) There are zero visual glitches i've encountered thus far because of this other than having Vertex Cache enabled causes a few polygons to become sporadically invisible in Metal Gear Ac!d. Disabling it fixes the problem with no performance hit.

This gets stutter free 30hz Vsync (except you use 1/2 Scanline Sync.) Unless it's a mixed framerate game that does menus at 60hz, then the 30hz elements aren't quite as stable. But this has been the biggest issue for using PPSSPP for me for years. No exclusive fullscreen, horrible frame pacing. PPSSPP on android runs a lot of games i'd like to play on a Droid 2 turbo at 1440p internal resolution. But even there the frame pacing is bad.

Using the RA PPSSPP core can be hit and miss but you can also get perfect 30hz sync in that as well by using Vsync interval =2, which will give you 1/2 refresh sync. (But not on android)

My hardware for reference. R5 2600x 4.2Ghz RTX 2080 16GB DDR3 W7/10 dualboot Buncha HDDs/NVM/SSDs, PCSX2/PPSSPP running off a mechanical drive though.

I can confirm what OCRBonk has done works. Same for the swap interval in Retroarch.

mirh commented 5 years ago

Is that working any worse or better than EnableVsyncWindowFlag=enabled ?

BParks21 commented 5 years ago

Technically better. RTSS reports are flawless 16.6ms frametime when limiting the framerate to 60fps in combination with the flag option. There is no devation in this frametime accept in screen transitions which is normal. Visually there is no difference in doing this as opposed to using the flag option alone. However without limiting the framerate in combination with the flag option the frametimes are less stable fluctuating between 16.7ms, 17ms and sometimes randomly jumps to the 40's! Strange that when only using the flag option never results in 16.6ms. Here are some screenshots. I had to take them in window mode because i couldn't capture them correctly in fullscreen, but this did not effect frametimes. Screenshot (32) Screenshot (33) Screenshot (36)

mirh commented 5 years ago

... wait a moment Why do you have those black bars on the sides of the window?

MrCK1 commented 5 years ago

He might be using the "Full" BIOS settings instead of 16:9, some games depend on it for aspect ratio

Dreadmoth commented 5 years ago

That's just how a 16:9 output fits between the title bar and taskbar with the PCSX2 window maximised - if it occupied the full width it'd be stretched (or cropped).

vsub commented 5 years ago

Yes,that's how 16:9 look like on 1920:1080 in window mode(not just on pcsx2) In fullscreen those black bars are gone

mirh commented 5 years ago

Uh, crap. Could you try to use fit to screen then instead?

BParks21 commented 5 years ago

Sure, fit to screen window mode fine? I'm unable to properly capture the overlay in fullscreen.

mirh commented 5 years ago

I meant: do you get a smooth image with that and the vsync flag instead (which.. are you putting inside PCSX2_ui btw?)? Because it already happened that destroyed perfection.

BParks21 commented 4 years ago

I'm using the flag option enabled. Now with fit to screen instead. With the flag option enabled there is no stutter in fullscreen or window mode. With flag enabled plus limiting to 60 with riva i get the same visible smoothness but frame times are locked perfectly at 16.6ms. With no flag enabled i get awful stutter in window and fullscreen. With flag disabled and the FPS limited to 60 i get stutter in both window and fullscreen even when the graph shows fairly stable frame times. The first image is just flag enabled. The second is flag enabled plus 60fps limit. the 3rd is no flag and 60 limited. Screenshot (2) Screenshot (3) Screenshot (4)

mirh commented 4 years ago

With the flag option enabled there is no stutter in fullscreen or window mode.

Thanks. god. And I hope you can also confirm that there is no tearing in either dx and opengl renderer, in both windowed and fullscren modes (at least when vsync is set in pcsx2).

So, again.. The only hard blocker to get the flag back, is having popup windows cooperate when exclusive fullscreen triggers. If you could also signal this in the other 999 emulators threads involved...

BParks21 commented 4 years ago

Yes with the flag option enabled there is no tearing or stutters both in DX and opengl windowed or fullscreen. I did notice DX has even better frame times in the graph than opengl though. A perfectly flat line with 16.7ms frametimes. Yes i will.

Margen67 commented 4 years ago

Windows 8.1+ have forced triple buffering/compositing with non-exclusive fullscreen so this would be nice to have.

Nicholas-Steel commented 4 years ago

I was getting periodic long bursts of Frame Doubling with my Nvidia Geforce 1070Ti and OpenGL, I'll give this EnableVsyncWindowFlag a shot to see if it improves the situation.

Nicholas-Steel commented 4 years ago

Nah it didn't resolve it. I'm not entirely sure what is going on but the emulator works fine and then something, unsure what, causes it to fall in to a bad mode where frame duplication frequently happens. The only way to stop it occurring, at least temporarily, is to do something that makes the screen flicker like opening and closing the graphics plug-in UI.

Unsure if I should make a new report to discuss this or discuss it on the forum.

ichee commented 4 years ago

Setting display refresh rate to 59.94hz seems to resolve stuttering. For displays that can only do 60hz at the nearest, setting emulation speed to 100.1% should fix the problem, though currently emulation speed can’t be set to a float value. Should be able to verify by temporarily setting the frame limit to 60 in the pcsx2_vm.ini.

Otherwise, some form of resampling would be needed.

Just so you should know, some native PC games behave similarly with nvidia cards with regard to occasional stuttering, primarily the console ports.

Windows 10 Intel 9820x Nvidia gtx 1080ti

Nicholas-Steel commented 3 years ago

I made a report that explains the issue, and includes a video recording ichee: https://github.com/PCSX2/pcsx2/issues/3571

clang88 commented 3 years ago

I can confirm the stuttering issue on both PCSX v1.6 and the latest pcsx2-v1.7.0-dev-944-g7c072094a-windows-x86.

I can however not confirm that the issue is only visible with OpenGL. While different, I am observing some stutter with the D3D Renderer aswell. This also exhibits in somewhat erratic jumps of reported FPS/Game Speed in the PCSX Window (Game Speed jumps between 99% and 101% while FPS varies from 59.9x to 60.7x. The issue is actually also present when using the Software Renderer on either of the APIs.

I can confirm that the solution @ichee suggested removes stutter completely: Changing FramerateNTSC to 60.00 in PCSX2_vm.ini completely eliminates stuttering. With this change, the reported FPS and Gamespeed are stuck to 100%/60 fps (well 59.9x to 60.0x) respectively. However, I have not tested this long enough to see if it results in some timing or other emulation issues (the game is, after all, running slightly faster).

I tested all this with Silent Hill 2 (which, I believe, runs at 30fps on original hardware), while keeping VSYNC off and Aspect Ratio to Standard in the PCSX GS Window settings.

My System: Ryzen 3900X Nvidia RTX 2060 (Driver 461.40) Windows 10 Pro

MrCK1 commented 3 years ago

I can confirm the stuttering issue on both PCSX v1.6 and the latest pcsx2-v1.7.0-dev-944-g7c072094a-windows-x86.

I can however not confirm that the issue is only visible with OpenGL. While different, I am observing some stutter with the D3D Renderer aswell. This also exhibits in somewhat erratic jumps of reported FPS/Game Speed in the PCSX Window (Game Speed jumps between 99% and 101% while FPS varies from 59.9x to 60.7x. The issue is actually also present when using the Software Renderer on either of the APIs.

I can confirm that the solution @ichee suggested removes stutter completely: Changing FramerateNTSC to 60.00 in PCSX2_vm.ini completely eliminates stuttering. With this change, the reported FPS and Gamespeed are stuck to 100%/60 fps (well 59.9x to 60.0x) respectively. However, I have not tested this long enough to see if it results in some timing or other emulation issues (the game is, after all, running slightly faster).

I tested all this with Silent Hill 2 (which, I believe, runs at 30fps on original hardware), while keeping VSYNC off and Aspect Ratio to Standard in the PCSX GS Window settings.

My System: Ryzen 3900X Nvidia RTX 2060 (Driver 461.40) Windows 10 Pro

Did you try a 1.7 build without the framerate limiter modifcation?

We had several users with prior input lag issues reporting no problems on 1.7 builds without other modifcations needed. There were several changes done to the framelimiter code that should elimintate those small spikes over 59.94.

clang88 commented 3 years ago

Did you try a 1.7 build without the framerate limiter modifcation?

We had several users with prior input lag issues reporting no problems on 1.7 builds without other modifcations needed. There were several changes done to the framelimiter code that should elimintate those small spikes over 59.94.

I tried the 1.7 build I mentioned (pcsx2-v1.7.0-dev-944-g7c072094a-windows-x86) first without any modifications and had stutter and jumping frametimes. Do earlier 1.7 builds behave differently? Would you mind pointing me to a build that should behave correctly?

refractionpcsx2 commented 3 years ago

Did you try a 1.7 build without the framerate limiter modifcation? We had several users with prior input lag issues reporting no problems on 1.7 builds without other modifcations needed. There were several changes done to the framelimiter code that should elimintate those small spikes over 59.94.

I tried the 1.7 build I mentioned (pcsx2-v1.7.0-dev-944-g7c072094a-windows-x86) first without any modifications and had stutter and jumping frametimes. Do earlier 1.7 builds behave differently? Would you mind pointing me to a build that should behave correctly?

are you using VSync in PCSX2 or forcing VSync in your GPU driver by chance? because that could cause microstutters

clang88 commented 3 years ago

I was doing neither, although I am using windows 10 which, I think, forces triple buffered VSync on everything but exclusive Fullscreen

refractionpcsx2 commented 3 years ago

Triple VSync? Do you mean Triple Buffering? You can turn that off in your GPU driver (at least with Nvidia), however PCSX2's frame limiter shouldn't exceed the time per frame to let you queue up frames like that.

Also I'm using Windows 10 and it doesn't force VSync on for me, that's done at GPU driver level.

Nicholas-Steel commented 3 years ago

The Triple Buffering option within the Nvidia Control Panel only affects OpenGL, it does not affect DirectX.

clang88 commented 3 years ago

I just retested it all. Running up and down in the beginning of silent hill 2. Vsync is set to application controlled in nvidia control panel (in fact, it is all default there); Vsync is disabled in PCSX 2. I'm using the "Safest" Preset with only the Multi-Core hack enabled (although I have observed the same issue with it disabled). For GS emulation I use the software renderer with 4 threads and everything enabled. pcsx2-v1.7.0-dev-944-g7c072094a-windows-x86

I also disabled any kind of overlay (steam, rivatuner) to be sure, that there is no interference.

Running at the default 59.94 Framelimit the game would periodically start stuttering, kind of like it needs to smooth out the accumulated missing frames. At 60.00 nothing, it runs smooth the whole time, never once stuttering.

@Nicholas-Steel has made a perfect video demonstrating the issue. I'm not sure it is the same issue as for me, because as I said, setting Framerate to 60.00 pretty much solves the stuttering issue in my case. If needed, I can make a video of my tests as well, or try some other things. Just let me know. Nicholas-Steel's post: #issuecomment-678797517

refractionpcsx2 commented 3 years ago

It's unlikely we're going to bring WS_POPUP back, but there is a PR #3549 which changes DX to the flip model which is likely similar to what WS_POPUP was using, so you will be able to use that. Of course you will likely get tearing but you can't have a nice smooth picture that's synced with your display and have it run at the correct framerate, that's two completely incompatible things.

With the PR mentioned above it supports technologies such as Freesync or Gsync, and from my testing that seems to remove any stuttering/tearing I experience without the tech.

A Good way to test for stuttering/tearing is to use Pillgen which I have attached here, you can watch the white box along the top

pillgen-60fps-ntsc.zip

jeremybris commented 2 years ago

Stuttering has been mitigated by the Vulkan Render, for me. (My vm.ini, NTSC refresh rate is changed to 60 fps.) Anyone else?

refractionpcsx2 commented 2 years ago

Should be fine in other renderers too since the GS window has been replaced with the host interface, so I don't believe it's using WX anymore (which was a problem)

F0bes commented 2 years ago

Closing for the reason stated in the above comment.