<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 5, 2015 at 11:28 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Patches 100, 102-104, 106-109, 114-117, 121-146 are:<div><br></div><div>Reviewed-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></div></div></blockquote><div><br></div><div>Noted.  I'm working on dealing with comments now.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Whew! I think I've looked through everything.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">NIR (pronounced "ner") is a new IR (internal representation) for the Mesa<br>
shader compiler that will sit between the old IR (GLSL IR) and back-end<br>
compilers.  The primary purpose of NIR is to be more efficient for doing<br>
optimizations and generate better code for the back-ends.  We have a lot of<br>
optimizations implemented in GLSL IR right now.  However, they still<br>
generate fairly bad code primarily because its tree-based structure makes<br>
writing good optimizations difficult.  For this reason, we have implemented<br>
a lot of optimizations in the i965 back-end compilers just to fix up the<br>
code we get from GLSL IR.  The "proper fix" to this is to implement a<br>
better high-level IR; enter NIR.<br>
<br>
Most of the initial work on NIR including setting up common data<br>
structures, helper methods, and a few basic passes was by Connor Abbot who<br>
interned with us over the summer.  Connor did a fantastic job, but there is<br>
still a lot left to be done.  I've spent the last two months trying to fill<br>
in the pieces that we need in order to get NIR off the ground.  At this<br>
point, we now have compitent in and out of SSA passes, are at zero piglit<br>
regressions for i965 SIMD8 fragment shaders, and the shader-db numbers<br>
aren't terrible.<br>
<br>
This is still a bit experimental.  I have been testing only on HSW but it<br>
should work ok on SNB and later.  Eventually, once we get booleans fixed<br>
up, it should work fine on older chips as well.  It also doesn't yet<br>
support SIMD16, so performance won't be that great.  That said, I think we<br>
are at the point now where we should try and land this and I can stop<br>
developing in my masive private branch.  Since this isn't quite ready for<br>
prime-time yet, using it requires setting the INTEL_USE_NIR environment<br>
variable.<br>
<br>
A few key points about NIR:<br>
<br>
 1. It is primarily an SSA-based IR.<br>
 2. It supports source/destination-modifiers and swizzles/*write-masks.<br>
 3. Standard GPU operations such as sin() and fmad() are first-class ALU<br>
    operations, not intrinsics.<br>
 4. GLSL concepts like inputs, outputs, uniforms, etc. are built into the<br>
    IR so we can do proper analysis on them.<br>
 5. Even though it's SSA, it still has a concept of registers and<br>
    write-masks in the core IR data structures.  This means we can generate<br>
    code that is much closer to what backends want.<br>
 6. Control flow is structured explicitly in the IR.<br>
<br>
(*write-masks are not available for SSA values)<br>
<br>
While source/destination modifiers and writemasks/swizzles are not<br>
particularly useful for optimizations, having them represented in the IR<br>
gives us the ability to generate more useful code for backends.<br>
<br>
A few notes about review:<br>
<br>
 1. For those of you who aren't interested in the general compiler, I'm<br>
    sorry for the patch-bomb.  However, several people have requsted that<br>
    we maintain the history of the NIR development since connor's original<br>
    drop at the end of the summer.  Therefore, while I've squashed several<br>
    things, I've tried to leave the diff of what I've done more-or-less<br>
    preserved.<br>
<br>
 2. No, this is not LLVM.  There was a long-winded discussion about that<br>
    when Connor dropped his patches that went a whole lot of nowhere as<br>
    usual.  I would really prefer if we left that debate alone.  If there<br>
    must be bikeshedding on the topic, please do so on the cover-letter<br>
    e-mail.<br>
<br>
 3. Please keep all bikeshedding about C++, typedefs, etc.  on the core<br>
    datastructures e-mail.  If we need, we can split that off in its own<br>
    thread.<br>
<br>
 4. While I welcome review, I don't plan to make non-trivial changes to<br>
    specific patches or squash anything beyond what has already been<br>
    squashed.  I've tried thus far to more-or-less keep the history and I'd<br>
    like to continue this if we can.<br>
<br>
 5. Eric Anholt has also written NIR -> TGSI -> NIR passes which will<br>
    hopefully get landed soon after NIR initially lands.  Exactly how that<br>
    all gets hooked up for other gallium drivers beyond vc4 is outside the<br>
    scope of this series.<br>
<br>
I have pushed a branch to my personal <a href="http://freedesktop.org" target="_blank">freedesktop.org</a> account.  For certain<br>
types of review, it may be easier to look at the end result rather than the<br>
patches.  The branch can be found via freedesktop cgit here:<br>
<br>
<a href="http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/nir-v1" target="_blank">http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/nir-v1</a><br>
<br>
Last week, I did a presentation for some of the other Intel people to try<br>
and help bring them up to speed on NIR concepts quickly.  As part of this,<br>
I typed up a bunch of notes that provide a decent overview of a lot of NIR<br>
concepts.  Those notes can be found here:<br>
<br>
<a href="http://www.jlekstrand.net/jason/projects/mesa/nir-notes/" target="_blank">http://www.jlekstrand.net/jason/projects/mesa/nir-notes/</a><br>
<br>
Happy reviewing!<br>
<br>
P.S. Connor, Don't do too much reviewing before your finals are done. :-P<br>
<br>
Connor Abbott (22):<br>
  exec_list: add a list_foreach_typed_reverse() macro<br>
  nir: add initial README<br>
  nir: add a simple C wrapper around glsl_types.h<br>
  nir: add the core datastructures<br>
  nir: add core helper functions<br>
  nir: add a printer<br>
  nir: add a validation pass<br>
  nir: add a glsl-to-nir pass<br>
  nir: add a pass to lower variables for scalar backends<br>
  nir: keep track of the number of input, output, and uniform slots<br>
  nir: add a pass to remove unused variables<br>
  nir: add a pass to lower sampler instructions<br>
  nir: add a pass to lower system value reads<br>
  nir: add a pass to lower atomics<br>
  nir: add an optimization to turn global registers into local registers<br>
  nir: calculate dominance information<br>
  nir: add a pass to convert to SSA<br>
  nir: add an SSA-based copy propagation pass<br>
  nir: add an SSA-based dead code elimination pass<br>
  i965/fs: make emit_fragcoord_interpolation() more general<br>
  i965/fs: Don't pass through the coordinate type<br>
  i965/fs: add a NIR frontend<br>
<br>
Jason Ekstrand (101):<br>
  i965/fs: Only use nir for 8-wide non-fast-clear shaders.<br>
  i965/fs_nir: Make the sampler register always unsigned<br>
  i965/fs_nir: Use the correct types for texture inputs<br>
  i965/fs_nir: Use the correct texture offset immediate<br>
  Fix what I think are a few NIR typos<br>
  Fix up varying pull constants<br>
  i965/fs_nir: Add support for sample_pos and sample_id<br>
  nir/glsl: Add support for saturate<br>
  nir: Add fine and coarse derivative opcodes<br>
  nir/glsl: Add support for coarse and fine derivatives<br>
  i965/fs_nir: Handle coarse/fine derivatives<br>
  nir/lower_atomics: Multiply array offsets by ATOMIC_COUNTER_SIZE<br>
  i965/fs_nir: Add atomic counters support<br>
  i965/fs: Allow reinterpretation in constant propagation<br>
  nir: Add NIR_TRUE and NIR_FALSE constants and use them for boolean<br>
    immediates<br>
  nir: Add intrinsics to do alternate interpolation on inputs<br>
  i965/fs: Don't take an ir_variable for emit_general_interpolation<br>
  i965/fs_nir: Don't duplicate emit_general_interpolation<br>
  nir: Add a naieve from-SSA pass<br>
  nir: Add a lower_vec_to_movs pass<br>
  i965/fs_nir: Convert the shader to/from SSA<br>
  nir/lower_variables_scalar: Silence a compiler warning<br>
  nir: Add a basic metadata management system<br>
  nir: Add an assert<br>
  nir/foreach_block: Return false if the callback on the last block<br>
    fails<br>
  nir: Add a foreach_block_reverse function<br>
  nir: Add a function to detect if a block is immediately followed by an<br>
    if<br>
  nir: Make the nir_index_* functions return the nuber of items<br>
  nir: Add an SSA-based liveness analysis pass.<br>
  nir: Add an initialization function for SSA definitions<br>
  nir: Automatically handle SSA uses when an instruction is inserted<br>
  nir: Add a function for rewriting all the uses of a SSA def<br>
  nir: Add a parallel copy instruction type<br>
  nir: Add a function for comparing two sources<br>
  nir: Add a better out-of-SSA pass<br>
  i965/fs_nir: Do retyping for ALU srouces in get_nir_alu_src<br>
  glsl/list: Fix the exec_list_validate function<br>
  nir: Validate all lists in the validator<br>
  nir/print: Don't reindex things<br>
  nir: Differentiate between signed and unsigned versions of find_msb<br>
  i965/fs_nir: Validate optimization passes<br>
  nir/nir: Fix a bug in move_successors<br>
  glsl/list: Add a foreach_list_typed_safe_reverse macro<br>
  nir/nir: Use safe iterators when iterating over the CFG<br>
  nir/nir: Patch up phi predecessors in move_successors<br>
  nir: Add a peephole select optimization<br>
  i965/fs_nir: Turn on the peephole select optimization<br>
  nir: Validate that the SSA def and register indices are unique<br>
  nir: Add a fused multiply-add peephole<br>
  nir: Add a basic CSE pass<br>
  i965/fs_nir: Add the CSE pass and actually run in a loop<br>
  i965/fs_nir: Use an array rather than a hash table for register lookup<br>
  i965/fs_nir: Handle SSA constants<br>
  i965/fs_nir: Properly saturate multiplies<br>
  nir: Add a helper for rewriting an instruction source<br>
  nir/lower_samplers: Use the nir_instr_rewrite_src function<br>
  nir: Clean up nir_deref helper functions<br>
  nir: Make array deref direct vs. indirect an enum<br>
  nir: Add a concept of a wildcard array dereference<br>
  nir: Use an integer index for specifying structure fields<br>
  nir: Don't require a function in ssa_def_init<br>
  nir/copy_propagate: Don't cause size mismatches on phi node sources<br>
  nir: Validate that the sources of a phi have the same size as the<br>
    destination<br>
  nir/glsl: Don't allocate a state_slots array for 0 state slots<br>
  i965/fs_nir: Don't dump the shader.<br>
  nir: Use the enum for the variable mode<br>
  nir: Automatically update SSA if uses<br>
  nir: Add a copy splitting pass<br>
  nir: Add a pass to lower local variable accesses to SSA values<br>
  nir: Add a pass to lower local variables to registers<br>
  nir: Add a pass for lowering input/output loads/stores<br>
  nir: Add a pass to lower global variables to local variables<br>
  nir/glsl: Generate SSA NIR<br>
  i965/fs_nir: Use the new variable lowering code<br>
  nir/validate: Ensure that outputs are write-only and inputs are<br>
    read-only<br>
  nir: Remove the old variable lowering code<br>
  nir: Vectorize intrinsics<br>
  nir/validate: Validate intrinsic source/destination sizes<br>
  nir: Add gpu_shader5 interpolation intrinsics<br>
  nir/glsl: Add support for gpu_shader5 interpolation instrinsics<br>
  nir: Add a helper for getting a constant value from an SSA source<br>
  i965/fs_nir: Add a has_indirect flag and clean up some of the<br>
    input/output code<br>
  i965/fs_nir: Implement the ARB_gpu_shader5 interpolation intrinsics<br>
  nir: Add neg, abs, and sat opcodes<br>
  nir: Add a lowering pass for adding source modifiers where possible<br>
  nir: Make the type casting operations static inline functions<br>
  nir/glsl: Emit abs, neg, and sat operations instead of source<br>
    modifiers<br>
  nir: Add an expression matching framework<br>
  nir: Add infastructure for generating algebraic transformation passes<br>
  nir: Add an algebraic optimization pass<br>
  nir: Add a basic constant folding pass<br>
  nir: Remove the ffma peephole<br>
  nir: Make texture instruction names more consistent<br>
  nir: Constant fold array indirects<br>
  nir: Use a source for uniform buffer indices instead of an index<br>
  nir: Add a sampler index indirect to nir_tex_instr<br>
  nir: Rework the way samplers are lowered<br>
  i965/fs_nir: Add support for indirect texture arrays<br>
  nir/metadata: Rename metadata_dirty to metadata_preserve<br>
  nir: Call nir_metadata_preserve more places<br>
  nir: Make bcsel a fully vector operation<br>
<br>
 src/glsl/Makefile.am                               |   10 +-<br>
 src/glsl/Makefile.sources                          |   39 +-<br>
 src/glsl/list.h                                    |   19 +-<br>
 src/glsl/nir/README                                |  118 ++<br>
 src/glsl/nir/glsl_to_nir.cpp                       | 1825 +++++++++++++++++<br>
 src/glsl/nir/glsl_to_nir.h                         |   40 +<br>
 src/glsl/nir/nir.c                                 | 2042 ++++++++++++++++++++<br>
 src/glsl/nir/nir.h                                 | 1433 ++++++++++++++<br>
 src/glsl/nir/nir_algebraic.py                      |  249 +++<br>
 src/glsl/nir/nir_dominance.c                       |  298 +++<br>
 src/glsl/nir/nir_from_ssa.c                        |  859 ++++++++<br>
 src/glsl/nir/nir_intrinsics.c                      |   49 +<br>
 src/glsl/nir/nir_intrinsics.h                      |  140 ++<br>
 src/glsl/nir/nir_live_variables.c                  |  282 +++<br>
 src/glsl/nir/nir_lower_atomics.c                   |  146 ++<br>
 src/glsl/nir/nir_lower_global_vars_to_local.c      |  107 +<br>
 src/glsl/nir/nir_lower_io.c                        |  324 ++++<br>
 src/glsl/nir/nir_lower_locals_to_regs.c            |  308 +++<br>
 src/glsl/nir/nir_lower_samplers.cpp                |  181 ++<br>
 src/glsl/nir/nir_lower_system_values.c             |  107 +<br>
 src/glsl/nir/nir_lower_to_source_mods.c            |  181 ++<br>
 src/glsl/nir/nir_lower_variables.c                 | 1046 ++++++++++<br>
 src/glsl/nir/nir_lower_vec_to_movs.c               |   96 +<br>
 src/glsl/nir/nir_metadata.c                        |   54 +<br>
 src/glsl/nir/nir_opcodes.c                         |   46 +<br>
 src/glsl/nir/nir_opcodes.h                         |  356 ++++<br>
 src/glsl/nir/nir_opt_algebraic.py                  |   67 +<br>
 src/glsl/nir/nir_opt_constant_folding.c            |  355 ++++<br>
 src/glsl/nir/nir_opt_copy_propagate.c              |  325 ++++<br>
 src/glsl/nir/nir_opt_cse.c                         |  269 +++<br>
 src/glsl/nir/nir_opt_dce.c                         |  186 ++<br>
 src/glsl/nir/nir_opt_global_to_local.c             |  103 +<br>
 src/glsl/nir/nir_opt_peephole_select.c             |  214 ++<br>
 src/glsl/nir/nir_print.c                           |  948 +++++++++<br>
 src/glsl/nir/nir_remove_dead_variables.c           |  138 ++<br>
 src/glsl/nir/nir_search.c                          |  337 ++++<br>
 src/glsl/nir/nir_search.h                          |   80 +<br>
 src/glsl/nir/nir_split_var_copies.c                |  225 +++<br>
 src/glsl/nir/nir_to_ssa.c                          |  660 +++++++<br>
 src/glsl/nir/nir_types.cpp                         |  143 ++<br>
 src/glsl/nir/nir_types.h                           |   75 +<br>
 src/glsl/nir/nir_validate.c                        |  912 +++++++++<br>
 src/mesa/drivers/dri/i965/Makefile.sources         |    1 +<br>
 src/mesa/drivers/dri/i965/brw_fs.cpp               |   74 +-<br>
 src/mesa/drivers/dri/i965/brw_fs.h                 |   57 +-<br>
 .../drivers/dri/i965/brw_fs_copy_propagation.cpp   |    4 +-<br>
 src/mesa/drivers/dri/i965/brw_fs_fp.cpp            |   32 +-<br>
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp           | 1778 +++++++++++++++++<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp       |   39 +-<br>
 src/mesa/main/bitset.h                             |    1 +<br>
 50 files changed, 17301 insertions(+), 77 deletions(-)<br>
 create mode 100644 src/glsl/nir/README<br>
 create mode 100644 src/glsl/nir/glsl_to_nir.cpp<br>
 create mode 100644 src/glsl/nir/glsl_to_nir.h<br>
 create mode 100644 src/glsl/nir/nir.c<br>
 create mode 100644 src/glsl/nir/nir.h<br>
 create mode 100644 src/glsl/nir/nir_algebraic.py<br>
 create mode 100644 src/glsl/nir/nir_dominance.c<br>
 create mode 100644 src/glsl/nir/nir_from_ssa.c<br>
 create mode 100644 src/glsl/nir/nir_intrinsics.c<br>
 create mode 100644 src/glsl/nir/nir_intrinsics.h<br>
 create mode 100644 src/glsl/nir/nir_live_variables.c<br>
 create mode 100644 src/glsl/nir/nir_lower_atomics.c<br>
 create mode 100644 src/glsl/nir/nir_lower_global_vars_to_local.c<br>
 create mode 100644 src/glsl/nir/nir_lower_io.c<br>
 create mode 100644 src/glsl/nir/nir_lower_locals_to_regs.c<br>
 create mode 100644 src/glsl/nir/nir_lower_samplers.cpp<br>
 create mode 100644 src/glsl/nir/nir_lower_system_values.c<br>
 create mode 100644 src/glsl/nir/nir_lower_to_source_mods.c<br>
 create mode 100644 src/glsl/nir/nir_lower_variables.c<br>
 create mode 100644 src/glsl/nir/nir_lower_vec_to_movs.c<br>
 create mode 100644 src/glsl/nir/nir_metadata.c<br>
 create mode 100644 src/glsl/nir/nir_opcodes.c<br>
 create mode 100644 src/glsl/nir/nir_opcodes.h<br>
 create mode 100644 src/glsl/nir/nir_opt_algebraic.py<br>
 create mode 100644 src/glsl/nir/nir_opt_constant_folding.c<br>
 create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c<br>
 create mode 100644 src/glsl/nir/nir_opt_cse.c<br>
 create mode 100644 src/glsl/nir/nir_opt_dce.c<br>
 create mode 100644 src/glsl/nir/nir_opt_global_to_local.c<br>
 create mode 100644 src/glsl/nir/nir_opt_peephole_select.c<br>
 create mode 100644 src/glsl/nir/nir_print.c<br>
 create mode 100644 src/glsl/nir/nir_remove_dead_variables.c<br>
 create mode 100644 src/glsl/nir/nir_search.c<br>
 create mode 100644 src/glsl/nir/nir_search.h<br>
 create mode 100644 src/glsl/nir/nir_split_var_copies.c<br>
 create mode 100644 src/glsl/nir/nir_to_ssa.c<br>
 create mode 100644 src/glsl/nir/nir_types.cpp<br>
 create mode 100644 src/glsl/nir/nir_types.h<br>
 create mode 100644 src/glsl/nir/nir_validate.c<br>
 create mode 100644 src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
</div></div><span><font color="#888888"><span class="HOEnZb"><font color="#888888"><br>
--<br>
2.2.0<br>
<br></font></span><span class="">
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</span></font></span></blockquote></div><br></div>
</blockquote></div><br></div></div>