Emulators is dead, current recompilers suck

2026-11-14 - 9 minutes

Recently a vulnerability in the Nintendo Switch 2 has been found which allows dumping userspace applications, which promptly sparked a lot work on emulators to get console exclusives to work on other platforms. The wide knowledge obtained on the original Switch by homebrew and emulator developers gave everyone a head start. While the built in chip is newer, it’s still an ARM64 CPU with an NVidia GPU. The architectural differences in the operating system are mostly invisible to games.

Two ways of running obtained games on a PC got very popular. Emulators, who dynamically convert the games code into native code segments, and recompilers, who take the original executable once and emit another that can be run from that point onwards. While being unfamiliar with both topics previously, I do know a bit about the original Switch from my homebrew days.

Looking into these projects, I found that these are all modeled in a very ineffective way. I don’t believe that any incremental update to them can result in a satisfactory performance so I want to propose an alternative way going forward. To bring my point across, lets start looking at the issues we encounter, trying to get a switch game to run on a desktop PC.

🔗Differences from a desktop PC

🔗Memory architecture

On both consoles, there is only one continuous memory bank. Games can get up to 7GB (3.5GB on Switch 1) and they are responsible for managing it throughout their execution. Allocation usually happens once at startup and runtime allocation works on that slap. The graphics chip gets access to that exact memory in regions where the game allows it. Creating a texture or 3D model data to be drawn on screen is all done in the games process, the GPU does no book-keeping on what the memory means.

On a desktop system you usually have main memory next to the CPU and VRAM on the GPU. The link between them is the PCIe link and control and data goes throught that channel. Modern systems allow cross mapping them. This allows bypassing the control channel and allows for a lower computational overhead because it mostly eliminates the control channel. The latency is orders of magnitude higher than each processors dedicated memory so you wouldn’t want to source textures from main memory, except for one off scenarios. A game would request memory on the GPU and copy data to it. Persisting data there for a long time is desireable.

🔗CPU

Horizon, the operating system underneath, only runs on two of the eight cores. Core 0-5 are dedicated to the running application and while threads are managed by the kernel, execution is cooperative and games are self responsible for not starving them.

On desktop, typically you contend for execution time with every other process running. Mechanisms exist for requesting higher or lower priority in the systems scheduler. Anything you do can be interrupted if something else comes up or the kernel doesn’t like you.

🔗GPU

Every game ships its own graphics driver and everything that will execute on the GPU comes from it directly. Games typically ship their shader programs already precompiled for the exact chip. They know which chip they run on so everything can be specifically made, just for that chip, which includes texture formats too. The graphics driver also emits the chips control instructions in-process and sending a list of draw commands is just another memory copy. Starting execution of either instructions is an instruction to the GPU to continue execution at the requested memory address.

On desktop, games target a graphics API (nowadays Vulkan, DirectX 12) which provides a common abstraction over a variety of graphics cards manufacturers. They don’t ship the drivers themselves. That is the task of the operating system and card vendor. In vulkans example, you will have a shim library you link against, which will look up what drivers to actually load. The control channel is a large set of functions from that driver. Here, games don’t have the luxuary of knowing which chip they run on so they ship an intermediate shader code which the graphics driver will have to translate.

🔗Shim/Interface

The specifics between each emulator is different but the general ideas stay the same, from my findings.

🔗Memory

Games will get their own memory, similarly sized to the console. They carve out what area gets to be read by the GPU but it still manages that slap on its own. On the seams that attribute meaning to any part of it, the emulator will have to give it meaning on our end. Textures, vertex and index buffers will have to be created and copied to the GPU, persisted, and, on future access, the same mirrored memory will be used.

Some of these two copies have to be kept in sync as either side might read from or write to them. Traversal might update floor tiles when entering new areas as the CPU reads in data from the ROM. Occlusion results being streamed back are required to determine what is displayed on the next frame. These copies are abysmally slow and can either produce stutter if we decide to wait for the result or produce the wrong result if we decide not to do it. Setting up canaries and elaborate heuristics have to decide if we copy data back in either direction.

