3D games working on Apple GPU on Linux at 4K!

Yup, pretty impressive. Certainly doesn't hurt that they could build on the previous work of getting OpenGL stood up, and I think using NVK as a starting point proved to be a good call from the description.

Still, that means there will be some fun stuff for me when it comes time to consider what to do with my M1 Mini.
 
Something I think is kind of interesting is how Asahi Linux works around the 16K vs 4K page size when emulating x86 apps, in particular games. They actually use a microVM (in addition to Wine/Proton) to run the software with near bare metal performance:

I can't remember how this is solved on macOS for Wine.
Ah here we go:


That's the issue: 16K pages never exist alongside 4K pages in the same address space half. The CPU has two mode flags, for kernel and userspace respectively. There is no way to mix modes within the same address space half. And changing the page size completely changes the page table structure and boundaries for different walk levels, the huge page size, etc.
Rosetta runs the userspace half in 4K mode, and XNU had to be reworked a lot to support this. Linux could of course be reworked to do something similar on paper, but it's a hugely intrusive change

That’s why it works in macOS. Later Hector talks about one possible solution, but now we know they went with a different approach: microVMs.

But apropos of the above, remember the online consternation that Apple was going to abandon Rosetta 2 right away? Good times. So not only does Apple own Rosetta 2, by developing it unlike v1, but had to make substantial changes to their kernel for it, and of course it’s (partially) powering their gaming initiative through GPTK. Somehow I don’t think it’s going away anytime soon …
 
Android moving to 16K pages




Devices with larger page sizes can have improved performance for memory-intensive workloads. As device manufacturers continue to build devices with larger amounts of physical memory (RAM), many of these devices will adopt 16 KB (and eventually greater) page sizes to optimize the device's performance. Adding support for 16 KB page size devices enables your app to run on these devices and helps your app benefit from the associated performance improvements. We plan to make 16 KB page compatibility required for app uploads to the Google Play store next year.
 
Back
Top