9 ms·
First triangle ever rendered on an M1 Mac with a fully open-source driver
- kaetemi 4y agoNeat. Getting a triangle to render is 99% of the work to getting games running. Only the remaining 99% to go... :)
- pabs3 4y agoThey have been working through the other 99% of the work under macOS for a while now: https://rosenzweig.io/blog/asahi-gpu-part-5.html 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-4.html https://rosenzweig.io/blog/asahi-gpu-part-3.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-2.html https://rosenzweig.io/blog/asahi-gpu-part-1.html https://rosenzweig.io/blog/asahi-gpu-part-1.html
- kaetemi 4y agoInteresting read. Thanks for the links! Explains the hardware rationale for tiled renderers really well. 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.
- throw0101a 4y ago> The first 90 percent of the code accounts for the first 90 percent of the development time. The remaining 10 percent of the code accounts for the other 90 percent of the development time.[1][2] — Tom Cargill, Bell Labs * https://en.wikipedia.org/wiki/Ninety–ninety_rule https://en.wikipedia.org/wiki/Ninety–ninety_rule
- picture_view 4y agoFor the uninitiated, could someone explain why this is important? Is rendering triangles really that difficult?
- pabs3 4y agoThis is the first time that the Apple M1 GPU has been able to be used outside of macOS. The earlier work (links elsewhere in thread) was all under macOS. So this means that there has been some reverse engineering of the macOS kernel side of the proprietary macOS driver and we are one step closer to a Linux or BSD kernel driver, which the macOS open source userspace driver could be ported to.
- LeoPanthera 4y agoIt allows 3D acceleration on M1 Macs when running an OS other than macOS. Linux, specifically.
- pabs3 4y agoThe tweet doesn't refer to a Linux driver, but to a driver for the Asahi m1n1 bootloader thing: https://www.phoronix.com/scan.php?page=news_item&px=Asahi-Linux-First-Triangle https://www.phoronix.com/scan.php?page=news_item&px=Asahi-Li...
- viraptor 4y agoCurrently, yes. But that's just for development purposes. Nobody is expected to run m1n1 itself. One of the reasons for this development is to create a Linux driver doing the same.
- viraptor 4y agoIt's not difficult as such (I mean a triangle is not hard, but getting something out is), but it's the basic building block. If you can render a triangle, you can render it lots of times and create any scene. (simplifying a bit, but still...)
- None4U 4y agoAll the models in 3D games are made up of triangles rendered on the GPU. This is the first time even one triangle has been rendered on an Apple M1 GPU without the macOS kernel driver, using fully reverse engineered open source code.
- samwestdev 4y agoThis is extremely fascinating. I can’t even fathom how people can create open source for closed hardware. Any resource to learn the process?
- pabs3 4y agoSee the blog posts linked above, especially the earliest one.
- dottedmag 4y agoHere's the main channel (everything but GPU) of reverse-engineering and writing open drivers for M1: https://www.youtube.com/c/marcan42/videos https://www.youtube.com/c/marcan42/videos
- frankjr 4y agoThere's also this other channel where the GPU work is happening. The author is the same. https://www.youtube.com/c/AsahiLina/videos https://www.youtube.com/c/AsahiLina/videos
- spyremeown 4y agoWait, I don't think that's Marcan, right?
- jokoon 4y agoI imagine they will receive a cease and desist? Did they reverse engineer something?
- stirlo 4y agoThis is a clean room open source implementation. Not property blobs are used. 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.
- ankurdhama 4y ago> Additionally Apple intentionally designed the M1 architecture to support additional OSes How can you say that? Where is the documentation for M1 that can be used to implement support for other OSes?
- stormbrew 4y agoSee the section "Permissive Security Policy" at https://support.apple.com/en-ca/guide/security/sec7d92dc49f/web https://support.apple.com/en-ca/guide/security/sec7d92dc49f/... 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)
- allenrb 4y agoNow that’s an interesting teaser! Care to share more, even if it was just a personal project?
- danmur 4y agoSurprised there's not an NFT of it :P
- danmur 4y agoYesss, let the hate flow through you!
- mcintyre1994 4y agoIs it normal that the first time you manage to render a triangle it has what looks like a pretty complex gradient colour? I’d have expected rendering a solid colour or without fill to be easier and to happen first, but that’s just a completely uninformed guess. Or is this person just way ahead of anyone else working on the same thing, and they would have had it working without that colour at some earlier point but didn’t show it off until now?
- kreddor 4y agoI think that's just how the hardware does it when you assign a different color to each vertex.
- flohofwoe 4y agoSince the color interpolation is done by the hardware from per-vertex attributes it's not any additional effort compared to a solid-color triangle (from a coder's point of view at least). 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.
- mcintyre1994 4y agoAh that hardware interpolation is what I wasn’t aware of, thanks! :)
- captainmuon 4y agoDoes modern hardware still have this "default" behavior? I could imagine you would have to write a (basic) shader to get any kind of output, whereas back in the day the 3D accelerator knew how to do Phong shading etc. in hardware.
- flohofwoe 4y agoYou need a vertex- and pixel-shader, but AFAIK even on modern GPUs the vertex attribute interpolation happens as fixed-function feature between the vertex- and pixel-stage (e.g. the vertex shader runs per vertex and outputs different colors for each vertex, and the pixel shader runs per pixel and gets the hardware-interpolated per-pixel color as input).
- xbar 4y agoThank you Alyssa Rosenzweig for your hard work to get us here.
- deleted 4y ago[deleted]
- substation13 4y agoThis is incredible work. An M1 Macbook running Linux would be a dream setup for me.
- solarkraft 4y agoThey already run Linux. Wifi works. It's already quite usable, I'm just too happy with macOS to bother with it.
- deleted 4y ago[deleted]
- mooktakim 4y agoHmm, I thought Linux already supported ARM architecture. Is there something different about M1? Is it not like other ARM?
- lathiat 4y agoYou are right but this is about the Apple GPU (Graphics) embedded in the M1 rather than the CPU. There is no existing driver for this Apple GPU (for doing "accelerated" 2D/3D graphics)
- floatboth 4y agoThere's more to a computer than just the CPU ISA. 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).
- lamontcg 4y agoCould this ultimately wind up producing eGPU support for the M1?
- warricksothr 4y agoNope, this would be the open source driver for a the GPU inside the M1 chip, which has to be reverse engineered. But it’s great news for anyone hoping for Vulkan support on M1 based GPU cores! 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.