Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Is there any way to get around V-sync?  (Read 4923 times)

0 Members and 1 Guest are viewing this topic.

Jack Burton

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1384
  • Last login:April 07, 2025, 02:12:05 pm
  • .
Is there any way to get around V-sync?
« on: May 21, 2009, 12:53:59 am »
Topic.

I've been using emulators for a decade or so now, and from way back the one thing that has bothered me more than anything else is screen tearing while I am playing a game on an emulator. 

Most emulators have options to help alleviate this issue.  They are usually known as "V-sync", "wait for V-blank", and "triple buffering".  Other emulators have "match game refresh", and "force monitor refresh" options to also aid in this issue and also make the game run at the correct speed.

Mostly the reason that emulators need to do this is because when they run in full screen they are running at resolutions and refresh rates that are different from the original game.  This causes the display of the game to run at a speed different from that of the monitor.

What vexes me now though is that I possess monitors and equipment that will allow me play games- both arcade and console- in their original native resolutions and refresh rates.  I know that the obstacle to overcome is merely software now, as I have hardware that is capable of displaying a signal from both my computer and the original hardware. 

For example:  I can run Ghosts n' Goblins on my emulation setup at 256x240, at 60hz (60.11 to be exact).  This will eliminate almost all the screen tearing, but just a little bit will be there.  If I enable v-sync this will solve this issue, but it will then add just a little bit of jerkiness to the scrolling of the screen that I find unacceptable.  This issue repeats itself across many titles and emulators for me.

I have done some research on the subject, and from what I can tell there is no emulator out there that is exactly equivalent in speed to original hardware.  As long as there is an operating system in the background there will always be little distractions that will prevent exact timing for an emulator. 

What can I do to get around this?  How can I minimize my operating system's impact on my emulator?  I have talked to some of my friends who are familiar with linux and they say that it is completely possible to build Linux so that the bare minimum processes are running that are necessary for the emulator to run.  Would this be beneficial to my purpose?

This seems to be the last hurdle for me when I think of MAME vs a PCB.  I can always tell something is an emulator because of that little bit of jerkiness in gameplay.  There's nothing that gets that pure smooth scrolling that a real PCB, NES, or SNES had. 

A side note for discussion as well:  I've heard conflicting things about whether or not v-sync and triple buffering add input lag.  Does anybody have have good evidence to one side or the other? 
« Last Edit: May 21, 2009, 12:57:49 am by Jack Burton »

Ummon

  • Trade Count: (+13)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5244
  • Last login:June 09, 2010, 06:37:18 pm
Re: Is there any way to get around V-sync?
« Reply #1 on: May 21, 2009, 01:18:41 am »
Um, okay. I think it depends on what build you're using and what mame version. Indeed, more and more, mame since the re-write seems unintended for native display and only for some obscure reason retains directdraw features (on which of course native resolutions depend). Apparently SailorSat's build gets around this some. I haven't really been keeping up to know it's current success. I use Advancemame, but of course that means I'm restricted to version .106 (I use .104). BUT, it's flawless where at times mame is not. The only time I get a slight of tearing or something is when I'm running too much stuff - cos I usually have AOL and Explorer going. Regardless, it's the smoothest in my experience, and the color palette is a little different.
Yo. Chocolate.


"Theoretical physics has been the most successful and cost-effective in all of science."

Stephen Hawking


People often confuse expressed observations with complaint, ridicule, or - even worse - self-pity.

Minwah

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7662
  • Last login:January 18, 2019, 05:03:20 am
    • MAMEWAH
Re: Is there any way to get around V-sync?
« Reply #2 on: May 21, 2009, 07:50:01 am »
I agree this is a big problem. Especially in recent Mame versions as Ummon was saying.

I believe the problem is only noticable when the refresh rate of your screen mode is less than that of the game. In other words as long as you use a refresh rate higher than the game then it is OK (no frames are skipped). I think if you could use 61Hz for all 60.xxHz games (instead of the more common ~60Hz) then most problems would disappear...just a shame the ArcadeVGA modes are 60Hz exactly (give or take a bit on the first AVGA cards).

