Beetle PSX Dynarec – Accurate PlayStation1 emulation is about to become a lot faster!


Two years ago, we started a bounty for Beetle PSX, our own heavily modified fork of Mednafen PSX. Mednafen PSX is a highly accurate PlayStation1 emulator. However, unlike emulators like ePSXe, it only has a CPU interpreter, which means that the emulator is fairly slow and is therefore not really usable on anything but desktop PCs and high end mobile phones. The bounty was created on BountySource in hopes of attracting someone who could add a dynamic recompiler to Beetle PSX so that it could run much faster and therefore be a viable emulator on lower end hardware, such as mid range mobile phones, game consoles, older PCs, etc.

We can happily report that heavy progress is being made on this bounty right now courtesy of two bounty hunters, and we have been able to test builds which confirm that it is in fact already working for some games. Right now, the dynarec is still in a fairly WIP (Work In Progress) state, many of the more popular games will crash or hang, but the ones that do work so far show a substantial increase in maximum framerate even on a Core i7 7700k CPU.

Game Without dynarec With dynarec
Alien Trilogy 227fps 415fps
Castlevania: Symphony of the Night 190fps 380fps
Crash Bandicoot 170fps 315fps
Doom 210fps 386fps
Mortal Kombat Trilogy 212fps ~500fps
Tekken 3 178fps 224fps
Tomb Raider 218fps ~450fps

NOTE: These tests were conducted on a Windows PC with a Core i7 7700k CPU. It should be noted that this is a highly experimental build and that the performance we measured here should be considered a snapshot performance overview. Most likely when the dynarec is merged into master, we should be looking at much higher framerates still.

1x software rendering mode was used during testing.

What does all this mean?

Higher performance means the core becomes far more viable to be used on other platforms. Up until now, ARM platforms have had to resort to PCSX ReARMed for their PlayStation1 emulation needs because Beetle PSX is simply too slow to run on these systems (unless you’re using a cutting edge iPhone/Android phone of course, and even then, on a Galaxy S10+, I’ve only been able to reliably run most games at fullspeed at 1x resolution with the software renderer). This means that when the Aarch64/ARMv7 backends start working, Beetle PSX could become another possibility for people wanting to use a PlayStation emulator. There’s always room for two emulators and it never hurts to give the user several options for a certain system, especially for a system as popular and with as many games as the PlayStation1.

Higher performance also means more potential for CPU overclocking and runahead latency reduction. Both require a lot of CPU resources, so the higher the performance, the more wiggle room we have to push both.

Implementation

pcercuei made a dynamic recompiler for MIPS powered by GNU Lightning. ZachCook then backported this system to work with Beetle PSX. Previous working implementations were PCSX ReARMed and PCSX 4 All.

When will this release?

We don’t do ETAs for this, and please don’t bug the developers about this. Let them work in peace, that results in better code too. We just wanted you to know about this exciting development that has been going on since it has been at least two years since the bounty started and finally we are starting to see the dream become a reality. We for one can’t be more excited!

Beyond that, we are even more convinced than ever that bounties have been an accelerator for innovation and growth for the project all-around. Our last major smash hit feature, the AI Service, was all courtesy of a bounty funded by both libretro creators and the community alike. Together we make amazing stuff happen, and we truly have our users to thank for all the amazing support they have given this project over the years.

RetroArch Disc Project – Alpha testing has begun! Details inside

Ever since the announcement earlier on June 30th, we have been working hard on the RetroArch Disc Project, and we are now getting to the stage where we want users to start alpha testing the latest code.

We invite you to come over to our Discord channel (also linked to on the RetroArch website – click on the tab ‘Discord’)- and join the channel #discordproject.

How to apply for alpha testing

For the purpose of this alpha test, we need you to meet the following requirements:

  • You are using the latest nightly versions of RetroArch (available here).
  • You are using RetroArch on PC, and are running either Linux or Windows with the CDROM support included.
  • Make sure the cores you are going to be testing are the latest up-to-date versions. Update them daily from the Core Updater if unsure – the cores should have physical CDROM support, otherwise the testing won’t work.
  • You have an optical disc drive (either USB or internal, any CD-ROM/DVD-ROM/BD-ROM drive should do).

Report issues you’re having with physical CDROM playback. Be as detailed as possible in your feedback – we are especially interested in which optical disc drive you’re using.

Be prepared that you might be asked by a moderator to run ‘retroarch_debug.exe’ and return a log message back to us in order to learn more about the issues you’re having. ‘retroarch_debug.exe’ is a debug executable that should be shipped with every RetroArch nightly version for Windows. For Linux users, we assume that they can build from source and compile with CDROM_DEBUG=1 manually in order to run these more detailed debug tests.

Compatible cores

Listed below are some of the cores that we added physical CD-ROM support to, and the ones that we would like you to test –

  • Beetle PSX (HW and non-HW)
  • Beetle Saturn
  • Genesis Plus GX
  • 4DO
  • Redbook Audio Player (Audio CD core)

We have also added support to more cores, but for now we want to go with these cores as they have been most extensively tested.

A couple of known edge cases:

  • Beetle PSX HW: The ‘vulkan’ renderer can exhibit issues where either the CD will not work, or some other corruption issue will manifest itself. We recommend you use ‘opengl’ or ‘software’ for now while you test CDROM.
  • Beetle PSX HW: Make sure the core option ‘CD Access Method’ is not set to ‘precache’. If you do, real discs won’t work.

