NIR-To-TGSI Support Added To Mesa 20.3
Mesa 20.3 has merged a long work-in-progress patch series providing support for going from the modern NIR intermediate representation to TGSI as the conventional Gallium3D IR.
The NIR-To-TGSI translation layer has been in the works for most of the year with hopes of using that to eventually kill the Mesa state tracker GLSL-to-TGSI code that is quite large and crusty. While RadeonSI, Iris, and the other larger Gallium3D drivers are making use of NIR for a while now, this NIR-to-TGSI path can help other Gallium3D drivers like Softpipe that still rely on TGSI. If getting rid of the GLSL-to-TGSI path, GLSL shaders would ultimately go through NIR and then translated to TGSI.
This can allow for better optimizations and ultimately better performance. This translation layer allows these other Gallium3D drivers to make use of NIR optimizations and all the attention it receives these days where as the TGSI-specific work is largely untouched.
Eric Anholt of Google who has been working on this support commented of the immediate benefits for TGSI-based Gallium3D drivers, "I've seen it reduce instruction count massively in compute, geometry, and UBO-loading shaders, but even a bit in trivial texturing shaders like glmark2!"
This patch also goes on to explain, "The goal is to replace glsl_to_tgsi.cpp and its supporting code (~10k LOC). This code ends up being smaller because NIR has many lowering passes that help it map better to TGSI than GLSL IR does. As a benefit, this brings NIR optimizations to TGSI-only drivers. Many of the softpipe shaders I've looked at end up being significantly shorter."
Mesa 20.3 remains under active development and should be out as stable in early December.