Raspberry Pi 4 MAME performance guide

I offer up to date MAME binaries for Raspberry Pi hardare, which can be downloaded here:

MAME for Linux runs quite well with default settings on regular x86 desktop and laptop systems, however needs some config tweaking to run well on a Raspberry Pi 4.

Notes

  • This guide is current to the February 2023 stable release of Raspberry Pi OS ("RPiOS").
  • CHECK THE NO-VIDEO BENCHMARKS:
  • This guide is for the Raspberry Pi 4 hardware ONLY. I may do older Raspberry Pi model guides at a later date.
  • This guide is for Raspberry Pi OS stable, currently based on Debian 11 "Bullseye". Driver changes for other distros will make them different.
  • I'll make some comments here about the CURRENT Vulkan drivers, which do not apply to new development versions or other distros. There are clever people working on updated Vulkan drivers for the Raspberry Pi 4 which will likely appear in future releases, and offer much better performance than what I'm seeing here.
  • I'll make some comments here about x11 vs Wayland, which do not appy to new development versions or other distros. Like the Mesa drivers, new Wayland code will likely be better in future releases, but this guide is only about the current stable release.

Find the version of Raspberry Pi OS you are running with the following command: lsb_release -a

This guide applies only to the following version:

Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

tl;dr

Fastest settings are as follows. These are the command line flags you need to set them at runtime, or you can edit your ~/.mame/mame.ini to make them permanent.

  • Higher than HD / 1080p (e.g.: 4K, UHD, 1440p, etc) - don't use this. Set your video to HD / 1080p.

  • HD / 1080p

    mame -videodriver x11 -renderdriver opengles -video accel -prescale 2 [other_options] <romname>
  • 720p or lower:

    mame -videodriver x11 -renderdriver opengles -video accel [other_options] <romname>

    Resolution

  • The Raspberry Pi 4's GPU is somewhat poor at scaling currently.

  • The device can output video at 4K (aka UHD / 2160p / 3840x2160 pixels), however it can really only achieve 30FPS. Fine for movies and TV, but not games.

  • Lower resolutions are easier for the GPU to scale to. If you're using a high resolution monitor or tv, force the RPi's resolution to be HD / 1080p. On a 4K TV this will give you a perfect 2:1 scale and still look fine.

  • 720p and 480p / VGA resolutions are faster again, although the RPi4 can achieve more than 60FPS at HD / 1080p, so no point going that low unless it's the native resolution of your display.

  • 1080p and 720p-and-lower resolutions require slightly different settings due to the RPi4's behaviour with scaling at certain resolutions. See below.

Video drivers

  • x11 is the fastest render driver for the current RPi drivers
  • KMS (direct Kernel Mode Settings from the command line direct to the framebuffer device) are very slow currently, and can't be used
  • Wayland is still very immature on the current stable RPiOS, and can't be used.

Settings

MAME's settings can be set either in the command line, or in your ~/.mame/mame.ini file. You can generate a new/default version by running mame -cc. This will generate three files - mame.ini, plugin.ini and ui.ini in the folder you ran the command. Create a ~/.mame folder (note the period before the word "mame"), and move the files there. You can edit these with any standard text editor.

The video settings are critical for smooth MAME playback, particularly at high resolution.

videodriver

The videodriver setting needs to be x11. The KMSDRM (Kernel Mode Setting Direct Rendering Manager) and Wayland options are too slow on current RPi4 drivers.

renderdriver

The renderdriver setting works best for all modes when set to opengles. Standard "opengl" works almost as well, however the RPi4's lightweight GPU does much better with the "opengles" API designed for mobile and lightweight GPUs.

video

The video setting works best when set to accel for all modes.

Specific to HD / 1080p, couple this with setting prescale to a sensible value (see below). This helps the lightweight GPU by software scaling the image before hitting the GPU.

prescale

The prescale setting should not be used for 720p or lower modes, as it negatively impacts performance.

For HD / 1080p and -video accel, it is quite beneficial, as it scales the picture internally prior to the GPU doing scaling, where the RPi4 is quite weak at HD / 1080p resolution.

-prescale 2 is generally a good option. "-prescale 3" is a little slower than 2, but "-prescale 4" degrades performance quite a lot.

Ensure that the chosen value multiplied with the original game resolution doesn't exceed the screen resolution, otherwise it can cause visual artefacts as the GPU scales it back down. Likewise, factor in rotation when scaling vertical games on a horizontal screen or vice versa.

BGFX / Vulkan

MAME supports the BGFX API, which is a software stack that allow things like complex shaders that do a very visually pleasing job of various image blending and smoothing options, simulating CRT displays, etc.

Sadly the current Rasperry Pi OS's drivers don't do a particularly good job at handling this. Best to avoid these features all together with this hardware until drivers mature in future releases.

Likewise BGFX's Vulkan implementation in the current stable RPiOS is not yet working. A lot of hard work is being done in the Mesa project to improve this, but it is not available in RPiOS just yet. Other distros may offer this, but are outside the scope of this guide.

Overclocking

Overclocking your RPi4 is very beneficial if you can do it safely. How far you can overclock will depend on your specific board, as well as your cooling solution.

Don't overclock without at least a heatsink (and a fan if the heatsink is small), as the RPi will throttle the CPU and GPU if temperatures get too high, hurting performance.

