diff options
author | Kenneth Graunke <[email protected]> | 2015-04-02 21:24:38 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2015-04-07 14:34:14 -0700 |
commit | de2014cf1e12826a53a1132f6d80c889f375b2e8 (patch) | |
tree | eed7f1dccb0d60a66e219a7366de2a5f9724099a /src/mesa/program | |
parent | 4f4b04b7c7ee1ce27da990190a740473db0f2ecb (diff) |
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 <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/mesa/program')
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index 5f00a8b2fd0..b298d076e5d 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -153,8 +153,7 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src) nir_intrinsic_instr *load = nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var); load->num_components = 4; - load->variables[0] = - nir_deref_var_create(b->shader, c->input_vars[prog_src->Index]); + load->variables[0] = nir_deref_var_create(load, c->input_vars[prog_src->Index]); nir_ssa_dest_init(&load->instr, &load->dest, 4, NULL); nir_instr_insert_after_cf_list(b->cf_node_list, &load->instr); @@ -918,7 +917,7 @@ ptn_add_output_stores(struct ptn_compile *c) nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_var); store->num_components = 4; store->variables[0] = - nir_deref_var_create(b->shader, c->output_vars[var->data.location]); + nir_deref_var_create(store, c->output_vars[var->data.location]); store->src[0].reg.reg = c->output_regs[var->data.location]; nir_instr_insert_after_cf_list(c->build.cf_node_list, &store->instr); } @@ -962,7 +961,7 @@ setup_registers_and_variables(struct ptn_compile *c) nir_intrinsic_instr *load_x = nir_intrinsic_instr_create(shader, nir_intrinsic_load_var); load_x->num_components = 1; - load_x->variables[0] = nir_deref_var_create(shader, var); + load_x->variables[0] = nir_deref_var_create(load_x, var); nir_ssa_dest_init(&load_x->instr, &load_x->dest, 1, NULL); nir_instr_insert_after_cf_list(b->cf_node_list, &load_x->instr); @@ -978,7 +977,7 @@ setup_registers_and_variables(struct ptn_compile *c) nir_intrinsic_instr *store = nir_intrinsic_instr_create(shader, nir_intrinsic_store_var); store->num_components = 4; - store->variables[0] = nir_deref_var_create(shader, fullvar); + store->variables[0] = nir_deref_var_create(store, fullvar); store->src[0] = nir_src_for_ssa(f001); nir_instr_insert_after_cf_list(b->cf_node_list, &store->instr); |