News for hackers. Stuff that matters.
Re:Yuzu: Nintendo Switch Emulator by jonpalmisc on Saturday January 22, 2022 @10:31PM (#30043358)
I would love to see a Switch emulator for the M1, although I certainly understand why it'd be a last-priority for emulator developers.

I know /nothing/ about emulator development, but I wonder what the performance of a Switch emulator written for the M1 using Metal for graphics would look like. I'd expect the Switch and the M1 both being ARM would be an advantage? Would be curious to learn more if anyone in this space wants to weigh in.

Re:Yuzu: Nintendo Switch Emulator by torginus on Sunday January 23, 2022 @03:38AM (#30044612)
Afaik the main issue is not the CPU architecture, but the Graphics APIs. Macos has only very old OpenGL and doesn't support Vulkan at all. And you're right, they probably don't have the effort to spare to implement Metal.

As for the CPU architecture, probably the dynamic recompilation step that turns ARM code to x86 could be skipped.

Just to show, how viable it is, there's a closed source emulator for Android that's probably base on Yuzu (with surprising good performance):

https://www.youtube.com/watch?v=Ex_AArUJ8cY

The suspicion coming from it having the same bugs as yuzu itself.

Re:Yuzu: Nintendo Switch Emulator by zapzupnz on Monday January 24, 2022 @02:08AM (#30054456)
The graphics shouldn't be an issue. macOS supports Vulkan via Metal, using MoltenVK. Plenty of other emulators already support Vulkan on macOS that way.
Re:Yuzu: Nintendo Switch Emulator by rfoo on Sunday January 23, 2022 @03:56AM (#30044688)
> probably the dynamic recompilation step that turns ARM code to x86 could be skipped

I don't know if Switch could be emulated with Wine-like approach, if not, it would be tricky to intercept syscalls without an ARM-to-ARM DBT. Performance impact should be minimal though.

Re:Yuzu: Nintendo Switch Emulator by torginus on Sunday January 23, 2022 @04:54AM (#30044945)
I'm not an expert on the ARM64 architecture, or the Switch OS, but from what I can tell, the interface between the OS and the app consists of function calls to the OS api, and syscall-s, that are triggered by the svc instruction. I'd guess the app is statically linked against the OS API, so for the OS calls, the addresses can be patched (or alternatively the emulated OS libs can be mmap-ed to the correct address), and the svc calls can be replaced with a jump to a thunk that emulates it's behavior.

Both seem to be possible, since arm64 uses fixed instruction length. I don't think svc calls can be trapped in-process with user privileges, and it's even less likely it can be done in a portable way.

So probably some level of source-patching needs to take place, but it requires just a high-level understanding of the code, not a full decompilation-recompilation.

Re:Yuzu: Nintendo Switch Emulator by londons_explore on Sunday January 23, 2022 @05:04AM (#30044995)
Seems like a fragile approach when you can't even be sure about which bits are code and which are data... You might end up patching a svc syscall only to find out that it's actually some constant used in the logic of the game.
Re:Yuzu: Nintendo Switch Emulator by my123 on Sunday January 23, 2022 @05:59AM (#30045267)
> I don't know if Switch could be emulated with Wine-like approach, if not, it would be tricky to intercept syscalls without an ARM-to-ARM DBT. Performance impact should be minimal though.

You don't need a DBT, VMs on arm64 are very cheap. You can just use Hypervisor.framework really.

Re:Yuzu: Nintendo Switch Emulator by Gigachad on Saturday January 22, 2022 @11:31PM (#30043644)
I only know a small amount but from what I have seen, having the same CPU arch is not really that important, as we have seen, you can run x86 apps on the M1 at blazing speeds. The hardware in modern consoles is becoming pretty standard, so the vast majority of effort goes in to emulating the libraries and such the switch comes with.

Modern emulators are a lot like Wine these days where they are just translating the custom api calls to something that works on a desktop OS.

Re:Yuzu: Nintendo Switch Emulator by schappim on Sunday January 23, 2022 @04:28AM (#30044831)
>> CPU arch is not really that important

It actually depends more on the memory ordering. To speed up the running of x86 apps, the M1 has a strong memory-ordering mode designed to match x86.

Re:Yuzu: Nintendo Switch Emulator by erwincoumans on Sunday January 23, 2022 @12:14AM (#30043821)
Yes, the emu for M1 will likely run very well, and OpenGL 3.x works very reasonable on M1, despite being marked as 'deprecated'. From the issue tracker, they want to use Molten Vulkan (on Metal) and clang lacks some C++20 features they use.

I've been running the PCSX2 PS2 emulator on M1 (rendering using either OpenGL backend or Software), it runs my favorite game SSX Tricky great, including joystick support, sound and smooth graphics.

Re:Yuzu: Nintendo Switch Emulator by ohgodplsno on Sunday January 23, 2022 @10:51AM (#30047047)
No emulator wants the burden of maintaining something like an OpenGL 3 renderer. They already struggle to keep the D3D11/Vulkan/Software ones up to date. Anything else is pretty much getting the axe as soon as possible, and pretty much all of those that have an OpenGL renderer use opengl4 or gles2
Re:Yuzu: Nintendo Switch Emulator by joshspankit on Sunday January 23, 2022 @09:01AM (#30046171)
Upvoting for SSX Tricky. When I got nostalgic for games most of them are EA titles from that era.
Re:Yuzu: Nintendo Switch Emulator by erwincoumans on Monday January 24, 2022 @01:21AM (#30054249)
Thanks, I'm still hoping for an SSX sequel :)
Re:Yuzu: Nintendo Switch Emulator by aufhebung on Saturday January 22, 2022 @11:33PM (#30043650)
There is an experimental PS4 emulator that ran using QEMU, taking advantage of the fact that the PS4 is x86. Something similar could be done for M1 and ARM.

https://wololo.net/2021/09/08/release-spine-ps4-emulator-v-2...

Re:Yuzu: Nintendo Switch Emulator by toastal on Saturday January 22, 2022 @11:37PM (#30043677)
Aside: if Apple's M1 processor is ARM-based, why do we bother making the distinction? If anything I feel like this hurts more than it helps because Windows and Linux need better ARM support too.
Re:Yuzu: Nintendo Switch Emulator by kmeisthax on Sunday January 23, 2022 @12:15AM (#30043827)
Because, quite frankly, ARM silicon is held back by other vendors. Apple is unique in the ARM space in that they actually make an attempt at retaining compatibility across SoC iterations. Linus Torvalds has famously gone on multiple rants about how much of a mess ARM chips are - every new chip usually meaning a full reshuffle of the register map and new drivers everywhere. The work being done on Asahi Linux, on the other hand, is very likely to carry forward to M2, M2 Pro/Max, etc.

FWIW, M1 Macs are also one of the few ARM platforms that will let you[0] actually install regular GNU-and-Wayland desktop Linux. I think the current crop of Windows on ARM machines will also let you install Linux, of course. But most Android hardware ranges from mildly to very hostile to users who want regular Linux - even if there's a bootloader unlock, the hardware is going to require all sorts of extra vendor-proprietary drivers that won't work with a standard distro. This also ties in with what I said before about backwards-compatibility across multiple SoCs.

The reason why people treat the M1 as separate from all other ARM hardware is because it actually acts like a computer; providing the performance and control you expect from something bearing the name. Most other ARM vendors are not aiming to provide that.

[0] You do have to sign the kernel with your Owner key, but that's manufacturer-supported, so it counts.

Re:Yuzu: Nintendo Switch Emulator by dagmx on Saturday January 22, 2022 @11:48PM (#30043728)
I guess because M1 describes the entire platform in shorthand (CPU+GPU+performance characteristics), whereas ARM only describes the CPU instruction set.
Re:Yuzu: Nintendo Switch Emulator by Wowfunhappy on Sunday January 23, 2022 @08:14AM (#30045911)
According to marcan’s Twitter, Apple actually broke the ARM spec in ways most companies are literally not allowed to do. Part of the deal is likely that Apple was not allowed to call their chips ARM.
Re:Yuzu: Nintendo Switch Emulator by jonpalmisc on Sunday January 23, 2022 @08:48AM (#30046079)
Do you have the links for those tweets by any chance? I’d like to learn more about this.
Re:Yuzu: Nintendo Switch Emulator by GlitchMr on Sunday January 23, 2022 @04:46AM (#30044914)
Unlike other ARM CPUs, M1 optionally supports x86 memory model, that said, it doesn't matter outside of x86 emulation.
Re:Yuzu: Nintendo Switch Emulator by IronBacon on Sunday January 23, 2022 @03:50AM (#30044670)
From what I know, SPINE doesn't use QEMU at all to emulate a PS4, it works with the same concept of Wine, a compatibility layer that translate Orbis syscall with Linux one. Its name follows the same "SPINE is not an emulator" geek joke.

According to Google, Orbital is the one using QEMU.

Re:Yuzu: Nintendo Switch Emulator by kaladin-jasnah on Sunday January 23, 2022 @01:14AM (#30044027)
How does one GPU acceleration when running on a VM (as I imagine QEMU is doing here)?

Also random thought, but can the opposite be achieved? That is, installing Orbis (PS4 OS, based on FreeBSD) on generic PC hardware?

Re:Yuzu: Nintendo Switch Emulator by mkdirp on Sunday January 23, 2022 @02:40AM (#30044373)
This is probably not exactly the same, because I'm assuming the ps3 is maybe emulated very different, but rpcs3 is able to boot up into the XMB.

https://www.pcgamesn.com/emulation/ps3-emulator-rpcs3-xmb

Re:Yuzu: Nintendo Switch Emulator by LinAGKar on Sunday January 23, 2022 @06:18AM (#30045347)
Same with xemu, using QEMU to emulate the original Xbox.
Re:Yuzu: Nintendo Switch Emulator by tjpnz on Saturday January 22, 2022 @11:35PM (#30043662)
>I'd expect the Switch and the M1 both being ARM would be an advantage?

Most emulators interpret the machine instructions in software so there wouldn't be any advantages there. Some are now incorporating dynamic recompilation but I doubt it would have any noticeable impact on ARM vs x86.

Re:Yuzu: Nintendo Switch Emulator by monocasa on Sunday January 23, 2022 @12:18AM (#30043833)
Honestly I can see it being a higher priority for switch emulator devs pretty soon. A rpi5 would be in the right neighborhood of being able to emulate the switch when using the virtualization extensions. The CPU is already more than there on the RPi4, just the GPU is a bit anemic. If they have it working against KVM, hypervisor.framework is then an almost trivial amount of work.