I will give an update on two topics involving shaders in radeonsi, the OpenGL driver for modern Radeon GPUs: the dynamic linking of shader parts, and the transition to the NIR intermediate representation.
Managing shader compilation in an OpenGL driver is challenging, because the final shader binary may depend not only on the shader source, but also on other state in the OpenGL pipeline such as framebuffer state, blending, and vertex array. When a shader is used in a new pipeline configuration, the driver may have to recompile it. This could cause noticeable stalls in some games. While on-disk shader caches can alleviate the problem somewhat, they cannot cover all cases. The approach taken by radeonsi is to split shaders into multiple parts, such as a prolog, a main part, and an epilog. In many cases, the effects of changing OpenGL states can be captured by only recompiling the prolog and epilog, which is sufficiently faster to virtually eliminate stalls.
The .text segments of these shader parts, which the driver originally gets in ELF format from the LLVM backend, are simply pasted together. This means that we cannot currently use most of the features of ELF which are taken for granted in the CPU world. Most interesting to us would be: putting large constant data into a .rodata segment, and representing LDS memory (a fast on-chip memory) as a proper ELF data segment. I will present a plan to introduce a proper ELF-based dynamic linking step into the driver to enable these features.
I also plan to present a brief update on the transition from TGSI to NIR as intermediate representation.
Speakers: Nicolai Hähnle