gallium: Add a nir-to-TGSI pass

Graphics / Mesa 3D Graphics Library / Mesa - Eric Anholt [] - 20 October 2020 15:54 UTC

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. Some potentially relevant changes to TGSI consumers:

- All immediates are now UINT typed. This means they're less legible in printouts, but means that they get deduplicated better (no more multiple copies of 0x0!)
- Sampler views are not currently declared.- nir_registers don't have their live ranges tracked, so TGSI temp usage may go up with a lot of control flow.- nir_lower_vec_to_mov naively inserts movs instead of trying to coalesce the movs with the generators of the ssa values, sometimes increasing instruction count.

34cc6a804ec gallium: Add a nir-to-TGSI pass.
src/gallium/auxiliary/Makefile.sources | 1 +
src/gallium/auxiliary/ | 2 +
src/gallium/auxiliary/nir/nir_to_tgsi.c | 2647 +++++++++++++++++++++++++++++++
src/gallium/auxiliary/nir/nir_to_tgsi.h | 33 +
4 files changed, 2683 insertions(+)


  • Share