[Mesa-dev] [PATCH 0/5] NIR vectorization

Connor Abbott cwabbott0 at gmail.com
Sat Nov 14 18:59:39 PST 2015


This series adds an optimization to detect things like:

foo.x = bar.x + baz.x;
foo.y = bar.y + baz.y;
foo.z = bar.z + baz.z;
foo.w = bar.w + baz.w;

and turn them into:

foo = bar + baz;

which shows up distressingly often in shaders translated from D3D
bytecode, or by people who seemingly don't know that GLSL can do all
that vector-y stuff for you. There is a similar pass in GLSL IR, but it
can only handle operations on uniforms/inputs since it would've been too
difficult to handle more complicated cases. But now that we have NIR,
and the i965 vec4 backend uses NIR, we can write a much better pass
using the magic of SSA. Shader-db results are in the last patch.

Series is also available as the 'nir-vectorize' branch of my FDO repository.

Connor Abbott (5):
  util/set: don't compare against deleted entries
  util/hash_table: don't compare deleted entries
  nir/array: add a few more helpers
  nir: add a vectorization pass
  i965/nir: use vectorization for non-scalar stages

 src/glsl/Makefile.sources           |   1 +
 src/glsl/nir/nir.h                  |   2 +
 src/glsl/nir/nir_array.h            |  21 ++
 src/glsl/nir/nir_opt_vectorize.c    | 447 ++++++++++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_nir.c |   8 +
 src/util/hash_table.c               |   3 +-
 src/util/set.c                      |   3 +-
 7 files changed, 483 insertions(+), 2 deletions(-)
 create mode 100644 src/glsl/nir/nir_opt_vectorize.c

-- 
2.4.3



More information about the mesa-dev mailing list