[Mesa-dev] [PATCH 00/16] gallium: add support for NIR as alternate IR

Rob Clark robdclark at gmail.com
Tue Apr 5 19:57:23 UTC 2016


On Tue, Apr 5, 2016 at 3:25 PM, Marek Olšák <maraeo at gmail.com> wrote:
> Hi Rob,
>
> I have 2 questions.
>
> 1) Do you have any data about performance of shader compilation between:
>
> GLSL -> TGSI -> driver IR -> bytecode
> -and-
> GLSL -> NIR -> driver IR -> bytecode
>

I can't compare this directly, since for me it is either
glsl->tgsi->nir->driver or glsl->nir->driver..  I dropped the ir3 tgsi
f/e a while back.  But from memory, NIR does have better constant
folding, for example.

There are some cases, like matrix column access, where by skipping
tgsi I should be able to do a bit better (ie. not do if/else ladder),
although I don't do this yet.  (driver_location is still in units of
vec4, which is a bit of a legacy of tgsi->nir..)

I should mention, that part of my goal for this is to avoid having to
plumb half-precision support through TGSI.. and for gles apps,
half/mediump can be a big win, at least on mobile hw.

Also, not loosing the input/output/uniform names in the
glsl->nir->driver path is nice for debugging ;-)

I do need to make some more formal measurements of shader compile
time, but "seat of the pants" it feels faster.

> 2) What's the quality of the driver IR when it comes out of NIR? Is it
> optimized well?

Most of the silly/suboptimal things in resulting shader binary are ir3
issues, not NIR issues.  (And I patches I pushed yesterday and today
fix the worst of those.)

I did notice the other day that NIR is missing out on some algebraic
opts in some cases, like loop unrolling that results in foo = ((bar +
1) + 1) + 1) doesn't become foo = bar + 3..  Jason did say he had some
patches for that somewhere.

BR,
-R