My personal device has a very large passive heatsink/case combo, and my overclock settings are in /boot/config.txt, and are as such:

gpu_freq=600
over_voltage=6
arm_freq=2000

These give me around 10% higher framerates in MAME than stock speeds.

Benchmark it yourself

Benchmark MAME for yourself to test your own settings. Remember that some games need manual setup first before you can run a benchmark (e.g.: Mortal Kombat needs to be run once to reset CMOS settings, then can be run subsequently after the NVRAM file is populated).

To run a pure CPU benchmark with no video/sound, run:

mame -bench 90 <romname>

To run a benchmark with video and sound, you need the minimum settings:

mame -norc -nothrottle -nosleep -nowaitvsync -nowindow -str 90 [other_options] <romname>

For example, to run at 1080p with my recommended settings:

mame -norc -nothrottle -nosleep -nowaitvsync -nowindow -str 90 -videodriver x11 -renderdriver opengles -video accel -prescale 2 <romname>

You will get a benchmark as a percentage of overall speed. Aim for at least 150% average speed when benchmarked for the best experience while playing.

Data

Benchmark runs on a stock (1.8GHz) RPi4 produced the following data. pacman is used as the ROM and the -noautorotate flag is passed to run it in 4:3 ratio. In benchmark mode the game reaches 2467%, and is a good choice to test the the video driver limitations of the system.

1080p

Avg% videodriver renderdriver video prescale
152.31 x11 opengles2 accel 2
147.19 x11 opengles2 accel 3
134.42 x11 opengl accel 2
133.69 x11 opengles2 opengl 2
133.67 x11 software opengl 2
133.54 x11 opengl opengl 2
120.97 x11 opengl accel 3
117.86 x11 opengles2 accel 1
112.62 x11 opengl accel 1
112.43 x11 software accel 1
109.39 x11 software opengl 3
109.25 x11 opengl opengl 3
109.13 x11 opengles2 opengl 1
109.10 x11 opengl opengl 1
107.95 x11 opengles2 opengl 3
107.20 x11 software opengl 1
102.65 x11 software accel 2
101.12 x11 opengles2 soft 1
100.86 x11 software soft 1
100.75 x11 software soft 2
100.52 x11 opengles2 soft 3
100.43 x11 opengles2 soft 2
100.23 x11 software soft 3
98.72 x11 software accel 3
69.73 x11 opengl soft 1
69.22 x11 opengl soft 2
68.29 x11 opengl soft 3

1080p bgfx

Avg% videodriver video bgfx_backend prescale
49.43 x11 bgfx opengl 1
26.18 x11 bgfx opengl 2
18.97 x11 bgfx opengl 3

720p

Avg% videodriver renderdriver video prescale
346.91 x11 opengles2 accel 1
331.64 x11 opengles2 accel 2
313.00 x11 opengl accel 1
300.55 x11 opengl opengl 1
300.07 x11 opengles2 opengl 1
299.58 x11 software opengl 1
269.25 x11 opengl accel 2
258.66 x11 opengles2 accel 3
221.81 x11 software opengl 2
220.19 x11 opengles2 opengl 2
216.90 x11 opengl opengl 2
207.74 x11 software accel 1
206.66 x11 software soft 2
205.92 x11 opengles2 soft 2
204.19 x11 software soft 1
202.90 x11 opengles2 soft 1
202.86 x11 opengles2 soft 3
202.32 x11 software accel 2
194.24 x11 software soft 3
183.97 x11 opengl accel 3
179.69 x11 software accel 3
146.47 x11 opengl soft 3
144.05 x11 opengl soft 1
140.37 x11 opengl soft 2
137.22 x11 software opengl 3
135.84 x11 opengles2 opengl 3
134.67 x11 opengl opengl 3

720p bgfx

Avg% videodriver video bgfx_backend prescale
110.46 x11 bgfx opengl 1
57.67 x11 bgfx opengl 2
40.15 x11 bgfx opengl 3

480p

Avg% videodriver renderdriver video prescale
748.64 x11 opengles2 accel 1
671.33 x11 software opengl 1
666.45 x11 opengl opengl 1
645.26 x11 opengles2 opengl 1
643.69 x11 opengl accel 1
496.51 x11 software accel 1
473.42 x11 opengles2 accel 2
449.31 x11 software accel 2
439.75 x11 software soft 2
438.86 x11 software soft 1
435.66 x11 software soft 3
415.37 x11 opengles2 soft 1
408.44 x11 opengles2 soft 2
398.30 x11 opengles2 soft 3
361.97 x11 opengl accel 2
311.16 x11 opengl soft 3
311.08 x11 opengl soft 2
309.60 x11 opengles2 accel 3
307.75 x11 opengl soft 1
306.09 x11 software accel 3
272.54 x11 opengl opengl 2
271.93 x11 opengles2 opengl 2
271.56 x11 software opengl 2
219.37 x11 opengl accel 3
155.32 x11 software opengl 3
155.20 x11 opengl opengl 3
154.92 x11 opengles2 opengl 3

480p bgfx

Avg% videodriver video bgfx_backend prescale
279.78 x11 bgfx opengl 1
123.04 x11 bgfx opengl 2
94.39 x11 bgfx opengl 3