My solution (which is far from ideal) is to use an older Mame version for most games, and a custom build for driving games (there are some good updates in recent Mame's). In my custom build I adjusted all the refresh rates to be 59.85Hz or less. The downsides are that this alters the game speed marginally, and I would not fancy doing this for *all* games in Mame!!

SailorSat

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1238
  • Last login:Today at 08:57:27 am
    • For Amusement Only e.V.
Re: Is there any way to get around V-sync?
« Reply #3 on: May 21, 2009, 09:19:37 am »
The timing question is a good one.
Actually there are two things to note.

1. Speed
Actually most Emulators COULD run at (nearly) exact speeds.
The Problem most likely that most speeds are "guessed".
As for MAME... Actually pretty much no arcade hardware runs at exactly 60Hz (though MAME may say so). Most speeds are "guessed".
So most emulators will limit their speed to some factor, for example the Vertical Refresh.

In theorie you should avoid tearing by using triplebuffer but NOT vsync.
But... practically every emulator nowadays automatically will enable vsync if you enable triple buffing so thats now gets us to the second thing...



2. The VSync Problem.
So... If you enable VSync on a 60Hz Screen, and your game would run at 61Hz (just as example). You actually slow things down. Now MOST emulators will try to match that slowdown by skiping frames every now and then. THATS where you get stuttering in the video.

That can be solved (MAME wise) if you disable autoframeskip, throttle, AND set frameskip to 0.

With BASE MAME you'll get sound stuttering now, as the emulated sound chip doesn't provide enough data for the soundcard. There are some builds (MAMEUIFX, CabMAME etc.) that feature my "soundsync" that will get rid of that problem, though it slightly changes the pitch/speed of the sound. In pretty much every case you won't notice that. (Exception would be R-Type run at 53Hz Mortal Kombat resolution instead of its original 55Hz).

Some may try out cabmame (in a fresh directory) WITHOUT "tweaking" the INI files. (Most ppl tend to make things worse when they try to make it better).


As for other systems...
Well I'm using a "hacked" Version of ZSNES for my SNES emulation and I never noticed "stuttering". The "hack" actually forces pixel perfect output (I run it in 512x240, instead of the SNESs "native" 512x224). That works pretty good. Just take care you use a NTSC (meaning Japanese or US) version of the game.

Give it a try @ http://files.arianchen.de/zsnesw.zip


Bottomline...
If you want "smooth" gameplay....

1. ENABLE Tripplebuffer/VSync.
2. DISABLE any frameskipping.
3. Match the resolution as close as possible to the one we need.

ArcadeVGA and Soft15kHz both will provide NTSC compatible timings (240/480 lines) and PAL compatible timings (288/600 lines).


P.S. you can't match the perfect speed as there is no operation system that allows direct control of the graphics card... No not even Linux.
I do all that stuff even without a Joystick ;)
Soft-15kHz, cabMAME, For Amusement Only e.V.


Jack Burton

  • Trade Count: (+3)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1384
  • Last login:April 07, 2025, 02:12:05 pm
  • .
Re: Is there any way to get around V-sync?
« Reply #4 on: May 28, 2009, 01:35:10 am »
Thank you for you input SailorSat.  I've tried out your advice on a variety of emulators now and have the best results I've seen.  It's smooth enough that I no longer notice during gameplay. 

I wonder about emulators for consoles, do those allow direct access to a graphics card?  I have played It might be NES on a PSX and it seemed to have perfect smooth scrolling.  I would be very interested if it was possible to get correct timing in an emulator running on a gamecube.

SailorSat

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1238
  • Last login:Today at 08:57:27 am
    • For Amusement Only e.V.
Re: Is there any way to get around V-sync?
« Reply #5 on: May 28, 2009, 08:54:56 am »
I guess most emulators on consoles don't throttle at all, they just would sync to the vsync as pretty much all console should run at either 50Hz (PAL) or 60Hz (NTSC / HD).
At long as the emulation keeps 100% (or faster) that should work out fine.
If the console is to slow for 100% emulation speed, it doesn't matter anyway.
I do all that stuff even without a Joystick ;)
Soft-15kHz, cabMAME, For Amusement Only e.V.