> Thanks,
> Marek
>
>
> On Sat, Mar 26, 2016 at 10:02 PM, Rob Clark <robdclark at gmail.com> wrote:
>> From: Rob Clark <robclark at freedesktop.org>
>>
>> Ok, hopefully (close to the) last iteration of this patchset.  Quite a
>> lot of it has r-b's by now.  There a few new nir bits (in particular,
>> the "lower-io-types" pass and some updates to the "lower-outputs-to-
>> temporaries" pass.  Some of that will have some conflicts with stuff
>> that Jason has in-flight.. I can either rebase on top of his patchset
>> or rebase his patchset on top of mine, depending on what lands first.
>>
>> There is also a new mesa/st pass to lower builtin uniforms, to address
>> issues that I mentioned with the previous round of patches (ie. built-
>> ins getting packed differently from normal struct uniforms).
>>
>> There is also a new nir_lower_io_types pass that splits up complex
>> inputs/outputs to vec4 slots so that we can deal with galliums VBO
>> slot assignment (ie. it will already only assign VBO space to VS
>> varyings which are actually read).
>>
>> Btw, I wouldn't mind starting to push at least parts of this patchset
>> which have r-b's and don't depend on other parts that don't have r-b.
>> But I've held off for now to avoid having a bunch of nir passes that
>> aren't used upstream.
>>
>> Rob Clark (16):
>>   gallium: refactor pipe_shader_state to support multiple IR's
>>   gallium: add NIR as a possible IR
>>   nir: add lowering pass for y-transform
>>   nir: add lowering pass for glDrawPixels
>>   nir: add lowering pass for glBitmap
>>   nir: clamp-color-output support
>>   nir: passthrough-edgeflags support
>>   nir: lower-io-types pass
>>   nir: move callsite of lower_outputs_to_temporaries
>>   nir: rename lower_outputs_to_temporaries -> lower_io_to_temporaries
>>   nir/lower-io: split out some helper fxns
>>   nir/lower-io: add support for lowering inputs
>>   glsl: export accessor for builtin-uniform descriptors
>>   mesa/st: split the type_size calculation into it's own file
>>   mesa/st: add nir pass for lowering builtin uniforms
>>   mesa/st: add support for NIR as possible driver IR
>>
>>  src/compiler/Makefile.sources                      |   8 +-
>>  src/compiler/glsl/builtin_variables.cpp            |  24 +-
>>  src/compiler/glsl/ir.h                             |   3 +
>>  src/compiler/nir/glsl_to_nir.cpp                   |   2 -
>>  src/compiler/nir/nir.h                             |  40 +-
>>  src/compiler/nir/nir_builder.h                     |   2 +-
>>  src/compiler/nir/nir_lower_bitmap.c                | 166 ++++++++
>>  src/compiler/nir/nir_lower_clamp_color_outputs.c   | 117 ++++++
>>  src/compiler/nir/nir_lower_drawpixels.c            | 252 ++++++++++++
>>  src/compiler/nir/nir_lower_io_to_temporaries.c     | 185 +++++++++
>>  src/compiler/nir/nir_lower_io_types.c              | 178 +++++++++
>>  .../nir/nir_lower_outputs_to_temporaries.c         | 133 -------
>>  src/compiler/nir/nir_lower_passthrough_edgeflags.c |  82 ++++
>>  src/compiler/nir/nir_lower_wpos_ytransform.c       | 310 +++++++++++++++
>>  src/gallium/auxiliary/hud/hud_context.c            |   9 +-
>>  src/gallium/auxiliary/postprocess/pp_run.c         |   3 +-
>>  src/gallium/auxiliary/tgsi/tgsi_ureg.c             |   4 +-
>>  src/gallium/auxiliary/util/u_simple_shaders.c      |  18 +-
>>  src/gallium/auxiliary/util/u_tests.c               |   3 +-
>>  .../drivers/freedreno/ir3/ir3_compiler_nir.c       |   8 +
>>  src/gallium/include/pipe/p_defines.h               |  13 +-
>>  src/gallium/include/pipe/p_screen.h                |   9 +
>>  src/gallium/include/pipe/p_state.h                 |  32 +-
>>  src/mesa/Makefile.sources                          |   5 +
>>  src/mesa/drivers/dri/i965/brw_nir.c                |   1 +
>>  src/mesa/state_tracker/st_glsl_to_nir.cpp          | 425 +++++++++++++++++++++
>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp         | 104 ++---
>>  src/mesa/state_tracker/st_glsl_to_tgsi.h           |   5 +
>>  src/mesa/state_tracker/st_glsl_types.cpp           |  98 +++++
>>  src/mesa/state_tracker/st_glsl_types.h             |  44 +++
>>  src/mesa/state_tracker/st_nir.h                    |  60 +++
>>  src/mesa/state_tracker/st_nir_lower_builtin.c      | 242 ++++++++++++
>>  src/mesa/state_tracker/st_program.c                | 148 ++++++-
>>  src/mesa/state_tracker/st_program.h                |   6 +
>>  34 files changed, 2487 insertions(+), 252 deletions(-)
>>  create mode 100644 src/compiler/nir/nir_lower_bitmap.c
>>  create mode 100644 src/compiler/nir/nir_lower_clamp_color_outputs.c
>>  create mode 100644 src/compiler/nir/nir_lower_drawpixels.c
>>  create mode 100644 src/compiler/nir/nir_lower_io_to_temporaries.c
>>  create mode 100644 src/compiler/nir/nir_lower_io_types.c
>>  delete mode 100644 src/compiler/nir/nir_lower_outputs_to_temporaries.c
>>  create mode 100644 src/compiler/nir/nir_lower_passthrough_edgeflags.c
>>  create mode 100644 src/compiler/nir/nir_lower_wpos_ytransform.c
>>  create mode 100644 src/mesa/state_tracker/st_glsl_to_nir.cpp
>>  create mode 100644 src/mesa/state_tracker/st_glsl_types.cpp
>>  create mode 100644 src/mesa/state_tracker/st_glsl_types.h
>>  create mode 100644 src/mesa/state_tracker/st_nir.h
>>  create mode 100644 src/mesa/state_tracker/st_nir_lower_builtin.c
>>
>> --
>> 2.5.5
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list