diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2015-04-02 21:24:38 -0700 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2015-04-07 14:34:14 -0700 |
commit | de2014cf1e12826a53a1132f6d80c889f375b2e8 (patch) | |
tree | eed7f1dccb0d60a66e219a7366de2a5f9724099a /src/glsl/nir/nir.c | |
parent | 4f4b04b7c7ee1ce27da990190a740473db0f2ecb (diff) | |
download | external_mesa3d-de2014cf1e12826a53a1132f6d80c889f375b2e8.zip external_mesa3d-de2014cf1e12826a53a1132f6d80c889f375b2e8.tar.gz external_mesa3d-de2014cf1e12826a53a1132f6d80c889f375b2e8.tar.bz2 |
nir: Allocate dereferences out of their parent instruction or deref.
Jason pointed out that variable dereferences in NIR are really part of
their parent instruction, and should have the same lifetime.
Unlike in GLSL IR, they're not used very often - just for intrinsic
variables, call parameters & return, and indirect samplers for
texturing. Also, nir_deref_var is the top-level concept, and
nir_deref_array/nir_deref_record are child nodes.
This patch attempts to allocate nir_deref_vars out of their parent
instruction, and any sub-dereferences out of their parent deref.
It enforces these restrictions in the validator as well.
This means that freeing an instruction should free its associated
dereference chain as well. The memory sweeper pass can also happily
ignore them.
v2: Rename make_deref to evaluate_deref and make it take a nir_instr *
instead of void *. This involves adding &instr->instr everywhere.
(Requested by Jason Ekstrand.)
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Diffstat (limited to 'src/glsl/nir/nir.c')
-rw-r--r-- | src/glsl/nir/nir.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 85ff0f4..1c6b603 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -543,7 +543,7 @@ copy_deref_var(void *mem_ctx, nir_deref_var *deref) nir_deref_var *ret = nir_deref_var_create(mem_ctx, deref->var); ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(mem_ctx, deref->deref.child); + ret->deref.child = nir_copy_deref(ret, deref->deref.child); return ret; } @@ -558,7 +558,7 @@ copy_deref_array(void *mem_ctx, nir_deref_array *deref) } ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(mem_ctx, deref->deref.child); + ret->deref.child = nir_copy_deref(ret, deref->deref.child); return ret; } @@ -568,7 +568,7 @@ copy_deref_struct(void *mem_ctx, nir_deref_struct *deref) nir_deref_struct *ret = nir_deref_struct_create(mem_ctx, deref->index); ret->deref.type = deref->deref.type; if (deref->deref.child) - ret->deref.child = nir_copy_deref(mem_ctx, deref->deref.child); + ret->deref.child = nir_copy_deref(ret, deref->deref.child); return ret; } |