flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.49k stars 174 forks source link

[Request]Support for smooth Vsync on 120hz refresh rate #293

Closed Immersion95 closed 2 years ago

Immersion95 commented 3 years ago

I moved on from 60hz to 120hz screen and I have a problems with juddering.

Retroarch fixes this by allowing to change the Vsync swap interval to 2 but I can't find any solution for standalone.

Thanks !

flyinghead commented 3 years ago

Why would a 120 Hz refresh rate cause any issue? Vsync will wait until the next screen refresh to display the current frame. This wait time will be lower than with a 60 Hz refresh rate.

Can you post a video of the issue?

Immersion95 commented 3 years ago

Here is a video and the log.

flycast.log Video here

Enabling or disabling Vsync doesn't change anything, I'm using Vulkan.

Immersion95 commented 3 years ago

Is there anything else I can help with ?

flyinghead commented 3 years ago

Thanks for the video. I think I know what the problem could be but I don't have a 120 Hz display to test with.

I'll have a look at retroarch's code to see if I can implement something similar in standalone.

Immersion95 commented 3 years ago

Hi,

There are 2 ways that RA is handling it :

-Vsync swap interval to 2 or -Sync to exact content framerate --->Best solution as it run the original framerate inside the 120hz (can also trigger VRR if supported).

Immersion95 commented 3 years ago

Question which has nothing to do with this issue : I saw a libretro branch which is built in your bot but with an .exe instead of .dll. Is it a libretro rebase ? How can I use it ?

flyinghead commented 3 years ago

You can grab the flycast core dll here: https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml

Get the flycast-libretro-x86_64-w64-mingw32 artifact from the latest run on the libretro branch.

Immersion95 commented 3 years ago

You can grab the flycast core dll here: https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml

Get the flycast-libretro-x86_64-w64-mingw32 artifact from the latest run on the libretro branch.

Thx a lot !

Unfortunately your build also crashes like the official core on my AMD 6800 card. Standalone works great though.

flyinghead commented 3 years ago

The last build on the libretro branch has a tentative fix for 120 Hz displays. Can you give it a try?

It should detect that your display is refreshing at 120 Hz and set a swap interval of 2.

Immersion95 commented 3 years ago

Tried the libretro .exe build from the buildbot but it doesn't work. There is no option to activate it.

flyinghead commented 3 years ago

There's no visible option: If VSync is enabled and the monitor refresh rate is 120 Hz, it should use a swap interval of 2 instead of 1.

Immersion95 commented 3 years ago

I'm sorry but it doesn't work

flyinghead commented 3 years ago

I just realized you're using Vulkan and this change won't work with it. Can you try Open GL instead?

Immersion95 commented 3 years ago

Yes it does work ! What about Vulkan then ?

Immersion95 commented 3 years ago

Is it 60 fps with Vswap 2 or 59.94 with Vswap 2 ?

flyinghead commented 3 years ago

One step at a time. At least we know it works for Open GL, then I can figure out a similar solution for Vulkan.

It's only using a swap interval of 2 so the actual frame rate should be half of your monitor refresh rate.

Immersion95 commented 3 years ago

Thx a lot ! I kid you not, Ikaruga isn't running fullspeed at 4k with the 6800 and OpenGL (shitty Windows drivers).

Immersion95 commented 3 years ago

Hi, sorry to bother you again :p. Can this be implemented in Vulkan ? Playing in 120hz is impossible now.

flyinghead commented 3 years ago

So far the only solution I have for Vulkan relies on an extension (VK_GOOGLE_display_timing) that's not widely supported except on mobile.

Immersion95 commented 3 years ago

It works great !

Only problem : Fast forward crashes frequently

flyinghead commented 3 years ago

Thanks for testing and reporting.

In case of crash, a .dmp file should be generated in your temp directory (%USERPROFILE%\AppData\Local\Temp by default on Windows.) Can you attach the most recent one to this issue?

Does the crash happen when switching to fast forward, when switching back to normal, or during fast forward? Are you using single-threaded mode or multi-threaded?

Immersion95 commented 3 years ago

flycast.zip Here are the requested dmp files. It crashes when activating fast forward and I'm on multi-threaded. I also attached the config file.

flyinghead commented 3 years ago

Good idea to also include your config file. Unfortunately I looked at all the crashes and they all happen at the same location, deep inside the AMD vulkan driver, so it doesn't help much.

When fast forward is enabled, the swap chain is recreated, the swap interval is reduced to 1 (the normal value) and vsync is disabled. I don't know why duplicating frames prior to that would make the driver crash but I'll keep looking.

LetramChi commented 3 years ago

I have a laptop with a 240hz monitor and an external 165hz monitor

When streaming and activating the OBS on the monitor and playing on the external display, it doesn't look smooth.

I imagine that with the work they are doing, the problem could be solved.

I will be attentive to the progress and if I can help you in something, let me know.

flyinghead commented 3 years ago

Dreamcast and Naomi output video at 60 Hz. So it won't be smooth on a 165 Hz monitor (165 isn't a multiple of 60). Set your external monitor to 120 Hz or 60 Hz if possible.

LetramChi commented 3 years ago

When playing everything well, the problem is when I want to capture or stream, it is there when the flycast screen is not fluid/smooth.

For now, deactivate VSync and it's better

Immersion95 commented 2 years ago

Should I close this issue ? It's fixed for me.