19 Apr 2025
The unix philosophy speaks clearly - do a thing and do it well. What if there was a need to show a browser window, the time, weather, or even, given the current situation, stock prices. An embedded device with an external display would be a no-brainer choice for such project.
However, could a modern MacBook running Linux be utilized instead?
Asahi Linux is a project that ports the Linux kernel to Apple Silicon MacBooks via reverse-engineering the vastly undocumented hardware. The whole project has made invaluable contributions to freedom. The combined effort on all fronts allowed for a very stable Linux desktop experience on the newest hardware.
There are topics to be explored before jumping into a project such as this one. The graphics stack being one of them - after all, that is what will make our kiosk display stuff on the screen! What follows is a bird's eye view of the Linux graphics stack.
The kernel should provide free-as-in-freedom GPU drivers out of the box. A problem arises when there is hardware for which no drivers were written. Worse yet - undocumented Apple hardware.
Asahi Lina wrote the first kernel GPU driver for the Apple M-series and done so in Rust, thereby also claiming the spot for the first Linux GPU driver written in Rust. They made it possible to utilize the hardware and overall allowed us to understand the graphic accelerators more. All that is, at least in this very simplified scenario, left to do is to send instructions from the user-space so the accelerator knows what to do!
There are many graphics and compute APIs one can utilize to draw a game, a graphical application or heck, a whole Window Manager. Namely OpenGL, often utilized for desktops, and Vulkan. As it would be unreasonably difficult to implement support for every GPU into each of these APIs, and it would also disregard the unix philosophy, an intermediate layer, Mesa, came to be. It contains various user-space drivers capturing buffers from the graphics APIs and translates them to calls the underlying kernel GPU driver understands.
The user-space GPU driver on Asahi Linux is called Honeykrisp, with Alyssa Rosenzweig as the main contributor. This driver is Khronos-recognized and, at the time of writing this, is conformant with Vulkan 1.4, OpenGL 4.6, OpenGL ES 3.2, and OpenCL 3.0. Honeykrisp is not entirely upstreamed to Mesa yet, that is why Asahi uses its own fork, Asahi Mesa, with all the patches present.
tinywl is the reference compositor implementation of wlroots, an abstraction library over Wayland. To test the ability of building parts of the Linux graphics stack locally, I decided to attempt to run tinywl through a locally built Mesa and wlroots. Building, apart from some minor hiccups, was quite pleasant as to be expected from Fedora, the distribution Asahi Linux is based on.
After the builds were finished, it was time to run tinywl as a session compositor nested inside of the already running Mutter. Using meson devenv pointing to locally built Asahi Mesa and running tinywl in the newly built wlroots directory. I heard the positive Honeykrisp Vulkan news and was excited to try the Vulkan renderer.
And tadaa ~ it did not work!
Vulkan layers and extensions
allow for the insertion of additional functionality or structures to the
base Vulkan spec. The Honeykrisp driver was missing an extension required
by tinywl, specifically the VK_EXT_queue_family_foreign
, to
utilize the Vulkan renderer properly. I added the extensions locally and
rebuilt.
Voilà, a wild tinywl window has appeared on the screen! I submitted a feature request in the Mesa issue tracker with Alyssa Rosenzweig swiftly adding the extension into Honeykrisp and marking the request as done.
With tinywl running as a session compositor I felt confident to run cage as a system compositor. After cloning and building cage I stumbled upon an issue - to run it via the Vulkan renderer, it required even more extensions to be enabled. Not a problem, I added them as before. Cage started just fine as a session compositor after this addition. However, as it had to start from a locally built version of Mesa running through meson devenv, which prohibits the use of root access, it was not possible to run it as a system compositor. To avoid installing a custom version of Asahi Mesa on the system or waiting for a new version to be packaged I decided to drop the Vulkan renderer and instead opted for OpenGL.
After creating a new entry in
`/usr/share/wayland-sessions`
, it was possible to launch cage
running a terminal window, as shown below!
I waved the white flag on the Vulkan renderer, but other than that I consider this experiment to be a success. I am now able to experiment with Cage and the HoneyKrisp driver on Asahi Linux, perhaps submitting more feature requests making it possible to run Cage through Vulkan.
Until then, OpenGL for desktop it is!