Ummon

  • Trade Count: (+13)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5244
  • Last login:June 09, 2010, 06:37:18 pm
Re: Is there any way to get around V-sync?
« Reply #6 on: May 29, 2009, 05:14:44 pm »
P.S. you can't match the perfect speed as there is no operation system that allows direct control of the graphics card... No not even Linux.


I thought Advancemame did, especially in Linux.
Yo. Chocolate.


"Theoretical physics has been the most successful and cost-effective in all of science."

Stephen Hawking


People often confuse expressed observations with complaint, ridicule, or - even worse - self-pity.

SailorSat

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1238
  • Last login:Today at 08:57:27 am
    • For Amusement Only e.V.
Re: Is there any way to get around V-sync?
« Reply #7 on: May 29, 2009, 06:58:19 pm »
P.S. you can't match the perfect speed as there is no operation system that allows direct control of the graphics card... No not even Linux.


I thought Advancemame did, especially in Linux.

The problem most likely is that the card itself "interpretes" the timings that the system requests. Say I wan't exactly 1360x768 pixels with exactly 60Hz, which would be somewhere around exactly 85MHz Pixelclock...
Basically ALL cards are "bound" to some technical restrictions, as the "pixelclock" being limited to (just a random guess) 27kHz steps.
Well on some cards you'll get 85,025 MHz, on some others you will get 84,973 etc.

Also. AdvanceMAME suffers from a simple fact. MAME only supplies the Pixel Resolution and the vertical Refresh (i.e. 320x224 @ 60Hz). But that does NOT describe all other timings, like how "long" the sync pulse should be. So those are "guessed" using a generic formula.

That comes close, but most likely will never match the "real" thing.
Pretty much the same as trying to get the "real" NeoGeo modeline, which actually is described in detail in the MAME source.

Hope I didn't confuse anyone ;)
I do all that stuff even without a Joystick ;)
Soft-15kHz, cabMAME, For Amusement Only e.V.


Ummon

  • Trade Count: (+13)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5244
  • Last login:June 09, 2010, 06:37:18 pm
Re: Is there any way to get around V-sync?
« Reply #8 on: May 31, 2009, 02:06:53 pm »
Hmm. I remember reading that Advancemame uses some kind of special algorithm to figure timings or something.
Yo. Chocolate.


"Theoretical physics has been the most successful and cost-effective in all of science."

Stephen Hawking


People often confuse expressed observations with complaint, ridicule, or - even worse - self-pity.

Ummon

  • Trade Count: (+13)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5244
  • Last login:June 09, 2010, 06:37:18 pm
Re: Is there any way to get around V-sync?
« Reply #9 on: June 21, 2009, 05:18:40 am »
Here's some things I found by, omigosh, reading the MameUI and Mame32 help files:

MameUI:

Advanced Tab : This tab allows the setting of additional numerous video options.

Triple buffering : This option controls how MameUI draws to the screen, if toggled on, it will draw to three buffers and cycle between them.  This setting when toggled on can also help alleviate tearing that sometimes occurs in some scrolling games.

Sync to monitor refresh : This option tells MameUI to ignore the original game’s refresh rate and sync it to the output monitor’s current rate.  This can cause the game to run too fast if the output monitor is using 85Hz for example.  This option is preferable if MameUI is used with authentic arcade monitor hardware and video card modes that are tweaked appropriately.

