In the context: Apple keeps the inner workings of the M1 processor family a secret from the public, but dedicated developers have reverse engineered it to create open source drivers and the Asahi Linux Linux distribution for M1 Macs. In the process, they discovered some interesting features.
In her efforts to develop an open source graphics driver for the M1, Alyssa Rosenzweig recently found a fad in the M1 GPU rendering pipeline. She rendered increasingly complex 3D geometries and eventually stumbled upon a bunny that triggered a GPU bug.
Essentially – and note that this and everything else I’m about to say is an oversimplification – the problem starts with poor GPU memory access. It’s a powerful GPU, but like the iPhone A-series SoC it shares a common ancestor with, it uses shortcuts to keep things efficient.
Instead of rendering directly to the framebuffer, as a discrete GPU can, M1 performs two frame passes: the first one finds the vertices, and the second one does the rest. Obviously the second pass is much more intensive, so between passes the dedicated hardware segments the frame into tiles (basically mini-frames) and the second pass is taken one tile at a time.
Tiling solves the problem of lack of memory resources, but in order to later put the fragments together into a frame, the GPU must store all the data for each vertex in the buffer. Rosenzweig found that whenever this buffer overflowed, rendering failed. See first rabbit above.
One of Apple’s presentations explains that when the buffer fills up, the GPU produces a partial render – that is, half a rabbit. In Apple software, the buffer in question is called parameter bufferthe name appears to be taken from the Imagination PowerVR documentation.
Imagination is a British company that, like Arm, develops processors that it licenses to other companies. In early 2020, Apple signed an agreement with the company that allows Apple to license a wide range of its intellectual property. It is understood that the M1, which was released to the market at the end of 2020, uses its PowerVR GPU architecture as a kind of basis for its GPU.
However, back to the rabbit. As you might guess, partial renders can be stacked together to create a render of the entire bunny (but with a dozen additional steps in between, of course).
But this render Still not quite right. You can see the artifacts on the rabbit’s foot. Turns out this is because different parts of the frame are split between the color buffer and the depth buffer, with the latter misbehaving when loaded with a partial render.
Reversing the configuration from the Apple driver fixes the problem, and then you can finally render the rabbit (below).
It’s not just the open source Rosenzweig graphics driver for the M1 that goes through all those image rendering hoops: that’s how the GPU works. Its architecture was probably not designed with 3D rendering in mind, but regardless, Apple has turned it into something that can compete with, if not outperform, the latest discrete GPUs, as Apple claims. This is great.
Head credit: Walling