<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 23, 2018 at 2:42 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This is something that Connor and I have been talking about for some time<br>
now.  The basic idea is to replace the current singly linked nir_deref list<br>
with deref instructions.  This is similar to what LLVM does and it offers<br>
quite a bit more freedom when we start getting more realistic pointers from<br>
compute applications.<br>
<br>
This series implements an almost complete conversion for both i965 and anv.<br>
The two remaining gaps are nir_lower_locals_to_regs and nir_lower_samplers.<br>
The former will have to wait for ir3 to be converted and the later will<br>
have to wait for radeonsi.  I've got patches for nir_lower_samplers but not<br>
nir_lower_samplers_as_deref which is required by at least radeonsi.  Once<br>
those are in place, we should be able to drop the lowering pass from the<br>
Intel back-end completely.<br>
<br>
The next step (which I will start on next week) will be removing legacy<br>
derefs from core NIR.  This will also involve significant reworks in some<br>
passes such as vars_to_ssa which still uses legacy derefs internally even<br>
for things which use deref instructions.<br>
<br>
Clearly, we can't remove anything until all of the other drivers are<br>
converted.  However, this series should be a good basis for anyone wanting<br>
to work on converting another driver since almost all of the core NIR<br>
passes now work with both types of derefs so you can convert in whatever<br>
way makes sense.<br>
<br>
This series can be found as a branch on gitlab:<br>
<br>
<a href="https://gitlab.freedesktop.org/jekstrand/mesa/commits/review/nir-deref-instrs-v1" rel="noreferrer" target="_blank">https://gitlab.freedesktop.<wbr>org/jekstrand/mesa/commits/<wbr>review/nir-deref-instrs-v1</a><br></blockquote><div><br></div>Oops, that's supposed to be -v2<br><br><a href="https://gitlab.freedesktop.org/jekstrand/mesa/commits/review/nir-deref-instr-v2">https://gitlab.freedesktop.org/jekstrand/mesa/commits/review/nir-deref-instr-v2</a><br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Cc: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>><br>
Cc: Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>><br>
Cc: Eric Anholt <<a href="mailto:eric@anholt.net">eric@anholt.net</a>><br>
Cc: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
Cc: Bas Nieuwenhuizen <<a href="mailto:bas@basnieuwenhuizen.nl">bas@basnieuwenhuizen.nl</a>><br>
Cc: Karol Herbst <<a href="mailto:kherbst@redhat.com">kherbst@redhat.com</a>><br>
<br>
Jason Ekstrand (61):<br>
  nir: Add src/dest num_components helpers<br>
  nir: Return a cursor from nir_instr_remove<br>
  nir/vars_to_ssa: Remove copies from the correct set<br>
  nir/lower_indirect_derefs: Support interp_var_at intrinsics<br>
  intel/vec4: Set channel_sizes for MOV_INDIRECT sources<br>
  nir/validator: Validate that all used variables exist<br>
  nir: Add a deref instruction type<br>
  nir/builder: Add deref building helpers<br>
  nir: Add _deref versions of all of the _var intrinsics<br>
  nir: Add deref sources to texture instructions<br>
  nir: Add helpers for working with deref instructions<br>
  anv,i965,radv,st,ir3: Call nir_lower_deref_instrs<br>
  glsl/nir: Only claim to handle intrinsic functions<br>
  glsl/nir: Use deref instructions instead of dref chains<br>
  prog/nir: Simplify some load/store operations<br>
  prog/nir: Use deref instructions for params<br>
  nir/lower_atomics: Rework the main walker loop a bit<br>
  nir: Support deref instructions in remove_dead_variables<br>
  nir: Add a pass for fixing deref modes<br>
  nir: Support deref instructions in lower_global_vars_to_local<br>
  nir: Support deref instructions in lower_io_to_temporaries<br>
  nir: Add a deref path helper struct<br>
  nir: Support deref instructions in lower_var_copies<br>
  nir: Support deref instructions in split_var_copies<br>
  nir: Support deref instructions in lower_vars_to_ssa<br>
  nir: Support deref instructions in lower_indirect_derefs<br>
  nir/deref: Add a deref cleanup function<br>
  nir: Support deref instructions in lower_system_values<br>
  nir: Support deref instructions in lower_clip_cull<br>
  nir: Support deref instructions in propagate_invariant<br>
  nir: Support deref instructions in gather_info<br>
  nir: Support deref instructions in lower_io<br>
  nir: Support deref instructions in lower_atomics<br>
  nir: Support deref instructions in lower_wpos_ytransform<br>
  nir: Support deref instructions in lower_pos_center<br>
  nir: Support deref instructions in remove_unused_varyings<br>
  intel,ir3: Disable nir_opt_copy_prop_vars<br>
  intel/nir: Fixup deref modes after lowering patch vertices<br>
  i965: Move nir_lower_deref_instrs to right before locals_to_regs<br>
  st/nir: Move lower_deref_instrs later<br>
  spirv: Use deref instructions for most variables<br>
  nir: Add a concept of per-member structs and a lowering pass<br>
  nir/lower_system_values: Support SYSTEM_VALUE_LOCAL_GROUP_SIZE<br>
  spirv: Use the LOCAL_GROUP_SIZE system value<br>
  nir/spirv: Pass nir_variable_data into apply_var_decoration<br>
  anv/pipeline: Lower more constant initializers earlier<br>
  spirv: Use NIR per-member splitting<br>
  spirv: Make push constants an offset-based pointer<br>
  spirv: Clean up vtn_pointer_to_offset<br>
  spirv: Allow pointers to have a deref at the base<br>
  spirv: Update vtn_pointer_to/from_ssa to handle deref pointers<br>
  spirv: Record the type of functions<br>
  spirv/cfg: Make the builder fully capable for both walks<br>
  nir,spirv: Rework function calls<br>
  anv/pipeline: Do less deref instruction lowering<br>
  anv/pipeline: Convert lower_input_attachments to deref instructions<br>
  anv/pipeline: Convert YCbCr lowering to deref instructiosn<br>
  anv/apply_pipeline_layout: Simplify extract_tex_src_plane<br>
  anv/pipeline: Convert apply_pipeline_layout to deref instructions<br>
  intel/fs: Use image_deref intrinsics instead of image_var<br>
  intel/nir: Only lower load/store derefs<br>