(I haven't tried this out at all.)



Mame32:

Match game refresh rate : This option tells Mame32 to attempt to force the output monitor to match the refresh rate of the selected game’s original video hardware.  The majority of games in Mame32 are 60Hz, using this option and triple buffering will produce smooth scrolling in those games.

(Though I haven't used these at native resolutions, at higher res and with hardware stretch enabled I have noticed a difference in smoothness and overall graphics rendering that is pleasing.)


Something else of note for Mame32:

D3D Tab : This tab allows the setting of Direct3D hardware supported video options.

Use Direct3D : This option controls whether or not Mame32 utilizes the Direct3D functions of DirectX.  It will override the DirectDraw setting on the Advanced tab, and assumes the use of hardware stretch.  Results will vary on individual hardware configurations, but the D3D effects may be faster than their DirectDraw counterparts on modern video cards.


For those running PC monitors at higher resolutions, but using lower-end PCs, you may get better performance using this - but pay attention to this:

Note that some of these effects will do integer stretches on the aspect ratio corrected image as far as possible for the set resolution, this means effects like 'auto', 'aperture grille', 'scan lines' will not stretch to the entire screen.  The various RGB/Dot/Mask/None effects will however stretch to the full screen.
« Last Edit: June 22, 2009, 05:24:28 pm by Ummon »
Yo. Chocolate.


"Theoretical physics has been the most successful and cost-effective in all of science."

Stephen Hawking


People often confuse expressed observations with complaint, ridicule, or - even worse - self-pity.

Popcorrin

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 858
  • Last login:March 06, 2022, 11:11:43 am
Re: Is there any way to get around V-sync?
« Reply #10 on: June 22, 2009, 12:59:15 am »

2. The VSync Problem.
So... If you enable VSync on a 60Hz Screen, and your game would run at 61Hz (just as example). You actually slow things down. Now MOST emulators will try to match that slowdown by skiping frames every now and then. THATS where you get stuttering in the video.

That can be solved (MAME wise) if you disable autoframeskip, throttle, AND set frameskip to 0.

I think there needs to be some clarification.  When you enable vsync in mame the game still runs at the correct speed, but it might skip a frame or show a frame twice to avoid tearing.  How often it needs to do this depends on the frame rate of the game as compared to the refresh rate your monitor is running at.

This can not be solved in mame by disabling autoframeskip, throttle, and setting frameskip to 0.  Disabling throttle will just cause the game to run as fast as your computer will run it.


Quote
Bottomline...
If you want "smooth" gameplay....

1. ENABLE Tripplebuffer/VSync.
2. DISABLE any frameskipping.
3. Match the resolution as close as possible to the one we need.

If you want smooth gameplay, the only way is to match the monitor refresh rate to the frame rate of the game or a multiple of the frame rate of the game.  For instance, you could match a game that ran at 53Hz by setting your monitor refresh rate to 53Hz or 106Hz.   In order to do this you need a multisync monitor that can run at various speeds and a system that can do the same. 
The other option for smooth gameplay is by speeding up or slowing down the game to match the monitor's refresh rate.  Not authentic, but works.




Quote
P.S. you can't match the perfect speed as there is no operation system that allows direct control of the graphics card... No not even Linux.

  You can match the perfect speed by utilizing advancemame under linux or dos(advancemame is pretty flaky under windows), since advancemame is capable of taking direct control of the graphic cards under those operating systems.  It's pretty amazing to see once you have it set up but it is a chore getting everything tweaked how you want it.

Ummon

  • Trade Count: (+13)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5244
  • Last login:June 09, 2010, 06:37:18 pm
Re: Is there any way to get around V-sync?
« Reply #11 on: June 22, 2009, 05:26:13 pm »

  You can match the perfect speed by utilizing advancemame under linux or dos(advancemame is pretty flaky under windows), since advancemame is capable of taking direct control of the graphic cards under those operating systems.  It's pretty amazing to see once you have it set up but it is a chore getting everything tweaked how you want it.

Um, I think she and I covered that some.
Yo. Chocolate.


"Theoretical physics has been the most successful and cost-effective in all of science."

Stephen Hawking


People often confuse expressed observations with complaint, ridicule, or - even worse - self-pity.

Popcorrin

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 858
  • Last login:March 06, 2022, 11:11:43 am
Re: Is there any way to get around V-sync?
« Reply #12 on: June 22, 2009, 11:48:15 pm »

  You can match the perfect speed by utilizing advancemame under linux or dos(advancemame is pretty flaky under windows), since advancemame is capable of taking direct control of the graphic cards under those operating systems.  It's pretty amazing to see once you have it set up but it is a chore getting everything tweaked how you want it.

Um, I think she and I covered that some.

I read the thread, but there wasn't a definitive correct answer regarding the capabilities of advance mame when it comes to matching the refresh rate to the frame rate of the original games.