First triangle ever rendered on an M1 Mac with a fully open-source driver
twitter.com
twitter.com
https://rosenzweig.io/blog/asahi-gpu-part-5.html https://rosenzweig.io/blog/asahi-gpu-part-4.html https://rosenzweig.io/blog/asahi-gpu-part-3.html https://rosenzweig.io/blog/asahi-gpu-part-2.html https://rosenzweig.io/blog/asahi-gpu-part-1.html
I remember tiling techniques being used on desktop mostly for localising lighting passes. Being able to cache framebuffer tiles to get past memory bottlenecks is a more interesting insight.
But the simple triangle still means that most of the render pipeline already works. The next step in the "Hello Triangle" evolution would be to apply a texture to the triangle.
For traditional rendering, a vertex shader outputs float4 position and a bunch of other per-vertex attributes which may contain normals, colors, texture coordinates, or anything else. GPU hardware itself only uses the positions.
The hardware rasterizes triangles into pixel grid, interpolates the rest of the per-vertex attributes over the triangle, and calls the pixel shader for each pixel covered by the triangle passing the interpolated per-vertex attributes.
It’s more complicated in reality: clipping, early depth rejection, pixel shaders need partial derivatives so the pixels are grouped into 2x2 blocks, some GPUs do tiled rendering. But still, on the high level the workflow stayed about the same since shaders arrived in Direct3D 8 in 2001 with GeForce 3.
The only major disruption so far is UE5 which uses compute shaders for nanite meshes, instead of the hardware rasterizer.
https://smile.amazon.com/Real-Time-Rendering-Fourth-Tomas-Ak...
While this particular thread is about the GPU, there is indeed "something different" about the M1 otherwise too. It is quite the non-standard SoC: unlike basically everything else (other than early Broadcom RPi crap) it even uses a custom Apple interrupt controller instead of the ARM GICv2/3. Also a custom IOMMU "DART" and a bunch of other peripherals. Very unusual: NVMe exposed as a plain hardcoded MMIO device (not enumerated over PCIe).
For external graphics support we would at a minimum need an open source thunderbolt driver to expose the PCIe lanes to an external GPU and then we would need to recompile the open source GPU drivers against the Apple Silicon or ARM64 machine targets. The good news there is that the AMD open source driver is very performant, the bad news is that it’ll require machine specific patches as I believe it has some low level assembly in it.
I’m sure we’ll get there with time, especially with so many smart people working toward Linux on Apple Silicon chips.
https://www.phoronix.com/scan.php?page=news_item&px=Asahi-Li...
edit: Ah, I think the original was "If you wish to make an apple pie from scratch"
Also: this is on hardware without any public information available that has to be reverse engineered from scratch, this is the actually incredible part.
“It was sometime in my first week possibly my first or second day. In the main engineering room, there was a whoop and cry of success.
Our company financial controller and acting HR lady, Jen, came in to see what incredible things the engineers and artists had come up with. Everyone was staring at a television set hooked up to a development box for the Sony Playstation. There, on the screen, against a single-color background, was a black triangle.
“It’s a black triangle,” she said in an amused but sarcastic voice. One of the engine programmers tried to explain, but she shook her head and went back to her office. I could almost hear her thoughts… “We’ve got ten months to deliver two games to Sony, and they are cheering over a black triangle? THAT took them nearly a month to develop?”
What she later came to realize (and explain to others) was that the black triangle was a pioneer. It wasn’t just that we’d managed to get a triangle onto the screen. That could be done in about a day. It was the journey the triangle had taken to get up on the screen. It had passed through our new modeling tools, through two different intermediate converter programs, had been loaded up as a complete database, and been rendered through a fairly complex scene hierarchy, fully textured and lit (though there were no lights, so the triangle came out looking black). The black triangle demonstrated that the foundation was finally complete the core of a fairly complex system was completed, and we were now ready to put it to work doing cool stuff. By the end of the day, we had complete models on the screen, manipulating them with the controllers. Within a week, we had an environment to move the model through.
Afterwards, we came to refer to certain types of accomplishments as “black triangles.” These are important accomplishments that take a lot of effort to achieve, but upon completion you don’t have much to show for it only that more work can now proceed. It takes someone who really knows the guts of what you are doing to appreciate a black triangle.”
This is similar, but slightly different. There isn’t months of work on writing tools to render scenes using Sony’s documentation to figure out how to render stuff, but months of work on figuring out what Apple’s internal documentation says about rendering a triangle.
Did they reverse engineer something?
Additionally Apple intentionally designed the M1 architecture to support additional OSes. They have even made changes to their code that have fixed issues the Asahi project was having. So while there's no official support this project is certainly known to Apple and has raised no concerns so far.
How can you say that? Where is the documentation for M1 that can be used to implement support for other OSes?
If you're looking for specific hardware documentation it doesn't really exist per se but the xnu kernel is open source, so if you want to look a lot of the basic architecture is out there I'm pretty sure.
That said, afaik asahi is avoiding looking at the xnu source and is mostly using their own m1n1 bootloader/hypervisor to run macos under and monitor hardware interaction and deriving their drivers from that.
(m1n1 is honestly some incredible work and I actually used it to get a non-Linux, non-macos os to boot to serial console a few weeks ago, it was fun)
Didn't you just say no proprietary code is used?
I'm confused.
[...] they *also* added a raw image mode that will never break again and doesn't require Mach-Os. And people said they wouldn't help. This is intended for us.
HN discussion about this tweet: https://news.ycombinator.com/item?id=29591578
Some people make a big deal out of reverse-engineering blobs through disassembly particularly for certain discrete components (e.g DSP or GPUs) but a) writing a set of clean-room specifications not containing any copyrighted information to use as a reference is a known task and often considered legal and b) m1n1 makes it in some cases easier to understand how the hardware is being used versus manual disassembly of blobs or drivers.