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: How to get MAME to run smoothly? (ie no tearing/jerkiness when scrolling)  (Read 22349 times)

0 Members and 1 Guest are viewing this topic.

u_rebelscum

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 3633
  • Last login:April 21, 2010, 03:06:26 pm
  • You rebel scum
    • Mame:Analog+
For a pretty good article, try anandtech's "Triple Buffering: Why We Love It".  The article goes into unbuffered, double buffered, double buffered with vsync, true triple buffering, and (in the update part) reader ahead.


I'm not sure, and have been trying to figure it out before saying anything, and haven't figured it out yet, but...

It seems to me like Mame is not using true triple buffering (at least with the default d3d), but "render ahead" with two back buffers + front buffer (which add up to 3, which leads to the common mistake calling it triple buffering.  I can't tell about when mame uses ddraw.  If mame is using render ahead instead of true triple buffering, this might be the reason you're topping out at ~110%.  I think it might be a fairly easy fix to get the unthrottle speeds back up near other setting's speeds, but I haven't gotten into that yet.  Implementing true triple buffering, OTOH, would be much bigger step, as DirectX does support it (render ahead is supported).

Please mind, this is my current guess.   I am not that experienced with coding for video, and haven't studied mame's code completely.  So I could be wrong.
Robin
Knowledge is Power

GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
I'm a graphics weeny for a living, and I'm pretty convinced that Mame isn't doing actual triple buffer, or at the very least they are doing it properly but still timing something based on vsync.  If Pacman runs perfectly fine for me with no triple buffer and/or vsync, it shouldn't cause sound timing problems to turn triple buffering on.  I'll have a look and see if I can fix it.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
Woo hoo!!  I have a fix that makes triple buffering not have audio sync problems (and will likely fast forward properly) for the d3d path.  There is probably a similar fix for ddraw.  Getting the 133u1 source now so that I can see if this is fixed already there.  If not, I'll have to figure out how to submit changes to Mame.

:)
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
Looks like it is a real fix that isn't in 133u1 yet!  I just submitted it.  Now the only thing that I need to do is to fix the D3D path so that everything is exactly aligned on pixel centers so that it is pixel accurate. :)

I'm not really sure how to make ddraw do triple buffering properly, but I'll look into it.  If the pixel center problem is fixed in D3D, I don't think that there is any reason to use ddraw anymore.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
OK, isn't a 100% fix.  Here's the thread with diffs, etc:

http://forum.arcadecontrols.com/index.php?topic=95005.0

My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


zmartin34

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 120
  • Last login:December 26, 2011, 09:22:42 pm
Thanks for the work!! So, would you suggest that I continue with cabmame or will this fix rectify those issues without the sound tweak?

Also, I am running ddraw with ArcadeVGA. But you said there may be no need for DDraw anymore? Can you elaborate on this please?

GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
Thanks for the work!! So, would you suggest that I continue with cabmame or will this fix rectify those issues without the sound tweak?

Also, I am running ddraw with ArcadeVGA. But you said there may be no need for DDraw anymore? Can you elaborate on this please?

I use all of cabmame minus the sound tweak.  It didn't work well for me.  If you are okay with an occasional tear so that sound is pretty much perfect (as it is without vsync), then I'd use my patch.  If you'd prefer inaccurate sound with a completely solid image, I'd use cabmame.

The main reason for using DDraw over D3D is the fact that ddraw has the game pixels lined up properly with the pixels on your screen.  D3D doesn't, so you get areas of the screen where you get a blend of two neighboring pixels instead of just one.  I know how to fix this problem in D3D (I've done similar things at work), but I'm not really sure how to get ddraw to triple-buffer properly without waiting for vsync all the time, which causes the sound problems.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


zmartin34

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 120
  • Last login:December 26, 2011, 09:22:42 pm
Thanks for the work!! So, would you suggest that I continue with cabmame or will this fix rectify those issues without the sound tweak?

Also, I am running ddraw with ArcadeVGA. But you said there may be no need for DDraw anymore? Can you elaborate on this please?

I use all of cabmame minus the sound tweak.  It didn't work well for me.  If you are okay with an occasional tear so that sound is pretty much perfect (as it is without vsync), then I'd use my patch.  If you'd prefer inaccurate sound with a completely solid image, I'd use cabmame.

The main reason for using DDraw over D3D is the fact that ddraw has the game pixels lined up properly with the pixels on your screen.  D3D doesn't, so you get areas of the screen where you get a blend of two neighboring pixels instead of just one.  I know how to fix this problem in D3D (I've done similar things at work), but I'm not really sure how to get ddraw to triple-buffer properly without waiting for vsync all the time, which causes the sound problems.


Got it!  ;D

