From b416c08e86953e947654283c0b2ef10f9589f007 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 20 Oct 2022 17:49:21 -0700 Subject: [PATCH] freedreno/ir3: Drop unused view_zero/layer_zero lowering Previous patch removed the only remaining user. Signed-off-by: Rob Clark Part-of: --- src/freedreno/ir3/ir3_nir.c | 60 ---------------------------------- src/freedreno/ir3/ir3_shader.c | 8 ----- src/freedreno/ir3/ir3_shader.h | 10 ------ 3 files changed, 78 deletions(-) diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 266955298b9..c2c1acf5d5f 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -588,59 +588,6 @@ ir3_nir_post_finalize(struct ir3_shader *shader) ir3_optimize_loop(compiler, s); } -static bool -ir3_nir_lower_view_layer_id(nir_shader *nir, bool layer_zero, bool view_zero) -{ - unsigned layer_id_loc = ~0, view_id_loc = ~0; - nir_foreach_shader_in_variable (var, nir) { - if (var->data.location == VARYING_SLOT_LAYER) - layer_id_loc = var->data.driver_location; - if (var->data.location == VARYING_SLOT_VIEWPORT) - view_id_loc = var->data.driver_location; - } - - assert(!layer_zero || layer_id_loc != ~0); - assert(!view_zero || view_id_loc != ~0); - - bool progress = false; - nir_builder b; - - nir_foreach_function (func, nir) { - nir_builder_init(&b, func->impl); - - nir_foreach_block (block, func->impl) { - nir_foreach_instr_safe (instr, block) { - if (instr->type != nir_instr_type_intrinsic) - continue; - - nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - - if (intrin->intrinsic != nir_intrinsic_load_input) - continue; - - unsigned base = nir_intrinsic_base(intrin); - if (base != layer_id_loc && base != view_id_loc) - continue; - - b.cursor = nir_before_instr(&intrin->instr); - nir_ssa_def *zero = nir_imm_int(&b, 0); - nir_ssa_def_rewrite_uses(&intrin->dest.ssa, zero); - nir_instr_remove(&intrin->instr); - progress = true; - } - } - - if (progress) { - nir_metadata_preserve( - func->impl, nir_metadata_block_index | nir_metadata_dominance); - } else { - nir_metadata_preserve(func->impl, nir_metadata_all); - } - } - - return progress; -} - static bool lower_ucp_vs(struct ir3_shader_variant *so) { @@ -707,15 +654,8 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s) if (lower_ucp_vs(so)) { progress |= OPT(s, nir_lower_clip_vs, so->key.ucp_enables, false, true, NULL); } else if (s->info.stage == MESA_SHADER_FRAGMENT) { - bool layer_zero = - so->key.layer_zero && (s->info.inputs_read & VARYING_BIT_LAYER); - bool view_zero = - so->key.view_zero && (s->info.inputs_read & VARYING_BIT_VIEWPORT); - if (so->key.ucp_enables && !so->compiler->has_clip_cull) progress |= OPT(s, nir_lower_clip_fs, so->key.ucp_enables, true); - if (layer_zero || view_zero) - progress |= OPT(s, ir3_nir_lower_view_layer_id, layer_zero, view_zero); } /* Move large constant variables to the constants attached to the NIR diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 049b5d7f184..02e615c438f 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -507,14 +507,6 @@ ir3_setup_used_key(struct ir3_shader *shader) key->rasterflat = true; } - if (info->inputs_read & VARYING_BIT_LAYER) { - key->layer_zero = true; - } - - if (info->inputs_read & VARYING_BIT_VIEWPORT) { - key->view_zero = true; - } - /* Only used for deciding on behavior of * nir_intrinsic_load_barycentric_sample and the centroid demotion * on older HW. diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index a97a65a797a..726a3cab3dc 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -324,13 +324,6 @@ struct ir3_shader_key { * the limit: */ unsigned safe_constlen : 1; - - /* Whether gl_Layer must be forced to 0 because it isn't written. */ - unsigned layer_zero : 1; - - /* Whether gl_ViewportIndex must be forced to 0 because it isn't - * written. */ - unsigned view_zero : 1; }; uint32_t global; }; @@ -403,9 +396,6 @@ ir3_shader_key_changes_fs(struct ir3_shader_key *key, if (last_key->rasterflat != key->rasterflat) return true; - if (last_key->layer_zero != key->layer_zero) - return true; - if (last_key->ucp_enables != key->ucp_enables) return true;