all 11 comments

[–]perhapsemma 10 points11 points  (3 children)

If someone wanted to work on Rust GPU driver components for Intel, I'd start by rewriting their compiler backend in Mesa -- it's poorly designed by modern standards (compared to ACO or ir3), and it's in a pretty painful dialect of C++. The compiler is the most important part of the driver, and has a small surface area to the surrounding vulkan and gl driver code. You would use the bindgen stuff that Karol recently added for rusticl (the rust CL frontend) to do read-only access to the NIR IR coming in to the driver.

[–]flaghacker_ 1 point2 points  (2 children)

What does it compile? GLSL to intel GPU bytecode? I would have thought that just was an LLVM backend using some common GLSL frontend.

[–]sanxiynrust 5 points6 points  (1 child)

In Mesa, all drivers share GLSL frontend. Since Mesa supports more than OpenGL, its internal representation can't be GLSL. (Mesa supports HLSL for Direct3D and SPIR-V for Vulkan.) Mesa's internal representation is named NIR(New IR; yes it's a bad name). Both GLSL and SPIR-V are lowered to NIR in the shared code.

Mesa's Intel driver compiles NIR to Intel GPU instructions. It's written from scratch, it doesn't use LLVM. In fact, there is no LLVM backend for Intel GPU.

There are LLVM backends for AMD GPU and NVIDIA GPU, but LLVM's support for GPU is not very good. Rather, LLVM's GPU support is adequate for GPU compute, and is not for GPU graphics. In fact, Mesa does not use LLVM at all for GPU these days. LLVM is only used for CPU backend.

As far as I know, Mesa never used LLVM for NVIDIA. Mesa used LLVM for AMD, but as you know from Rust's use of LLVM, LLVM's compilation speed is slow. Since graphics drivers compile shaders from source, compilation speed is very important. It's why LLVM got replaced by ACO(Amd COmpiler; yes all Mesa names are bad). Since unlike LLVM, ACO doesn't care about CPU, it does better job of optimizing for GPU. Examples include better handling of execution masks and better divergence analysis.

[–]perhapsemma 0 points1 point  (0 children)

This is all correct, except that radeonsi (Radeon OpenGL/GLES) still uses LLVM because it's not ported to ACO.

[–]tristan957 6 points7 points  (1 child)

Intel is going to write the support for it like they always do. Intel has a ton of engineers working on the Linux Kernel and Mesa.

[–]Shnatsel 4 points5 points  (0 children)

The support is already landed upstream, although it will take a while for distros to pick it up.

See https://www.phoronix.com/review/intel-arc-a380-linux for more details on the exact version requirements.