<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jun 3, 2018 at 4:18 PM, Bas Nieuwenhuizen <span dir="ltr"><<a href="mailto:bas@basnieuwenhuizen.nl" target="_blank">bas@basnieuwenhuizen.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sat, Jun 2, 2018 at 2:48 AM, Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>> wrote:<br>
> On Fri, Jun 1, 2018 at 1:01 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
>> 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>
>> Right now, we still have a fully "logical" pointer model where pointer<br>
>> chains eventually terminate at variable dereferences.  In future, we'd like<br>
>> to be able to use nir_deref_instrs for things like UBOs and SSBOs where tha<br>
>> tmay not be the case.  There are still a couple open questions around how<br>
>> we want to handle "raw" pointers in SPIR-V for OpenCL drivers particularly<br>
>> around casting.  However, the hard part is getting the deref instructions<br>
>> and getting everything switched over to them.  Now that we've done that,<br>
>> some of those other details can be sorted out later.<br>
>><br>
>> This series is, as far as Rob, Bas, and I can tell, a complete and correct<br>
>> transition for all NIR-based drivers.  The final patch deletes the data<br>
>> structures and helpers for the older deref chains.<br>
>><br>
>> A massive thank you goes out to Rob for putting the final patch set<br>
>> together and trying to get things in an order that will hopefully not<br>
>> regress anyone.  Thanks also to Bas for fixing up the radeon and radv<br>
>> bits.<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-instr-v4" rel="noreferrer" target="_blank">https://gitlab.freedesktop.<wbr>org/jekstrand/mesa/commits/<wbr>review/nir-deref-instr-v4</a><br>
>><br>
>> Ideally, I'd like the series to get some amount of real review before it<br>
>> lands.  Honestly, it's been baking long enough and tested by enough people<br>
>> on enough drivers that we can probably throw a bunch of Acked-by and<br>
>> Tested-bys on it and call it a day but I'd rather not.  I plan to review<br>
>> all of the patches I didn't write but that will have to wait until<br>
>> tomorrow.<br>
>><br>
>> At the very least, I'd like some sort of an ACK from a variety of the<br>
>> people that use NIR on the core concept and the sort of general shape of<br>
>> things at the end of the series.  A lot of work has gone into this but it's<br>
>> also a big change and the more positive feedback it gets, the more<br>
>> comfortable I'll be pulling the trigger.<br>
><br>
> fwiw, with the issues that Bas hit, strong a-b from me..<br>
<br>
</div></div>With the fixups I just sent (and which the list will hopefully pick up<br>
soon ...) and the mentioned patch moves in the cover letter (and Daves<br>
r-b applied on the original AMD patches?), this series is acked-by me.<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div><br></div><div>Cool.  I've applied your patches and they are now in my wip/nir-deref-instrs branch.  Please double-check that I applied them correctly.</div><div><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"><span class="HOEnZb"><font color="#888888">
- Bas<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> I've been working with the patchset for a while, (and a big stack of<br>
> compute related patches on top that I'd like to be able to start<br>
> sending to list) and the handful of comments made on irc in the early<br>
> stages have been addressed.  This makes for a much cleaner base to<br>
> start adding "real" pointer support for compute, so I'm totally happy,<br>
> it works out much cleaner than earlier attempts based on working<br>
> around deref chains :-)<br>
><br>
> not a traditional patch-by-patch review, so not really sure r-b is<br>
> appropriate, but I'm pretty happy with the result (and the amount of<br>
> churn involved does make tranditional patch-by-patch review difficult)<br>
><br>
> BR,<br>
> -R<br>
><br>
>><br>
>> Thanks,<br>
>><br>
>> --Jason Ekstrand<br>
>><br>
>><br>
>><br>
>> 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>
>> Cc: Matt Turner <<a href="mailto:mattst88@gmail.com">mattst88@gmail.com</a>><br>
>> Cc: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
>> Cc: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
>><br>
>> Bas Nieuwenhuizen (16):<br>
>>   ac/nir: Implement the deref instr for shared memory.<br>
>>   ac/nir: Support deref instructions in get_sampler_desc.<br>
>>   ac/nir: Support deref instructions in tex instructions.<br>
>>   ac/nir: Implement derefs for integer gather4 lowering.<br>
>>   ac/nir: Add deref support to image intrinsics.<br>
>>   radv: Add shader info support for image deref instructions.<br>
>>   ac/nir: Add deref based var loads/stores.<br>
>>   radv: Gather info for deref instr based load/store.<br>
>>   ac/nir: Add shared atomic deref instr support.<br>
>>   ac/nir: Add deref interp support.<br>
>>   radv: Use deref instructions for tex derefs in meta shaders.<br>
>>   radv: Remove image_var stores.<br>
>>   radeonsi: Add deref support to the nir scan pass.<br>
>>   ac/nir: Remove deref chain support.<br>
>>   radv: Remove deref chain support in radv shader info pass.<br>
>>   radeonsi: Remove deref chain support in nir scan pass.<br>
>><br>
>> Eric Anholt (1):<br>
>>   broadcom/vc4: Remove deref chain support from nir_lower_txf_ms.<br>
>><br>
>> Jason Ekstrand (98):<br>
>>   nir/validate: Rework intrinsic type validation<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>
>>   nir/deref: Add some deref cleanup functions<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: Use deref instructions for params<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: 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>
>>   nir: Support deref instructions in loop_analyze<br>
>>   nir: Support deref instructions in lower_alpha_test<br>
>>   nir: Support deref instructions in lower_clamp_color_outputs<br>
>>   nir: Support deref instructions in lower_drawpixels<br>
>>   nir: Consider deref instructions in lower_phis_to_scalar<br>
>>   nir: Consider deref instructions in opt_peephole_select<br>
>>   nir: Support deref instructions in opt_undef<br>
>>   intel,ir3: Disable nir_opt_copy_prop_vars<br>
>>   intel/nir: Fixup deref modes after lowering patch vertices<br>
>>   nir/lower_tex: Always copy deref and offset sources<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/spirv: Pass nir_variable_data into apply_var_decoration<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/pipeline: Convert lower_multiview to deref instructions<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>
>>   intel/blorp: Stop setting tex->texture/sampler<br>
>>   nir/lower_samplers: Clean up function arguments<br>
>>   nir: Use derefs in nir_lower_samplers<br>
>>   nir/builder: Use deref instructions for load/store/copy_var<br>
>>   nir: Use deref instructions in lower_constant_initializers<br>
>>   nir/vars_to_ssa: Add an is_direct field to deref_node<br>
>>   nir/vars_to_ssa: Rework to entirely use deref instructions<br>
>>   nir: Rework gather_info to entirely use deref instructions<br>
>>   nir: Remove deref chain support from lower_indirect_derefs<br>
>>   nir: Remove deref chain support from lower_clip_cull_distance_<wbr>arrays<br>
>>   nir: Remove deref chain support from lower_atomics<br>
>>   nir: Remove deref chain support from lower_alpha_test<br>
>>   nir: Remove deref chain support from lower_clamp_color_outputs<br>
>>   nir: Remove deref chain support from lower_global_vars_to_local<br>
>>   nir/lower_io: Convert atomic lowering to deref instructions<br>
>>   nir: Convert lower_io to deref instructions<br>
>>   nir: Remove deref chain support from lower_phis_to_scalar<br>
>>   nir: Delete lower_io_types<br>
>>   nir: Remove deref chain support from remove_unused_varyings<br>
>>   nir: Remove deref chain support from lower_system_values<br>
>>   nir: Remove deref chain support from lower_wpos_center<br>
>>   nir: Remove deref chain support from lower_wpos_ytransform<br>
>>   nir: Remove deref chain support from lower_tex<br>
>>   nir: Remove deref chain support from opt_peephole_select<br>
>>   nir: Remove deref chain support from lower_drawpixels<br>
>>   nir: Remove deref chain support from lower_var_copies<br>
>>   nir: Remove deref chain support from propagate_invariant<br>
>>   nir: Remove deref chain support from dead_variables<br>
>>   nir: Remove deref chain support from split_var_copies<br>
>>   nir: Remove deref chain support from opt_undef<br>
>>   nir: Remove deref chain support from split_per_member_structs<br>
>>   nir/copy_prop_vars: Re-order some logic in compare_derefs<br>
>>   nir: Rework opt_copy_prop_vars to use deref instructions<br>
>>   intel,ir3: Re-enable nir_opt_copy_prop_vars<br>
>>   nir: Rework lower_locals_to_regs to use deref instructions<br>
>>   nir: Remove deref chain support from analyze_loops<br>
>>   nir: Remove old-school deref chain support<br>
>>   nir/lower_system_values: Assert/assume direct var derefs<br>
>><br>
>> Rob Clark (14):<br>
>>   nir: add deref lowering sanity checking<br>
>>   ttn: convert to deref instructions<br>
>>   nir/lower_samplers: split out _legacy version for deref chains<br>
>>   move lower_deref_instrs<br>
>>   nir: convert lower_io_to_scalar to deref instructions<br>
>>   mesa/st: temporarily disable lower_io_to_elements()<br>
>>   mesa/st/nir: convert lower_builtins to deref instructions<br>
>>   nir: convert lower_io_arrays_to_elements to deref instructions<br>
>>   mesa/st: re-enable lower_io_to_elements()<br>
>>   nir: convert lower_samplers_as_deref to deref instructions<br>
>>   nir/lower_samplers: remove legacy version<br>
>>   st,ir3,radeonsi: push lower_deref_instrs back into driver<br>
>>   nir: promote intrinsic_get_var() to helper<br>
>>   freedreno/ir3: convert to deref instructions<br>
>><br>
>>  src/amd/common/ac_nir_to_llvm.<wbr>c                    | 547 ++++++++++----------<br>
>>  src/amd/vulkan/radv_meta.c                         |  20 +-<br>
>>  src/amd/vulkan/radv_meta_blit.<wbr>c                    |  30 +-<br>
>>  src/amd/vulkan/radv_meta_<wbr>blit2d.c                  |  21 +-<br>
>>  src/amd/vulkan/radv_meta_<wbr>bufimage.c                |  62 +--<br>
>>  src/amd/vulkan/radv_meta_fast_<wbr>clear.c              |  17 +-<br>
>>  src/amd/vulkan/radv_meta_<wbr>resolve_cs.c              |  10 +-<br>
>>  src/amd/vulkan/radv_shader.c                       |   8 +<br>
>>  src/amd/vulkan/radv_shader_<wbr>info.c                  | 139 ++---<br>
>>  src/compiler/Makefile.sources                      |   4 +-<br>
>>  src/compiler/glsl/gl_nir_<wbr>lower_atomics.c           | 137 ++---<br>
>>  src/compiler/glsl/gl_nir_<wbr>lower_samplers.c          | 162 +++---<br>
>>  src/compiler/glsl/gl_nir_<wbr>lower_samplers_as_deref.c | 180 ++++---<br>
>>  src/compiler/glsl/glsl_to_nir.<wbr>cpp                  | 267 ++++------<br>
>>  src/compiler/nir/meson.build                       |   4 +-<br>
>>  src/compiler/nir/nir.c                             | 423 +++-------------<br>
>>  src/compiler/nir/nir.h                             | 207 ++++----<br>
>>  src/compiler/nir/nir_builder.h                     | 254 ++++++++--<br>
>>  src/compiler/nir/nir_clone.c                       | 143 ++----<br>
>>  src/compiler/nir/nir_deref.c                       | 165 ++++++<br>
>>  src/compiler/nir/nir_deref.h                       |  55 ++<br>
>>  src/compiler/nir/nir_gather_<wbr>info.c                 |  51 +-<br>
>>  src/compiler/nir/nir_inline_<wbr>functions.c            | 193 ++-----<br>
>>  src/compiler/nir/nir_instr_<wbr>set.c                   | 101 +++-<br>
>>  src/compiler/nir/nir_<wbr>intrinsics.py                 |  99 ++--<br>
>>  src/compiler/nir/nir_<wbr>intrinsics_c.py               |   1 -<br>
>>  src/compiler/nir/nir_linking_<wbr>helpers.c             |  47 +-<br>
>>  src/compiler/nir/nir_loop_<wbr>analyze.c                |  70 ++-<br>
>>  src/compiler/nir/nir_lower_<wbr>alpha_test.c            |   7 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>clamp_color_outputs.c   |   9 +-<br>
>>  .../nir/nir_lower_clip_cull_<wbr>distance_arrays.c      |  85 ++--<br>
>>  src/compiler/nir/nir_lower_<wbr>constant_initializers.c |  57 ++-<br>
>>  src/compiler/nir/nir_lower_<wbr>drawpixels.c            |  10 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>global_vars_to_local.c  |  45 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>indirect_derefs.c       | 174 +++----<br>
>>  src/compiler/nir/nir_lower_io.<wbr>c                    | 185 ++++---<br>
>>  src/compiler/nir/nir_lower_io_<wbr>arrays_to_elements.c | 154 +++---<br>
>>  src/compiler/nir/nir_lower_io_<wbr>to_scalar.c          |  90 ++--<br>
>>  src/compiler/nir/nir_lower_io_<wbr>to_temporaries.c     |   2 +<br>
>>  src/compiler/nir/nir_lower_io_<wbr>types.c              | 176 -------<br>
>>  src/compiler/nir/nir_lower_<wbr>locals_to_regs.c        | 186 ++++---<br>
>>  src/compiler/nir/nir_lower_<wbr>phis_to_scalar.c        |  14 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>system_values.c         |  31 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>tex.c                   |  47 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>var_copies.c            | 165 +++---<br>
>>  src/compiler/nir/nir_lower_<wbr>vars_to_ssa.c           | 330 ++++++------<br>
>>  src/compiler/nir/nir_lower_<wbr>wpos_center.c           |   8 +-<br>
>>  src/compiler/nir/nir_lower_<wbr>wpos_ytransform.c       |  33 +-<br>
>>  src/compiler/nir/nir_opt_<wbr>constant_folding.c        |  53 --<br>
>>  src/compiler/nir/nir_opt_copy_<wbr>prop_vars.c          | 316 ++++++------<br>
>>  src/compiler/nir/nir_opt_copy_<wbr>propagate.c          |  95 ++--<br>
>>  src/compiler/nir/nir_opt_dce.c                     |   7 +<br>
>>  src/compiler/nir/nir_opt_<wbr>peephole_select.c         |   4 +-<br>
>>  src/compiler/nir/nir_opt_<wbr>undef.c                   |   2 +-<br>
>>  src/compiler/nir/nir_print.c                       | 252 +++++----<br>
>>  src/compiler/nir/nir_<wbr>propagate_invariant.c         |  17 +-<br>
>>  src/compiler/nir/nir_remove_<wbr>dead_variables.c       | 152 +++---<br>
>>  src/compiler/nir/nir_<wbr>serialize.c                   | 234 ++++-----<br>
>>  src/compiler/nir/nir_split_<wbr>per_member_structs.c    | 208 ++++++++<br>
>>  src/compiler/nir/nir_split_<wbr>var_copies.c            | 234 ++-------<br>
>>  src/compiler/nir/nir_sweep.c                       |   4 -<br>
>>  src/compiler/nir/nir_validate.<wbr>c                    | 247 ++++-----<br>
>>  src/compiler/spirv/spirv_to_<wbr>nir.c                  | 184 ++++---<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                   |  26 +-<br>
>>  src/compiler/spirv/vtn_<wbr>variables.c                 | 563 +++++++--------------<br>
>>  src/gallium/auxiliary/nir/<wbr>tgsi_to_nir.c            |  52 +-<br>
>>  src/gallium/drivers/freedreno/<wbr>ir3/ir3_cmdline.c    |   1 -<br>
>>  .../drivers/freedreno/ir3/ir3_<wbr>compiler_nir.c       |  49 +-<br>
>>  src/gallium/drivers/freedreno/<wbr>ir3/ir3_nir.c        |   4 +-<br>
>>  .../freedreno/ir3/ir3_nir_<wbr>lower_tg4_to_tex.c       |   4 +-<br>
>>  src/gallium/drivers/radeonsi/<wbr>si_shader_nir.c       |  72 ++-<br>
>>  src/gallium/drivers/vc4/vc4_<wbr>nir_lower_txf_ms.c     |   1 -<br>
>>  src/intel/blorp/blorp_blit.c                       |   2 -<br>
>>  src/intel/compiler/brw_fs.h                        |   2 +-<br>
>>  src/intel/compiler/brw_fs_nir.<wbr>cpp                  | 157 +++---<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_multiview.c         |  17 +-<br>
>>  src/intel/vulkan/anv_nir_<wbr>lower_ycbcr_textures.c    |  34 +-<br>
>>  src/intel/vulkan/anv_pipeline.<wbr>c                    |   7 +<br>
>>  src/mesa/drivers/dri/i965/brw_<wbr>nir_uniforms.cpp     |   2 +<br>
>>  src/mesa/drivers/dri/i965/brw_<wbr>program.c            |   5 +-<br>
>>  src/mesa/program/prog_to_nir.c                     |  41 +-<br>
>>  src/mesa/state_tracker/st_nir_<wbr>lower_builtin.c      |  62 ++-<br>
>>  86 files changed, 4183 insertions(+), 4620 deletions(-)<br>
>>  create mode 100644 src/compiler/nir/nir_deref.c<br>
>>  create mode 100644 src/compiler/nir/nir_deref.h<br>
>>  delete mode 100644 src/compiler/nir/nir_lower_io_<wbr>types.c<br>
>>  create mode 100644 src/compiler/nir/nir_split_<wbr>per_member_structs.c<br>
>><br>
>> --<br>
>> 2.5.0.400.gff86faf<br>
>><br>
</div></div></blockquote></div><br></div></div>