Attributed meaning can change at all times and locations can overlap. The location of a light source might influence the size and memory location of a render texture frame-to-frame. Switching to a different render resolution of the screen requires a differently sized render target. These and to the emulator it looks like a new texture every frame. More heuristics decide what we can re-use the old attribution, if we should cache it for the next time or discard it entirely.

🔗CPU

If you aren’t using an ARM64 CPU on your desktop, we’ll have to translate the games code into something you can run here. This usually happens when the game code executes and can be accomplished fairly quickly. It only has to happen once for any function as the game is not allowed to modify its own executable.

Games can rely on execution ordering on the Switch or write code that can deadlock but always runs fine on the console. To support these messed up games, we have to keep the execution ordering mostly in place and can’t use as many cores as we could throw at it or use the operating systems scheduler.

🔗GPU

Since we can’t pass the control and shader code emitted by the game to the GPU, we have to interpret what the game wants and turn that into e.g. Vulkan. The games drivers upload a known set of “macros” which we require to understand what its control code and draw commands mean. When it is done and issues the draw commands, our work only just starts. A few memory copies on the switch explode into a huge task for us. We have to tear the GPU instructions apart, find what resources we need, create or resolve them to cached entries and issue equivalent vulkan commands. If we don’t want to interrupt the game until we are done, we have to copy aside everything the game might overwrite again.

Game shaders, even if translatable, have to be combined with its context and compiled by the host driver. This is another source of the stutter and more visibly irritating to most users as most emulators show it and reloading caches is also visible.

The mentioned texture specialization manifests with ASTC compressed textures which don’t work on Arc and Radeon cards. If the game wants to draw such a texture, it has to be converted into a format our GPU can draw. Doing it on-the-fly with compute shaders can work but then we loose hardware intrinsics and more runtime performance.

🔗A dead end?

Old consoles are primitive compared to whatever device you read this on, even if it’s a 15 year old EBook reader. Emulating them to be accurate can be accomplished by having a device that is faster in most regards and throw more compute at the remaining parts. Mores law is dead and a PC released today isn’t hundreds or thousands of times faster than consoles released 10 years ago. Of all parts, your graphics card probably got the most relative growth. Your memory isn’t 100x faster or bigger. Your CPU didn’t get anywhere as many relative cores and latency between any of them is bound by the speed of light.

There are now powerful devices which use a unified memory architecture, similar to the switch, which do solve parts of our issues.

The original Switch is almost a decade old at this point and its chip is two years older. We got emulation on it years ago and, for the most part, it can run well and accelerates on mobile devices too now.

Just hope that games don’t rely too much on the hardware specific differences.

🔗Enter: Ocarina of Time remake

The game looks great is fun and runs fantastically on the original console. I have bought my own copy and do enjoy it. I kinda wish I didn’t get side-tracked with this, but here we are.

To much dread of Nintendo, the game came out before they could fix the vulnerability stated above and the game can now be dumped, distributed and played on other systems, outside of Nintendos power.

Lucky as they are, the game relies on things that are hard or close to impossible to emulate well. Pretty much everyone is having a bad experience right now, as much as they want to convince you that it runs great. The examples mentioned above are exact issues that plague current emulators. I have looked into improving one of them and eliminating a few of them is possible in a generic way but most have now resorted to adding a lot of game specific patches.

🔗Recompilers

Another way of playing the game has been on the rise and it gives us a bigger leverage over the game at the cost of general applicability. Emulators will resolve one issue and other games can benefit. Resolve one issue here and it might only help in one game. We’ll take the entire game, convert its code into host native instructions ahead of time and insert patches somewhere in the process. We can replace portions of the code and choose an implementation that works better for us or modify general behavior.

In reality, non of the projects make any use of that leaver. They are all practically still an emulator, use too much memory and crash when it runs out. Game code executes pinned to the same six cores, internal memory pools stay the same, the mirroring memory model stays. The same heuristics the emulators implement to know when GPU data has to be synced and can be freed is implemented here and its just as flawed.

The faced issues mostly aren’t intrinsic to OoT’s high level code but implementation details in their lower level functions. It’s texture handler is designed to work on unified memory. The renderer doesn’t have to keep render textures around or at stable addresses, as its target does not care about either. While its built for six cores, we can unlock more and spread its work out.