How to load discs

1.You need to first start up the core itself (there is no automatic system detection yet when you insert a disc).
Go to Load Core, and select the core you want to use.

2. Once the core is loaded, select ‘Load Disc’.
3. It will now list all optical drives. Make sure the disc you want to use has been inserted into the optical drive tray and make sure the tray is closed. Then select the drive. The core will now start with your CDROM as input.

How to dump discs

RetroArch can dump discs to internal storage in bin/cue format. The video above will show you how.

  1. Select ‘Dump Disc’.
  2. It will now list all optical drives. Make sure the disc you want to use has been inserted into the optical drive tray and make sure the tray is closed. Then select the drive.

The disc will now be dumped to the ‘Downloads’ directory. It will continue showing the progress bar until the operation has finished. In the meantime, you can play any core/game (as long as it doesn’t involve real CD playback) until the dumping has finished.

Redbook Audio Player – Libretro core for music CD playback!

As a testbed for the Disc Project, we made a redbook audio CD player Libretro core!

You can grab this core for Windows and/or Linux by going to Online Updater, and downloading it from the list (Redbook Audio Player).

Known potential issues

  • Right now, CDROM works better on Linux vs. Windows.
  • FMV playback with Beetle PSX HW has the potential to be slow on some optical disc drives on Windows. Cause yet unconfirmed.
  • There is a known issue with redbook audio – the redbook audio track begins a few seconds later from its starting period.
  • Libcrypt copy-protected PlayStation1 games will not work right now, but any other copy-protected PlayStation1 disc should.
    Here is a listing of some Libcrypt-protected games from Europe: https://hastebin.com/ruyacahuba.http . You can generally assume these won’t work.

New Vulkan graphics enhancements features in Beetle PSX HW!

MDEC YUV filtering

PlayStation used a special unit called the MDEC to decode full motion videos instead of relying on software rendering (like the Saturn). These videos were encoded in YUV macroblocks and had to be converted from YCbCr to RGB so that the PSX can output the final image to the screen. A common issue with PlayStation emulators is that the chroma channel generally should be smoothed, but the PlayStation tend to leave it unfiltered.

There’s now a feature called ‘MDEC YUV smoothing’ which does filter the chroma channel. You can see the before/after screenshot above (video in question is the Resident Evil 1 intro) to see the kind of visual enhancement this brings to the picture.

SSAA (Super Sampled Anti Aliasing)


Some people prefer to play PlayStation1 games at native resolution and just applying a CRT shader at the end instead of running them at very high resolutions. However, there are some issues with that approach. 3D polygon graphics can tend to look very aliased and jagged and lacking in definition.

Alternatively, others like to crank the resolution up as high as possible. Both approaches have their pros and cons, but a definite disadvantage is that early 3D was very primitive so you might not want to see razor sharp angular polygons rendered at obscene resolutions, especially when a game relies a lot on pre-rendered backgrounds and other 2D elements. The Final Fantasy and Resident Evil games come to mind for one.

The option ‘Adaptive smoothing’ already exists and it attempts to distinguish 2D elements from 3D elements. It will smooth out the 2D elements but leave the 3D elements alone, resulting in a high resolution picture with the 2D elements not looking pixelated and ugly.

This new Vulkan-only option, SSAA, is a completely new approach. The image is rendered at the internal resolution you set it at (2x/4x/8x/16x, you name it). It then downsamples it at the final output stage back to a resolution somewhere in the ballpark of 240p. What you get is a low-resolution image with very clean anti-aliased 3D, kinda similar to the N64 actually which had native 8x multi sampled anti aliasing of some sort.

Certain CRT shaders expect a 240p-ish image to look their absolute best, so this option lends itself very well to that. It also can tend to look bit more coherent with mixed 2D and 3D in cases where adaptive smoothing fails.

Tip: We recommend you turn dithering off when using SSAA (Super Sampled Anti-Aliasing).

Example – Final Fantasy IX

Below you see SSAA in action with Final Fantasy IX on RetroArch. The first image is SSAA at 1x internal resolution. The second image is SSAA at 8x internal resolution. You can see how the downscaling does its magic in the second picture – it results in an image that almost looks like as if the polygon characters are part of the background itself.

Finally, a CRT shader is used – crt-royale-ntsc-320px.

Final Fantasy IX – SSAA at 1x internal resolution with CRT Royale
Final Fantasy IX – SSAA at 8x internal resolution with CRT Royale

Dithering for Vulkan

PlayStation and N64 output the final image at 16 bits per pixel. Since that isn’t a particularly wide colorspace, both systems used dithering in order to fake the illusion of a larger palette of colors. This combats color banding and wouldn’t be very noticeable at native resolutions on a CRT TV. On more powerful hardware and when emulated, the limitations of this approach become clear, and some would prefer either internally rendering the dithering at the internal resolution, or disabling it altogether.

Dithering was previously ignored by the Vulkan renderer and was always turned off, no matter what you configured. Now it will actually let you enable it. If dithering is enabled, the scanout image will be 16 bits per pixel. If it is disabled, the scanout image will be 32bits. We recommend that you turn dithering off if you are going to be using ‘SSAA’ (Super Sampled Anti Aliasing)