schellingb / dosbox-pure

DOSBox Pure is a new fork of DOSBox built for RetroArch/Libretro aiming for simplicity and ease of use.
GNU General Public License v2.0
778 stars 65 forks source link

Vsync support? #26

Closed Tasosgemah closed 2 years ago

Tasosgemah commented 3 years ago

I noticed a lot of games have screen tearing. I'm aware this is a DOS thing but IIRC there were some DosBox versions that did eliminate this issue. Could something similar be implemented in Pure?

mrmatteastwood commented 3 years ago

Any games in particular? I haven't encountered any screen tearing myself. On Windows, I have vsync enabled in RetroArch's video settings, and on Linux, I am using the "Force Composition Pipeline" feature of the Nvidia driver to eliminate screen tearing across the whole desktop, which also works in RA.

baltimoresports commented 3 years ago

Outside DBP, I find the best setting for RetroArch is to disable V-Sync in the app, but enable it in the (NVidia) Driver Settings.

Tasosgemah commented 3 years ago

Any games in particular? I haven't encountered any screen tearing myself. On Windows, I have vsync enabled in RetroArch's video settings, and on Linux, I am using the "Force Composition Pipeline" feature of the Nvidia driver to eliminate screen tearing across the whole desktop, which also works in RA.

DOOM, Duke 3D and Quake all suffer from screen tearing. I also enable VSYNC through drivers but no matter what setting you change in RetroArch, i'm still getting screen tearing in those games.

Tasosgemah commented 3 years ago

I found another game that suffers from very severe screen Tearing:

Mortal Kombat Trilogy

I tried MK2 and that was clean but Trilogy is so bad, it tears the screen in 2 places non stop.

mrmatteastwood commented 3 years ago

Hmm, I haven't tried any of these games under DOSBox, I'm afraid, so I can't comment on them specifically. I do play DOOM, but I'm using the GZDoom source port.

I'm wondering whether the following might help though, provided you're on Linux:

  1. Open NVIDIA X Server Settings
  2. Pick "X Server Display Configuration"
  3. Click "Advanced..." button
  4. Enable "Force Composition Pipeline" and "Force Full Composition Pipeline"

Now, run the affected games in RA again, see if screen tearing is gone.

If that is indeed the solution, you'll need a way to make the "Force Composition Pipeline" options persistent across reboots. Here's my own script, which I run for my 3 screens on every system startup. It also sets the GPU PowerMizer mode to "prefer performance" on every boot. You could try adapting this script for your needs, save as a .sh file, make it executable and set it to run on system startup with a few seconds delay:

#!/bin/sh
nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +2560+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On, AllowGSYNC=Off}, nvidia-auto-select +3840+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On, AllowGSYNC=Off}, nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On, AllowGSYNC=Off}"
nvidia-settings --load-config-only
nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1"
Tasosgemah commented 3 years ago

Appreciate the help but I'm on Windows.

I hope vsync can be added in the core itself so it can be consistent across all systems.

mrmatteastwood commented 3 years ago

Ahhh, yeah I see. Perhaps, until (that is, if) this option comes to DOSBox Pure, have you tried injecting driver-side vsync through the NVIDIA Control panel in Windows?

https://www.youtube.com/watch?v=IjPVlVhlsOQ

Start the video at 0:45 to see how to do this for only one program (in our case, RetroArch).

Tasosgemah commented 3 years ago

Yes, i always have Vsync enabled in Nvidia drivers anyway because i can't stand screen tearing.

I also have Vsync enabled in RA's main options as well.

This Vsync issue was something i was trying to fix when i made my first DosBox setup a few years ago.

From what i can understand, DOS games don't support hardware vsync natively (or so i heard). So when you emulate a game that doesn't have it's own, software vsync or something, you will get screen tearing no matter what because the screen tearing is part of the emulation. I could be wrong but that's how i understand it.

Supposedly, there are DosBox builds that add vsync to those games somehow. But i never tested them personally because by the time i heard of them i was doing other projects. But now with this core, i decided to make a new couch setup and i'm re-living the same thing with vsync issues. So i'm asking if whatever the other DosBox builds do to fix this can be done in this core as well.

