A Linux GPU Driver for the M4 Mac mini Was Written in a Month with AI
Translated by a model; the original is in Russian.
Developers Cody Ho and Niklas Sheth have described how, in roughly a month, they built a graphics processor driver for Apple Silicon chips on Linux—a task that normally takes years. The driver already passes the OpenGL ES 3.0 conformance tests in full and, according to the authors, is fast enough to run Minecraft at 200 fps, as well as WebGL in Chrome and Firefox on an M4 Mac mini.
Clean room and hypervisor
The work was done using the “clean-room” method: Apple's original binaries were not studied; the only things analyzed were hardware traces captured through a hypervisor the author had written earlier, along with their own shaders. Apple's mandatory closed blobs were treated as opaque objects, and documentation for them was written, at the authors' request, by an outside person. All the experiments have been published so that the provenance of the code can be verified.
The main difficulty lay in reverse-engineering the ABI of the GPU firmware (Apple calls it AGX). On Apple Silicon the kernel does not talk to the hardware directly; instead it exchanges data with the firmware running on the closed RTKit OS through shared structures in memory, where firmware fields are interleaved with host fields. On the A18 Pro chip this ABI turned out to be markedly more complex than the already very tricky M1: one and a half times as many structures, twice as many pointers. The author gives credit to Asahi Lina and Alyssa Rosenzweig, who reverse-engineered the M1/M2 back in the day.
The role of AI agents
Most of the drudgery was taken on by AI agents—Codex (on the GPT-5.6 Sol and GPT-6 Astra models) for reversing the firmware and Claude for the disassembler. The approach was built on reproduction: see what macOS does, replicate it, then implement it independently. Codex saved the GPU's memory state, restored it after a reboot, and gradually replaced the copied pages with its own code.
Human intervention was still needed. A capture of the compute workload's state initially weighed 336 MB and could not be reproduced; the fix was to boot into single-user mode with rendering disabled and take a tiny, clean trace. The author also notes the agents' weaknesses: Codex is “pedantic” and sometimes disappears into inconsequential details for a long time. Tellingly, his colleague Niklas—whose agent was “grounded” by the need to build Mesa and pass the Khronos CTS tests—made significantly faster progress.
The described “workaround” can be counted as a separate curiosity: to get around overly strict security restrictions that kept halting the agent, the author wrote a daemon that takes a screenshot once a minute and, if the picture hasn't changed, enters the continue command itself.
What's next
The plans include Vulkan, OpenGL 4.6, OpenCL, ray tracing, and running Direct3D 12 through Proton. The code is not yet ready for end users. Upstreaming into the Linux kernel will be difficult: the M1/M2 driver itself has not been accepted yet, and for what is essentially the first GPU driver written almost entirely by AI, the authors expect heightened skepticism and stricter scrutiny—problems that, as they admit, machines will not help solve.
Source: Hacker News
Comments
Sign in, to comment.