From 56fc791b3190be2a9a2295b0e6245687645c9b84 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Sun, 15 Dec 2019 18:09:46 +0100 Subject: [PATCH] etnaviv: use nir_lower_clip_halfz instead of open-coding We already have a helper for this, so let's use that instead of rolling our own version. Reviewed-by: Jonathan Marek Tested-by: Paul Cercueil --- .../drivers/etnaviv/etnaviv_compiler_nir.c | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c index c481b890456..7934eb0490e 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c +++ b/src/gallium/drivers/etnaviv/etnaviv_compiler_nir.c @@ -97,26 +97,6 @@ etna_lower_io(nir_shader *shader, struct etna_shader_variant *v) } break; case nir_intrinsic_store_deref: { nir_deref_instr *deref = nir_src_as_deref(intr->src[0]); - if (shader->info.stage == MESA_SHADER_VERTEX && - v->shader->specs->vs_need_z_div && - deref->var->data.location == VARYING_SLOT_POS) { - - assert(deref->deref_type == nir_deref_type_var); - - b.cursor = nir_before_instr(instr); - - nir_ssa_def *out[4]; - out[0] = nir_channel(&b, intr->src[1].ssa, 0); - out[1] = nir_channel(&b, intr->src[1].ssa, 1); - out[2] = nir_fmul_imm(&b, nir_fadd(&b, nir_channel(&b, intr->src[1].ssa, 2), - nir_channel(&b, intr->src[1].ssa, 3)), - 0.5f); - out[3] = nir_channel(&b, intr->src[1].ssa, 3); - - nir_instr_rewrite_src(instr, &intr->src[1], - nir_src_for_ssa(nir_vec(&b, out, 4))); - } - if (shader->info.stage != MESA_SHADER_FRAGMENT || !v->key.frag_rb_swap) break; @@ -773,6 +753,9 @@ etna_compile_shader_nir(struct etna_shader_variant *v) OPT_V(s, etna_lower_io, v); + if (v->shader->specs->vs_need_z_div) + NIR_PASS_V(s, nir_lower_clip_halfz); + /* lower pre-halti2 to float (halti0 has integers, but only scalar..) */ if (c->specs->halti < 2) { /* use opt_algebraic between int_to_float and boot_to_float because -- 2.30.2