Bringing Jay to Intel GFX12

Over the past year, I've become really interested in Mesa. Seeing ACO's success, Valve's investment in Linux gaming, and all the Proton stuff made me want to take a closer look.

I already had some background in graphics and low-level programming, especially embedded operating systems, so it was a pretty natural rabbit hole to fall into. I was really curious about what was going on under the hood.

I remember working on my own game engine and renderer and trying to understand GPUs and how graphics APIs actually work. I just couldn't treat OpenGL or Vulkan as black boxes. That... literally bothered me :D

I really like the handmade kind of stuff Casey and Ryan do: building things from scratch, understanding the hardware, and figuring out where the performance comes from. I wanted to do that myself too, and a few years later I somehow ended up working on Mesa :D.

Now I'm much closer to GPUs, and I'm really happy about that. Learning new things about graphics systems is still amazing to me. I love how learning one thing immediately opens up a dozen things I didn't even know I had to learn. It's like discovering a whole new side of the mountain :D. I've also been poking around the DRM side lately.

Finding Jay

I started with ACO. I even made an ACO dump project :D. But I didn't have an AMD GPU, so after a while I decided to give my own hardware a chance. My laptop has an Intel Raptor Lake GPU and an NVIDIA RTX 40-series GPU, and ofc I picked Intel... becauuuseee it's much less of a black box. You have ISA documentation, presentations, and developers you can actually email with questions :P

When I first tried to get into BRW/ANV (well, tried :D), I came across Jay, a newer project mostly developed by Alyssa Rosenzweig and Kenneth Graunke. A newer compiler probably has moooar room for contributions than a mature driver or compiler, right? Turns out I wasn't wrong :)

I started reading Jay's code, looking through the important files and trying to get a feel for the architecture. At the same time, I was learning the Gfx12 ISA and execution model from Intel's documentation.

Why Jay is interesting

Jay caught my attention because it's an SSA-based shader compiler with some newer (and imo better) approaches to register allocation. I wanted to understand how it worked, so I read the papers behind it and dug into the algorithms, Jay's IR, and how it represents programs in memory.

First, it uses a spiller based on Braun & Hack's work on spilling and live-range splitting to decide which values need to be spilled to memory. Then it uses a tree-scan register allocator based on Colombet et al. to... allocate the registers, ofc :D. The spiller also draws on Braun et al.'s "Simple and Efficient Construction of Static Single Assignment Form" to keep things in SSA as spilling introduces new definitions. So even though NIR already comes in SSA, there's still work to do here :D

Jay uses a simpler per-lane SSA model and partitions the physical register file by stride before assigning values to it. That way, most of the compiler can work without directly dealing with all of Intel's regioning rules.

BRW isn't SSA-based, and it supports a lot of different architectures. Over time it grew... A LOT :D. For me, that makes it harder to follow, add features to, and debug. But NIR is SSA, so why leave that behind? Turns out the FS backend goes back to 2010, while NIR arrived in 2014. They have separate IRs, so NIR being SSA doesn't mean BRW has to be. Still, that doesn't explain why BRW wasn't SSA-based in the first place. The papers already existed back then... what were the tradeoffs? idk, I'd like to understand that part too.

On 28 September 2026, Alyssa presented Jay at XDC 2026 (slides, video). A few days before the presentation, Jay became the default compiler for Xe2 and Xe3 hardware on Intel. Huge success btw (MR). I hope we can get Gfx12 there too :)

Alyssa's XDC results also report 98% less spilling than BRW on a collection of game shaders. Pretty exciting :D (those are her results; I haven't benchmarked my Gfx12 branch against BRW yet).

Getting involved

As I said, Jay really caught my interest. My first contribution was actually a small memory-leak fix. I ran into it while experimenting with debug builds and sanitizers :D. A shader allocation simply wasn't using the memctx it was supposed to use. Finding new bugs or places to contribute is a lot harder when you don't have the hardware, though.

I was kinda sad about that, and even decided to buy a new Xe3 laptop to work on Jay. I love GPUs, graphics, compilers, and low-level performance work, and helping the Linux graphics ecosystem grow made it even more appealing :). That purchase keeps getting pushed back, but it actually worked out pretty well: I ended up finding moooar interesting things to do in Jay with the hardware I already had :))

Since I'd already contributed to Mesa and Jay/BRW, I decided to say hi to Alyssa. I wanted to ask whether there was any unowned work I could take on, both to learn more about Jay and hopefully take some work off the other developers' plates. I also mentioned my plan to buy a new laptop for development.

And then came the funny part: I had an older Intel iGPU. A few people were already working on Xe2+, but bringing Jay to older hardware, all the way back to Skylake, was also a goal. I guess I showed up at a good time :))

Since I had a Gfx12 laptop, she shared a branch she'd been working on in her free time for Gfx12.5. I took that branch and started bringing up Gfx12 on top of it. foreshadowing... it went well, and it's still going well :)) An earlier CTS run had 4,534 passed tests; the FS8 run now reaches 6,547 (I didn't record the older run's SIMD setting, so this isn't an exact before/after comparison).

I've mostly tested FS8 and FS16 so far. A lot of these fixes are in shared compiler code, so they should also help VS, but I still need to actually test that :D. FS32 needs more work and testing too... we have a long way to go :)

Code: my Gfx12 branch.

Thanks to Alyssa Rosenzweig for sharing her work-in-progress branch, reviewing the patches, and helping me find a useful starting point.

My working style

I started with vkcube and fixed the accumulator issues until it finally rendered in FS8. Then I moved on to CTS. An early run got stuck at test #6,418 (divbyzero_frag). After a few patches, the latest FS8 run reached 6,547 passed tests out of 28,399. There were also 1,901 NotSupported results before test #8,449 (helper_invocation.load_after_store) crashed. That leaves 19,950 tests unrun. Only FS uses Jay in this setup; the other stages still use BRW.

My usual loop is to hit a CTS failure and figure out what happened. If it's a compiler assertion, I run the failing test under GDB, get a backtrace, jump into the Jay frame, and print the NIR intrinsic name to see which path isn't handled yet. If it's a misrender or miscompile instead, I compare the output and generated ISA.

Then I check how BRW handles that intrinsic and find the corresponding place in Jay. Sometimes the fix touches more than the code around the assertion (see my partition patch). Once I understand what BRW prepares and what Jay already handles, the actual patch can be almost trivial thanks to Jay's abstractions :). Then I rerun the failing test, related tests, and the relevant SIMD widths to make sure I haven't broken something else.

What's next?

I'll update this when I hit another milestone, or maybe when there's a patch worth writing about... no promises :D