[Mesa-dev] [RFC v1 00/38] nir: Move to using instructions for derefs
Jason Ekstrand
jason at jlekstrand.net
Wed Mar 21 05:54:34 UTC 2018
This is something that Connor and I have been talking about for some time
now. The basic idea is to replace the current singly linked nir_deref list
with deref instructions. This is similar to what LLVM does and it offers
quite a bit more freedom when we start getting more realistic pointers from
compute applications.
This series is the start of the conversion. I have almost everything
working for i965. The two remaining gaps are nir_lower_locals_to_regs and
nir_lower_samplers. However, those two passes are a bit less practical to
change in the same additive fashion that I've done for most of core NIR.
Instead, my plan is to just change them for everyone all at the same time.
Before we can do that, however, we need to get other drivers to the same
point as i965. I don't think I've broken anyone else's drivers in this
process since they just lower derefs away immediately.
My next project will be Vulkan. Unfortunately, that means reworking the
way that NIR functions work so that we can use deref instructions with
them. My plan there is to vastly simplify them so that they just have a
list of SSA defs which get filled out at the start of the function call.
Those SSA defs may be derefs or regular values. Return parameters are
handled by passing a deref into the function as a parameter and then
writing to it from within the function. This should map fairly naturally
to SPIR-V but it'll be a fairly big change. I've already started hacking
on this and I think I really like it. One result is that function inlining
is now basically trivial.
If you're the owner of a GL driver and would like to work on converting it,
that would be awesome. I'm happy to take a crack but there's enough work
to do to get core Vulkan bits working that it'd be nice if I didn't do all
the work. :-) Bas, I'm afraid Vulkan is blocking on the function reworks;
I'll let you know once I have something.
The other thing that's left to do after we get all the drivers moved over
is to rip out legacy deref chains and do a final rework of a few of the
core optimization/lowering passes. Some passes such as vars_to_ssa still
use deref chains internally by converting deref instructions to deref
chains on-the-fly. I've got a plan for converting them but we need to make
deref chains an artifact of history first.
This series can be found as a branch on gitlab:
https://gitlab.freedesktop.org/jekstrand/mesa/commits/review/nir-deref-instrs-v1
Cc: Rob Clark <robdclark at gmail.com>
Cc: Timothy Arceri <tarceri at itsqueeze.com>
Cc: Eric Anholt <eric at anholt.net>
Cc: Connor Abbott <cwabbott0 at gmail.com>
Cc: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Jason Ekstrand (38):
nir: Add src/dest num_components helpers
nir: Return a cursor from nir_instr_remove
nir/vars_to_ssa: Remove copies from the correct set
nir/lower_indirect_derefs: Support interp_var_at intrinsics
nir/validator: Validate that all used variables exist
nir: Rename image intrinsics to image_var
nir: Add a deref instruction type
nir/builder: Add deref building helpers
nir: Add _deref versions of all of the _var intrinsics
nir: Add deref sources to texture instructions
nir: Add helpers for working with deref instructions
anv,i965,radv,st,ir3: Call nir_lower_deref_instrs
glsl/nir: Only claim to handle intrinsic functions
glsl/nir: Use deref instructions instead of dref chains
prog/nir: Simplify some load/store operations
prog/nir: Use deref instructions for params
nir/lower_atomics: Rework the main walker loop a bit
nir: Support deref instructions in remove_dead_variables
nir: Add a pass for fixing deref modes
nir: Support deref instructions in lower_global_vars_to_local
nir: Support deref instructions in lower_io_to_temporaries
nir: Add a deref path helper struct
nir: Support deref instructions in lower_var_copies
nir: Support deref instructions in split_var_copies
nir: Support deref instructions in lower_vars_to_ssa
nir: Support deref instructions in lower_indirect_derefs
nir/deref: Add a deref cleanup function
nir: Support deref instructions in lower_system_values
nir: Support deref instructions in lower_clip_cull
nir: Support deref instructions in propagate_invariant
nir: Support deref instructions in gather_info
nir: Support deref instructions in lower_io
nir: Support deref instructions in lower_atomics
nir: Support deref instructions in lower_wpos_ytransform
nir: Support deref instructions in remove_unused_varyings
intel,ir3: Disable nir_opt_copy_prop_vars
intel/nir: Fixup deref modes after lowering patch vertices
i965: Move nir_lower_deref_instrs to right before locals_to_regs
src/amd/common/ac_nir_to_llvm.c | 42 +--
src/amd/vulkan/radv_meta_bufimage.c | 8 +-
src/amd/vulkan/radv_meta_fast_clear.c | 2 +-
src/amd/vulkan/radv_meta_resolve_cs.c | 2 +-
src/amd/vulkan/radv_shader.c | 2 +
src/amd/vulkan/radv_shader_info.c | 40 +--
src/compiler/Makefile.sources | 2 +
src/compiler/glsl/glsl_to_nir.cpp | 264 +++++---------
src/compiler/nir/meson.build | 2 +
src/compiler/nir/nir.c | 52 ++-
src/compiler/nir/nir.h | 129 ++++++-
src/compiler/nir/nir_builder.h | 201 +++++++++++
src/compiler/nir/nir_clone.c | 41 +++
src/compiler/nir/nir_deref.c | 392 +++++++++++++++++++++
src/compiler/nir/nir_deref.h | 55 +++
src/compiler/nir/nir_gather_info.c | 26 +-
src/compiler/nir/nir_instr_set.c | 76 ++++
src/compiler/nir/nir_intrinsics.h | 108 +++++-
src/compiler/nir/nir_linking_helpers.c | 50 +--
src/compiler/nir/nir_lower_atomics.c | 133 ++++++-
.../nir/nir_lower_clip_cull_distance_arrays.c | 69 +++-
src/compiler/nir/nir_lower_global_vars_to_local.c | 62 ++--
src/compiler/nir/nir_lower_indirect_derefs.c | 169 ++++++++-
src/compiler/nir/nir_lower_io.c | 70 ++--
src/compiler/nir/nir_lower_io_to_temporaries.c | 2 +
src/compiler/nir/nir_lower_samplers_as_deref.c | 22 +-
src/compiler/nir/nir_lower_system_values.c | 13 +-
src/compiler/nir/nir_lower_var_copies.c | 90 ++++-
src/compiler/nir/nir_lower_vars_to_ssa.c | 77 +++-
src/compiler/nir/nir_lower_wpos_ytransform.c | 29 +-
src/compiler/nir/nir_opt_copy_prop_vars.c | 19 +-
src/compiler/nir/nir_opt_copy_propagate.c | 18 +
src/compiler/nir/nir_opt_dce.c | 7 +
src/compiler/nir/nir_print.c | 52 +++
src/compiler/nir/nir_propagate_invariant.c | 23 +-
src/compiler/nir/nir_remove_dead_variables.c | 99 ++++++
src/compiler/nir/nir_serialize.c | 79 +++++
src/compiler/nir/nir_split_var_copies.c | 42 +++
src/compiler/nir/nir_validate.c | 90 ++++-
src/compiler/spirv/spirv_to_nir.c | 4 +-
src/gallium/drivers/freedreno/ir3/ir3_cmdline.c | 3 +
.../drivers/freedreno/ir3/ir3_compiler_nir.c | 38 +-
src/gallium/drivers/freedreno/ir3/ir3_nir.c | 4 +-
src/gallium/drivers/radeonsi/si_shader_nir.c | 18 +-
src/intel/compiler/brw_fs_nir.cpp | 46 +--
src/intel/compiler/brw_nir.c | 4 +-
src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 24 +-
src/intel/vulkan/anv_nir_lower_input_attachments.c | 2 +-
src/intel/vulkan/anv_pipeline.c | 2 +
src/mesa/drivers/dri/i965/brw_nir_uniforms.cpp | 2 +
src/mesa/drivers/dri/i965/brw_program.c | 1 +
src/mesa/program/prog_to_nir.c | 65 +---
src/mesa/state_tracker/st_glsl_to_nir.cpp | 1 +
53 files changed, 2365 insertions(+), 508 deletions(-)
create mode 100644 src/compiler/nir/nir_deref.c
create mode 100644 src/compiler/nir/nir_deref.h
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list