hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.22k stars 2.17k forks source link

Vsync is messed up when using shaders #4440

Closed xZabuzax closed 10 years ago

xZabuzax commented 10 years ago

Vsync is not working properly in the latest revisions when you use a shader, if Vsync and any shader are enabled Vsync won't work unless the emu is in windowed mode first and then you alt+enter to go to fullscreen.

To reproduce the issue:

Vsync and a shader is enabled and the emu is in fullscreen, when you play a game you will have screen tearing so to fix it you need to alt+enter to go to windowed mode and alt+enter again to go to fullscreen.

Another way to fix it is starting the game with no shaders and after the game is loaded you can enable the shader and you won't have screen tearing.

thedax commented 10 years ago

I can't reproduce this on my NVidia card on Windows with driver 334.67. Is this still happening?

xZabuzax commented 10 years ago

Just tried it in the latest version "v0.9.6-691-g4f2f8f0" and is still happening, the screen tearing happens every 5 seconds so is easy to miss.

Try this, in "MegaMan - Powered Up" just try running left and right, you will see that every 5 seconds there's a slight tearing in the way he moves, again, this only happens when you start a game with shaders and Vsync turned on.

I haven't updated my graphic card in years btw, my NVidia driver's is 260.99.

unknownbrackets commented 10 years ago

Well, old drivers may have bugs...

-[Unknown]

thedax commented 10 years ago

Try this, in "MegaMan - Powered Up" just try running left and right, you will see that every 5 seconds there's a slight tearing in the way he moves, again, this only happens when you start a game with shaders and Vsync turned on.

I don't have that game, so I wouldn't be able to test it. I tested in the Monster Hunter games; you can spin the camera in 360 degrees freely, and it'd be really obvious to me if my vsync wasn't working (I have an old IPS display which has a terrible response time, so with vsync off, tearing is incredibly obvious). Also, I did start it with shaders and vsync on, still no tearing.

Can you see if it's a driver bug?

xZabuzax commented 10 years ago

My internet is pretty crappy at the moment so downloading the driver will take a while, i will try to update the drivers tomorrow and see whats up.

xZabuzax commented 10 years ago

OK, so i updated my graphic card drivers to 332.21 (this is the latest stable release) and i still have the same problem, only difference is that "MegaMan - Powered Up" have a strange issue now. The opening video sometimes doens't work and the emu skip the video and go directly to the title screen.

Oh well, i still needed to update the drivers anyways.

xZabuzax commented 10 years ago

^ I'm finally home again and i did some testing with the new drivers, i still have the same screen tearing problem with vsync and shaders turned on (in any revision, old or new...) but the issue with "MegaMan - Powered Up" is fixed in newer revisions, i was using an older revision "v0.9.6-13-g33771d3" which didn't have the problem with the emu skipping the video with my old driver, but with the new driver this game was sometimes skipping the video but it is fixed in newer revision.

I spotted a minor bug tho while testing "MegaMan - Powered Up".

https://github.com/hrydgard/ppsspp/issues/5295

Keep up the amazing work dudes.

unknownbrackets commented 10 years ago

Hmm, does that mean this bug is fixed? Should we close it?

-[Unknown]

thedax commented 10 years ago

Yeah, his reply is a bit confusing..he's saying the tearing is fixed with this game, but he still has it in others, I guess? Could you clarify for us?

xZabuzax commented 10 years ago

English is not my main language so i probably needed to use more fancy words i guess =p

Vsync is still not working if i start any game with a shader turned on, i was having this issue with the old graphic driver and sadly updating the driver didn't fixed the issue.

But another issue popped up, "MegaMan - Powered Up" was working fine with my old driver and with an older PPSSPP revision i had in my pc which was "v0.9.6-13-g33771d3" but with the updated drivers "MegaMan - Powered Up" was having issues with "v0.9.6-13-g33771d3". (The emu was skipping the intro movie).

The latest PPSSPP revision fixed the intro movie in "MegaMan - Powered Up" but i still have the above issue, Vsync is still not working if i start a game with a shader turned on.

I hope i was clear enough this time, keep up the awesome work dudes.

thedax commented 10 years ago

Well, the other issue can be discussed in the new one you made. As for VSync, that's really weird. Can you upload the contents of your ppsspp.ini to https://gist.github.com/ and share it with us? Maybe a combination of certain settings is causing it. I'm using all default settings except for vsync on and postprocessing shader set to natural colours when testing this issue. Do you have any other games it happens on? Maybe we have a game in common that I could test.

xZabuzax commented 10 years ago

Sorry for the late reply, was helping my aunt with something.

Here's the ppsspp.ini https://gist.github.com/xZabuzax/8749010 but remember dude, the issue still happens with a clean install of PPSSPP so i don't know if posting my .ini will be of any help. Also remember that this issue happens if you start the emu in fullscreen.

As for VSync + Shader issue, i tested it with 3 more games: "Wipeout Pure", "Ultimate Ghosts'n Goblins" and "Patapon 1".

*Wipeout Pure: Since theres a lot going on in the screen, all the explosions and the fast pace and all, it's gonna be a bit hard to notice the screen tearing but i did noticed it.

*Ultimate Ghosts'n Goblins: Same as "Wipeout Pure", there's just too much going on in the screen that you will probably have a hard time spotting the tearing, and yep, i did have a hard time spotting it. It was harder to spot than "Wipeout Pure".

*Patapon 1: Since you need to keep track in the rythm it's pretty challenging to spot the tearing at the same time too (i suck at multitasking...), the best way to spot it is finishing the first stage and then they will start walking and the background with the white trees will start rolling. This is the best way to spot the tearing and yep, it was pretty obvious this time, the screen was tearing every 5 seconds.

