diff options
author | Jason Ekstrand <[email protected]> | 2018-03-19 13:43:54 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-06-22 20:15:54 -0700 |
commit | 82c498510eeaa6644e1646e138c86fddffdc9f1f (patch) | |
tree | 2ea75931885ecdb159e2f1391c770ed14b477baf /src/mesa | |
parent | 2c7b8929094064086bb6af4dcda1083b6ac4ad1d (diff) |
prog/nir: Use deref instructions for params
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Acked-by: Rob Clark <[email protected]>
Acked-by: Bas Nieuwenhuizen <[email protected]>
Acked-by: Dave Airlie <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/program/prog_to_nir.c | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c index cd874e489f3..14e57b6c6a1 100644 --- a/src/mesa/program/prog_to_nir.c +++ b/src/mesa/program/prog_to_nir.c @@ -164,43 +164,14 @@ ptn_get_src(struct ptn_compile *c, const struct prog_src_register *prog_src) case PROGRAM_STATE_VAR: { assert(c->parameters != NULL); - nir_intrinsic_instr *load = - nir_intrinsic_instr_create(b->shader, nir_intrinsic_load_var); - nir_ssa_dest_init(&load->instr, &load->dest, 4, 32, NULL); - load->num_components = 4; - - load->variables[0] = nir_deref_var_create(load, c->parameters); - nir_deref_array *deref_arr = - nir_deref_array_create(load->variables[0]); - deref_arr->deref.type = glsl_vec4_type(); - load->variables[0]->deref.child = &deref_arr->deref; - - if (prog_src->RelAddr) { - deref_arr->deref_array_type = nir_deref_array_type_indirect; - - nir_alu_src addr_src = { NIR_SRC_INIT }; - addr_src.src = nir_src_for_reg(c->addr_reg); - nir_ssa_def *reladdr = nir_imov_alu(b, addr_src, 1); - - if (prog_src->Index < 0) { - /* This is a negative offset which should be added to the address - * register's value. - */ - reladdr = nir_iadd(b, reladdr, nir_imm_int(b, prog_src->Index)); - - deref_arr->base_offset = 0; - } else { - deref_arr->base_offset = prog_src->Index; - } - deref_arr->indirect = nir_src_for_ssa(reladdr); - } else { - deref_arr->deref_array_type = nir_deref_array_type_direct; - deref_arr->base_offset = prog_src->Index; - } + nir_deref_instr *deref = nir_build_deref_var(b, c->parameters); - nir_builder_instr_insert(b, &load->instr); + nir_ssa_def *index = nir_imm_int(b, prog_src->Index); + if (prog_src->RelAddr) + index = nir_iadd(b, index, nir_load_reg(b, c->addr_reg)); + deref = nir_build_deref_array(b, deref, nir_channel(b, index, 0)); - src.src = nir_src_for_ssa(&load->dest.ssa); + src.src = nir_src_for_ssa(nir_load_deref(b, deref)); break; } default: |