Mesa Drivers' Use Of Multiple IRs, Gallium3D With NIR

Written by Michael Larabel in Mesa on 27 August 2017 at 05:20 PM EDT. 1 Comment
MESA
Following the news this week that RadeonSI may switch to NIR completely in the future, in the forums a number of questions were raised about why the Linux graphics drivers are using multiple forms of intermediate representation and whether this would still make RadeonSI a Gallium3D driver if it doesn't default to TGSI.

Freedreno lead developer Rob Clark sought to clarify these misconceptions today in a blog post. In regards to RadeonSI and other graphics drivers making use of multiple forms of intermediate representation (IR; e.g. TGSI, NIR, then LLVM IR, and then the actual GPU instructions), it's because each IR has in effect its own specialty for what it can be best done for optimization/lowering passes at that stage, etc. The cost of translating from one IR to another is relatively tiny in the grand scheme and the drivers aren't redundantly running the same optimization passes with each form of intermediate representation.

In Rob's profiling of the Freedreno behavior with OpenGL, about 10% of the time was spent parsing into OpenGL while going from GLSL to NIR was just 1.3% and going from NIR to the IR3 hardware instructions were just 1.5%. The actual optimization passes for each IR were taking about 21%. In Freedreno's case, the NIR passes do some algebraic optimizations, common subexpression elimination, dead code elimination, and other optimizations. Most of the IR3 passes come down to scheduling, register allocation, and other near-final optimizations.

He also explains how even if drivers are using an alternative IR like NIR rather than TGSI, they are still Gallium3D drivers, and there are glsl-to-nir and tgsi-to-nir helpers.

More details can be found via Rob's blog.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week