nouveau,nvk: Add a new back-end compiler for NVIDIA hardware
What does this MR do and why?
This adds the new back-end compiler for NVK that I've been cooking for about 6 months now. It's written in Rust, SSA all the way through, and designed assuming competent NIR input. The long-term plan is that this will be the compiler for NVK. We're a ways from that goal but far enough along that I feel pretty okay posting it as a draft MR. We may use it for GL one day but there's a decent chance that'll just be Zink.
What works?
Compute shaders on Turing. Everything else is a bit sketchy still.
Right now, it passes most of the CTS when enabled for compute shaders. There's still a few fails which I need to investigate but it's pretty close to parity with codegen. There are also quite a few tests which pass on NAK that don't pass with codegen because NAK has a better register allocator.
What doesn't work?
- We're missing atomic cmpxchg on images but @dwlsalmeida is working on that. (It's currently the only source of panics)
- Non-Turing hardware support
- Dependency tracking. I have a pass for it but it's currently bogus. I don't know why it's bogus, just that it is. You need to run with
NAK_DEBUG=serial
or all sorts of random stuff fails. - Anything related to 3D is sketchy as heck. It kinda works but the headers are all messed up. I've got a plan and I think @marysaka is going to make it happen once her Turing card shows up. Or maybe I will. In any case, I'm not too worried about it. All that stuff is easy on NVIDIA.
- Misc. control-flow stuff required to guarantee re-convergence.
- 16 and 64-bit support. Everything other than 64-bit iadd is getting lowered right now.
Importantly, though, the bones are good. Spilling and RA seems rock-solid, even forcing everything down to 18 registers. The SSA plan seems to be working out quite well. I'm happy with the way I'm representing instructions and the way things map to Rust in general. There's a lot of work yet to do but I'm well past the "Is this a good idea?" stage and on to the "Let's make it all happen".
A note about Rust and Meson
NAK depends on four crates: syn, proc-macro2, quote, and unicode-ident. They're pretty much required for proc macros which NAK depends on pretty heavily. Currently, I've got each of those crates cloned into a branch on my GitHub (thanks @dbaker) and I'm pulling them in as wraps. @xclaesse has a couple of Meson PRs which will enable us to drop this and pull them in through Meson's subproject mechanism:
I already have a patch (currently living in my nak/meson-crates branch) which switches everything to use this mechanism. I'm really hoping that goes in before we need to land this MR. If we have to pull from my GitHub for a little while, we can, but letting Meson handle crates is a better long-term plan by far.