schellingb commented 3 years ago

In the latest release I tweaked a bit how the frame refresh is submitted to RetroArch. If someone could try it out and report if things feel better, worse, or about the same I'd be grateful. Thanks.

Tasosgemah commented 3 years ago

Tested on Duke Nukem 3D and MK Trilogy.

Didn't notice any difference. I'm still getting the same amount of screen tearing as before. I can reduce it in MK if i select Pentium 100mhz (instead of auto) but it's still there (and i feel the game is a bit slower).

I think screen tearing gets reduced if the emulated CPU isn't much faster than what the game needs. But in every case, there is no Vsync, just less or more screen tearing. Duke Nukem has less.

Tasosgemah commented 3 years ago

I also can't reduce the screen tearing in 7th guest, which is extreme. It tears the screen in 2 places and it almost never stops when something is moving. I looked up a video on Youtube and it's definitely not as bad normally.

Need to search a bit on how to reduce it. But i remember having similar issues years ago and didn't find anything. Heard there was a DosBox build that has vsync but i never tested it.

schellingb commented 3 years ago

Sorry that this didn't do much. If you have some more time, could you enable the RetroArch option Settings -> On-Screen Display -> On-Screen Notifications -> Notification Visibility -> Display Statistics and post a screenshot of what it displays during either of these games?

Next, I assume you are on Windows 64-bit, can you try with the special build below? It uses more buffers so it should have no way of tearing (unless the game is really bad and tears on a CRT I think) and if it does, I'm not sure it can be the core's fault. But either way we should know more. dosbox_pure_libretro-win64-0.7-8bufs.zip

Tasosgemah commented 3 years ago

Thanks for trying to fix this. Unfortunately, this special build doesn't change the behavior. Yes, i'm using Windows 64 bit.

I manage to capture how the screen tearing looks in 7th guest when the camera turns, which is the most severe case:

7th Guest, The (1993)-210106-212812

Tasosgemah commented 3 years ago

I'm not sure if this game has tearing issues on a real machine/CRT. But i saw some youtube videos and it doesn't look as bad so i assume it can be improved?

schellingb commented 3 years ago

It must be some weird combination of display, gpu driver, RetroArch and this core's behavior but I have no idea what could cause it to be this distorted.

Have you tried to set the RetroArch option Settings -> On-Screen Display -> On-Screen Notifications -> Notification Visibility -> Display Statistics? There's a bunch of numbers I'm curious about.

Tasosgemah commented 3 years ago

Statistics on my 240hz monitor:

7th Guest, The (1993)-210106-214723

Edit: It cuts the screen when i save a screen :(

Anyway, i'm getting the save screen tearing on my 60hz TV so i assume there is no difference.

boomercore commented 3 years ago

Vsync/VRR works fine in OpenGL/Vulkan but there is tearing in D3D11/12. Troublesome as save states work in those APIs, but they're broken in GL/Vulkan.

javis commented 3 years ago

I'm also experiencing tearing on MKTril, it is really bad.

I'm using RetroArch on Emuelec

schellingb commented 3 years ago

@javis Have you had a chance to try the new timing mode that was added a few days ago? I'm curious if it improves things for you. You can find some details how to use it in this issue comment

javis commented 3 years ago

@schellingb It seems the version in Emuelec is not up to date yet, I will wait for them to update the core version to try again, thanks

schellingb commented 2 years ago

Version 0.21 released 6 months ago hopefully improved vsync and timing issues with its improvements and the optional "Force 60 FPS" mode. If there are still vsync or tearing issues, I'd appreciate if the comments were collected in #184 as that's where all the discussion about timing related enhancements takes place. Thanks! Closing this one now.

javis commented 2 years ago

Hi!

I've been able to try MK Trilogy with "Force 60 FPS" option enabled and it did not fix the tearing issue, moreover, it increased the speed of the game to an abnormal level and made it unplayable.