diff options
author | Jason Ekstrand <[email protected]> | 2015-09-09 13:18:29 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-09-11 09:21:04 -0700 |
commit | 8c8fc5f8336c8c79e5890265ae6c03271aa94075 (patch) | |
tree | 862f8a0cad00a534a147ccffc70741f71a3428e6 /src/glsl/nir/nir.c | |
parent | 794355e77167291a3acc8d42249c760c24f54f38 (diff) |
nir: Fix a bunch of ralloc parenting errors
As of a10d4937, we would really like things associated with an instruction
to be allocated out of that instruction and not out of the shader. In
particular, you should be passing the instruction that will ultimately be
holding the source into nir_src_copy rather than an arbitrary memory
context.
We also change the prototypes of nir_dest_copy and nir_alu_src/dest_copy to
explicitly take an instruction so we catch this earlier in the future.
Cc: "11.0" <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir.c')
-rw-r--r-- | src/glsl/nir/nir.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c index 1dc7e12445f..fd675322b12 100644 --- a/src/glsl/nir/nir.c +++ b/src/glsl/nir/nir.c @@ -153,7 +153,7 @@ void nir_src_copy(nir_src *dest, const nir_src *src, void *mem_ctx) } } -void nir_dest_copy(nir_dest *dest, const nir_dest *src, void *mem_ctx) +void nir_dest_copy(nir_dest *dest, const nir_dest *src, nir_instr *instr) { /* Copying an SSA definition makes no sense whatsoever. */ assert(!src->is_ssa); @@ -163,17 +163,18 @@ void nir_dest_copy(nir_dest *dest, const nir_dest *src, void *mem_ctx) dest->reg.base_offset = src->reg.base_offset; dest->reg.reg = src->reg.reg; if (src->reg.indirect) { - dest->reg.indirect = ralloc(mem_ctx, nir_src); - nir_src_copy(dest->reg.indirect, src->reg.indirect, mem_ctx); + dest->reg.indirect = ralloc(instr, nir_src); + nir_src_copy(dest->reg.indirect, src->reg.indirect, instr); } else { dest->reg.indirect = NULL; } } void -nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, void *mem_ctx) +nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, + nir_alu_instr *instr) { - nir_src_copy(&dest->src, &src->src, mem_ctx); + nir_src_copy(&dest->src, &src->src, &instr->instr); dest->abs = src->abs; dest->negate = src->negate; for (unsigned i = 0; i < 4; i++) @@ -181,9 +182,10 @@ nir_alu_src_copy(nir_alu_src *dest, const nir_alu_src *src, void *mem_ctx) } void -nir_alu_dest_copy(nir_alu_dest *dest, const nir_alu_dest *src, void *mem_ctx) +nir_alu_dest_copy(nir_alu_dest *dest, const nir_alu_dest *src, + nir_alu_instr *instr) { - nir_dest_copy(&dest->dest, &src->dest, mem_ctx); + nir_dest_copy(&dest->dest, &src->dest, &instr->instr); dest->write_mask = src->write_mask; dest->saturate = src->saturate; } @@ -1210,14 +1212,14 @@ nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx) nir_foreach_use_safe(def, use_src) { nir_instr *src_parent_instr = use_src->parent_instr; list_del(&use_src->use_link); - nir_src_copy(use_src, &new_src, mem_ctx); + nir_src_copy(use_src, &new_src, src_parent_instr); src_add_all_uses(use_src, src_parent_instr, NULL); } nir_foreach_if_use_safe(def, use_src) { nir_if *src_parent_if = use_src->parent_if; list_del(&use_src->use_link); - nir_src_copy(use_src, &new_src, mem_ctx); + nir_src_copy(use_src, &new_src, src_parent_if); src_add_all_uses(use_src, NULL, src_parent_if); } } |