And like always, thanks for all the hard work in this awesome emu and keep rocking dudes.

thedax commented 10 years ago

I was able to reproduce it in Monster Hunter by switching to the Windows Classic theme on Windows 7 (with Aero Glass on, it's not reproducible). Now we're getting somewhere. It seems as if the shader has nothing to do with it; if you start the emulator in fullscreen with vsync enabled, then whatever game you load will have screen tearing until you go back to windowed mode and then re-enter fullscreen, so there's definitely a bug here.

I guess the Windows code is somehow not respecting vsync when it starts up in fullscreen?

Edit: It seems to happen in windowed mode too. It's totally broken/tearing until going fullscreen or returning to windowed mode. What's going on here?

xZabuzax commented 10 years ago

Hmmm, i see you found another way to reproduce it but this is weird because i have Windows 7 Ultimate (32-bit) but the issue is happening with "Aero Glass" turned on, in fact, it was turned on all along, and this issue only happens when starting a game with any shader turned on (if it's turned off it doesn't happen), but you managed to reproduce the issue in an opposite way as mine.

Another thing i might add, by now you're aware that i'm the type of dude that hardly updates the pc software, which means, i haven't even updated Windows 7 in years too... you think that would be the cause of the problem?

thedax commented 10 years ago

What's interesting is even if I force VSync via the NVidia GPU control panel, it'll still tear until fullscreen is exited and re-entered.

Out of curiosity.. @solarmystic: are you able to reproduce this at all? Might give some interesting insight if it can be reproduced on ATI too.

xZabuzax commented 10 years ago

I tried to do this issue the way you reproduced it but i can't reproduce it like that, i mean, switching to the Windows Classic theme is not giving me the screen tearing, i only get the screen tearing when starting a game in fullscreen with Vsync + Shader turned on.

Switching between Windows Classic theme or Aero Glass have the same effect here, so i guess we both are experiencing different issues perhaps?

Edit:

Also i was wrong about 1 thing, i said the issue i'm having only happens in fullscreen, well, turns out i also have screen tearing if i start in windowed mode too (with Vsync + Shader turned on before a game of course).

solarmystic commented 10 years ago

@thedax Unfortunately, I can't reproduce the issue on my ATI card mate, sorry. I tried it both ways (starting in full screen mode + Vsync, and windowed mode +Vsync), and there's no tearing whatsoever. I used Monster Hunter Freedom Unite for the test. As you already know, I use the Windows Classic theme with DWM manually disabled.

@xZabuzax Same goes for your method as well, I'm beginning to think this is a Nvidia only issue.

thedax commented 10 years ago

@hrydgard / @unknownbrackets: Can either of you guys reproduce this?

unknownbrackets commented 10 years ago

I've never really been able to reproduce any vsync issues... I think the checkbox changes nothing for me.

-[Unknown]

thedax commented 10 years ago

Do you use Aero Glass? That might explain it.

hrydgard commented 10 years ago

I don't see how shaders enabled can possibly affect vsync, unless you're for some reason getting adaptive sync (setinterval(-1)) and it slows it down just enough to miss a frame.

Is your tear line most often near the top of the screen or all over the place?

thedax commented 10 years ago

I actually meant more if you guys get tearing at all when vsync is on and starting the emulator in fullscreen. The shaders thing is a red herring, I think. Or at least, it has no bearing on when I test it.

xZabuzax commented 10 years ago

@hrydgard I'm getting fullspeed all the time so i don't think the emu is missing a frame, i stated above that if i start a game with no shaders and then i enable the shader (while the game is running) the tearing doesn't happen, it only happens when starting the game with a shader turned on, it is weird... seems like i'm the only one having this issue.

About the tearing, it's basically the same as starting a game with VSync turned off, the game have a slight tearing after a while, example, the movement of MegaMan in "MegaMan - Powered Up" is kinda choppy every 5 seconds but then it's back to normal, after 5 seconds it gets choppy again. (I'm getting fullspeed all the time so is not a fps issue).

@thedax We probably have different issues dude because i can't reproduce the issue you're having with "Windows Classic theme" but it seems our issues might be Nvidia related, also i get the issue when starting a game in fullscreen or windowed mode, i was wrong in saying i only get the issue in fullscreen.

And like always, keep up the amazing work in this awesome emu dudes.

thedax commented 10 years ago

@xZabuzax: Can you test this test build for me and see if it still tears? I think I found what the cause of this problem is. After I made one simple change, it no longer tears for me with the method I can reproduce it with..

Removed, code was merged into master

Before the GPL stuff comes in: all I did was move

        if (g_Config.bFullScreen)
            _ViewFullScreen(hwndMain);

In WndMainWindow.cpp::Show down to after SetFocus(hwndMain). It seems as if waiting until the window being shown is the "solution".

solarmystic commented 10 years ago

@thedax Vsync is still good on my ATI card using your test build, so it'd be an acceptable change if it works for @xZabuzax.

xZabuzax commented 10 years ago

@thedax

Glad to know that you found a fix for your issue.

Unfortunately i still get the tearing with "v0.9.8-131-g98b6f0d" but i really don't mind about that little issue, it's not affecting me at all.

Since i'm probably the only one having this issue (AFAIK) i think this thread can be closed, if more people do notice the issue then this thread can be opened again.

Keep up the awesome work dudes.

thedax commented 10 years ago

I'm not really sure what else to try currently, then..I'm sorry that we couldn't figure it out.

unknownbrackets commented 10 years ago

Does this still happen?

-[Unknown]

shinra358 commented 10 years ago

No. Ya fixed it.

unknownbrackets commented 10 years ago

Blind fix for the win. Yay.

-[Unknown]