<br>
 src/amd/vulkan/radv_shader.c                       |  10 +<br>
 src/compiler/Makefile.sources                      |   3 +<br>
 src/compiler/glsl/glsl_to_nir.<wbr>cpp                  | 265 ++++------<br>
 src/compiler/nir/meson.build                       |   3 +<br>
 src/compiler/nir/nir.c                             | 107 ++--<br>
 src/compiler/nir/nir.h                             | 175 +++++-<br>
 src/compiler/nir/nir_builder.h                     | 236 +++++++++<br>
 src/compiler/nir/nir_clone.c                       |  65 ++-<br>
 src/compiler/nir/nir_deref.c                       | 393 ++++++++++++++<br>
 src/compiler/nir/nir_deref.h                       |  55 ++<br>
 src/compiler/nir/nir_gather_<wbr>info.c                 |  26 +-<br>
 src/compiler/nir/nir_inline_<wbr>functions.c            | 193 +------<br>
 src/compiler/nir/nir_instr_<wbr>set.c                   |  78 +++<br>
 src/compiler/nir/nir_<wbr>intrinsics.h                  |  88 ++++<br>
 src/compiler/nir/nir_linking_<wbr>helpers.c             |  50 +-<br>
 src/compiler/nir/nir_lower_<wbr>atomics.c               | 137 ++++-<br>
 .../nir/nir_lower_clip_cull_<wbr>distance_arrays.c      |  69 ++-<br>
 src/compiler/nir/nir_lower_<wbr>global_vars_to_local.c  |  62 ++-<br>
 src/compiler/nir/nir_lower_<wbr>indirect_derefs.c       | 169 +++++-<br>
 src/compiler/nir/nir_lower_io.<wbr>c                    |  70 ++-<br>
 src/compiler/nir/nir_lower_io_<wbr>to_temporaries.c     |   2 +<br>
 src/compiler/nir/nir_lower_<wbr>system_values.c         |  23 +-<br>
 src/compiler/nir/nir_lower_<wbr>var_copies.c            |  90 +++-<br>
 src/compiler/nir/nir_lower_<wbr>vars_to_ssa.c           |  77 ++-<br>
 src/compiler/nir/nir_lower_<wbr>wpos_center.c           |  13 +-<br>
 src/compiler/nir/nir_lower_<wbr>wpos_ytransform.c       |  51 +-<br>
 src/compiler/nir/nir_opt_copy_<wbr>prop_vars.c          |  19 +-<br>
 src/compiler/nir/nir_opt_copy_<wbr>propagate.c          |  62 ++-<br>
 src/compiler/nir/nir_opt_dce.c                     |   7 +<br>
 src/compiler/nir/nir_print.c                       | 119 +++--<br>
 src/compiler/nir/nir_<wbr>propagate_invariant.c         |  23 +-<br>
 src/compiler/nir/nir_remove_<wbr>dead_variables.c       | 117 +++-<br>
 src/compiler/nir/nir_<wbr>serialize.c                   | 137 +++--<br>
 src/compiler/nir/nir_split_<wbr>per_member_structs.c    | 289 ++++++++++<br>
 src/compiler/nir/nir_split_<wbr>var_copies.c            |  42 ++<br>
 src/compiler/nir/nir_sweep.c                       |   4 -<br>
 src/compiler/nir/nir_validate.<wbr>c                    | 143 +++--<br>
 src/compiler/spirv/spirv_to_<wbr>nir.c                  | 180 ++++---<br>
 src/compiler/spirv/vtn_cfg.c                       | 231 ++++----<br>
 src/compiler/spirv/vtn_<wbr>glsl450.c                   |  19 +-<br>
 src/compiler/spirv/vtn_<wbr>private.h                   |  28 +-<br>
 src/compiler/spirv/vtn_<wbr>variables.c                 | 586 +++++++--------------<br>
 src/gallium/drivers/freedreno/<wbr>ir3/ir3_cmdline.c    |   3 +<br>
 src/gallium/drivers/freedreno/<wbr>ir3/ir3_nir.c        |   2 +-<br>
 src/intel/compiler/brw_fs.h                        |   2 +-<br>
 src/intel/compiler/brw_fs_nir.<wbr>cpp                  | 157 +++---<br>
 src/intel/compiler/brw_nir.c                       |   4 +-<br>
 src/intel/compiler/brw_vec4.<wbr>cpp                    |   5 +-<br>
 src/intel/vulkan/anv_nir_<wbr>apply_pipeline_layout.c   | 187 +++----<br>
 src/intel/vulkan/anv_nir_<wbr>lower_input_attachments.c |  31 +-<br>
 src/intel/vulkan/anv_nir_<wbr>lower_ycbcr_textures.c    |  34 +-<br>
 src/intel/vulkan/anv_pipeline.<wbr>c                    |  19 +-<br>
 src/mesa/drivers/dri/i965/brw_<wbr>nir_uniforms.cpp     |   2 +<br>
 src/mesa/drivers/dri/i965/brw_<wbr>program.c            |   1 +<br>
 src/mesa/program/prog_to_nir.c                     |  65 +--<br>
 src/mesa/state_tracker/st_<wbr>glsl_to_nir.cpp          |   2 +<br>
 56 files changed, 3451 insertions(+), 1579 deletions(-)<br>
 create mode 100644 src/compiler/nir/nir_deref.c<br>
 create mode 100644 src/compiler/nir/nir_deref.h<br>
 create mode 100644 src/compiler/nir/nir_split_<wbr>per_member_structs.c<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
2.5.0.400.gff86faf<br>
<br>
</font></span></blockquote></div><br></div></div>