cboy

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 120
  • Last login:October 07, 2012, 02:09:29 am
AH, Ive been wondering about tearing...I missed this thread before


I notice it a lot when I play Bank Panic

I'm using DDraw D3D doesnt work for my video card for some reason it ends up all garbled

Is there a way to get it working if I'm using the high score/no nag compiled version of mame 131?

GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
AH, Ive been wondering about tearing...I missed this thread before


I notice it a lot when I play Bank Panic

I'm using DDraw D3D doesnt work for my video card for some reason it ends up all garbled

Is there a way to get it working if I'm using the high score/no nag compiled version of mame 131?

I'm still digging into what the problem is.  Seems like the simulation is getting ahead of real-time and causing sound buffer overflows. . that's why triple buffering isn't working properly. I'm going to continue digging.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


cboy

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 120
  • Last login:October 07, 2012, 02:09:29 am
I just tried triple buffering and i get the same sound glitching will sit and wait for you to see what more u find  :cheers:

cboy

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 120
  • Last login:October 07, 2012, 02:09:29 am
its been a while now since i had asked about this.... has there been any improvement on using triple buffering to reduce the tearing without having the sound go wonky?

GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
Sorry.  I stopped working on Mame-related stuff.  If anyone wants to have a look at it, it seems like the problem happens when the original games refresh rate is higher than the actual refresh rate on your machine.  Triple buffering in Windows isn't the kind of triple buffering that will throw away frame if it has too many.  Someone needs to modify Mame so that it'll take care of throwing away frames itself.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


dekar24k

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 378
  • Last login:April 28, 2019, 03:50:11 pm
    • ArcadeForum.com
The following MameUIFX config works perfectly on my setup (ArcadeVGA2 + WG D9800, WinXP Pro SP3 32 bit):

Options > Display:

Enforce aspect ratio: Enabled
Throttle: Enabled
Video mode: Direct draw
No hardware stretching (of course ;))

Options > Advanced:

Triple buffering: Enabled
Wait for vertical sync: Enabled
No frame skipping (Draw every frame)

Options > Sound:

Synchronize audio with video: Enabled

--

In some games (very, very few) you might notice that the sound gets pitched a little. This happens if the game's original refresh rate differs too much from the refresh rate MAME is set to run it in. In that case you will need to disable VSync, Triple buffering and audio/video sync for that particular game. You can still have vsync/triple buffering enabled if you don't want tearing, but then you will have sound stuttering which I believe is a lot worse than tearing.
Finished project: "The Saloon Arcade" - 2 player upright cabinet

Joystick.net - Retro gaming news and reviews

Huggybaby

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 43
  • Last login:November 22, 2012, 12:55:33 pm
Has anyone tried D3DOverrider to force triple buffer vsynch?

Also, the newest FBA has a working implementation for windowed mode, figured out by CaptainCPS-X.
http://neosource.1emu.net/forums/index.php?topic=1315.msg10638#msg10638

Ginsu Victim

  • Yeah, owning a MAME cab only leads to owning real ones. MAME just isn't good enough. It's a gateway drug.
  • Trade Count: (+10)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 10092
  • Last login:June 28, 2025, 10:45:55 pm
  • Comanche, OK -- USA
Sorry.  I stopped working on Mame-related stuff.

Aw man....

I was looking forward to seeing what you could come up with.

Hit a wall or just lost interest?

GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
The following MameUIFX config works perfectly on my setup (ArcadeVGA2 + WG D9800, WinXP Pro SP3 32 bit):

Options > Display:

Enforce aspect ratio: Enabled
Throttle: Enabled
Video mode: Direct draw
No hardware stretching (of course ;))

Options > Advanced:

Triple buffering: Enabled
Wait for vertical sync: Enabled
No frame skipping (Draw every frame)

Options > Sound:

Synchronize audio with video: Enabled

--

In some games (very, very few) you might notice that the sound gets pitched a little. This happens if the game's original refresh rate differs too much from the refresh rate MAME is set to run it in. In that case you will need to disable VSync, Triple buffering and audio/video sync for that particular game. You can still have vsync/triple buffering enabled if you don't want tearing, but then you will have sound stuttering which I believe is a lot worse than tearing.

I wasn't happy with the pitch shifting.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com


GaryMcT

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 745
  • Last login:September 24, 2014, 11:19:27 am
    • GaryMcT's arcade blog
Sorry.  I stopped working on Mame-related stuff.

Aw man....

I was looking forward to seeing what you could come up with.

Hit a wall or just lost interest?

Lost interest.  There are too many problems with Windows for me to get Mame running well enough for me.  I've moved onto either using the real PCB or working on FPGA implementations of boards for the long term.
My blog on learning how to develop FPGA versions of arcade boards: http://garymct.blogspot.com