Mesa Prepares To Drop Old GLSL-To-TGSI - Big Code Removal, Win For Performance & Fixes
Anholt since the end of 2020 has been working to move the older/smaller drivers off their TGSI dependence and getting NIR support plumbed in by way of the NIR-to-TGSI path. From this long ongoing work Mesa has moved Virgl to NIR, GeForce FX / 6 / 7 series on Nouveau now using NIR-to-TGSI as of Mesa 22.1, Radeon R300g using this path too since last year, and the old Intel i915g driver also takes this route. With these driver changes and other Mesa work that has been mainlined over the past year, going the GLSL-to-TGSI route is being made redundant and can be eliminated. NIR is the modern intermediate representation used by the newer open-source Mesa drivers and has much better optimization potential, better designed for modern graphics needs, and all around is of better code quality and capabilities these days than TGSI that started out as the original Gallium3D IR for Mesa.
This removal is a win for Mesa developers with more than 20k lines of code removed to lower the maintenance burden, particularly for this neglected area of the massive code-base.
This merge request replaces the glsl_to_tgsi() function with using glsl_to_nir() and nir_to_tgsi(). So those drivers not natively supporting the NIR intermediate representation will go from the OpenGL Shading Language (GLSL) to NIR and back to TGSI for driver consumption. Just a few changes are still pending first around Virgl, R600g, Nouveau, and a few regression fixes before that merge can land.
Those with older GPUs can also celebrate since this effort to go through NIR means the possibility of better performance, fixes, and better tested code in general.
Emma Anholt noted on the mailing list for the benefits of passing the finish line beyond just the performance potential, "We're down to very few test regressions in the remaining drivers, and landing it nets us test fixes and performance wins while removing 22,000 lines of unmaintained, non-CI-tested code."
So assuming no last minute hurdles appear, the hope is to complete this work soon and thus should be a nice clean-up for the Mesa 22.2 release next quarter.