From: Jonathan Marek Date: Thu, 9 Jul 2020 20:15:18 +0000 (-0400) Subject: freedreno/ir3: add view_zero to shader key X-Git-Tag: upstream/21.0.0~5387 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=52534c3a865298015711c948bc9f3408c5485aa4;p=platform%2Fupstream%2Fmesa.git freedreno/ir3: add view_zero to shader key Does the same thing as layer_zero, but for VARYING_SLOT_VIEWPORT. Signed-off-by: Jonathan Marek Part-of: --- diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 46c1d1c..f10ec8b 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -320,17 +320,18 @@ ir3_nir_post_finalize(struct ir3_compiler *compiler, nir_shader *s) } static bool -ir3_nir_lower_layer_id(nir_shader *nir) +ir3_nir_lower_view_layer_id(nir_shader *nir, bool layer_zero, bool view_zero) { - unsigned layer_id_loc = ~0; + unsigned layer_id_loc = ~0, view_id_loc = ~0; nir_foreach_shader_in_variable(var, nir) { - if (var->data.location == VARYING_SLOT_LAYER) { + if (var->data.location == VARYING_SLOT_LAYER) layer_id_loc = var->data.driver_location; - break; - } + if (var->data.location == VARYING_SLOT_VIEWPORT) + view_id_loc = var->data.driver_location; } - assert(layer_id_loc != ~0); + assert(!layer_zero || layer_id_loc != ~0); + assert(!view_zero || view_id_loc != ~0); bool progress = false; nir_builder b; @@ -350,7 +351,7 @@ ir3_nir_lower_layer_id(nir_shader *nir) continue; unsigned base = nir_intrinsic_base(intrin); - if (base != layer_id_loc) + if (base != layer_id_loc && base != view_id_loc) continue; b.cursor = nir_before_instr(&intrin->instr); @@ -417,12 +418,15 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s) if (so->key.vclamp_color) progress |= OPT(s, nir_lower_clamp_color_outputs); } 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) progress |= OPT(s, nir_lower_clip_fs, so->key.ucp_enables, false); if (so->key.fclamp_color) progress |= OPT(s, nir_lower_clamp_color_outputs); - if (so->key.layer_zero && (s->info.inputs_read & VARYING_BIT_LAYER)) - progress |= OPT(s, ir3_nir_lower_layer_id); + if (layer_zero || view_zero) + progress |= OPT(s, ir3_nir_lower_view_layer_id, layer_zero, view_zero); } if (so->key.color_two_side) { OPT_V(s, nir_lower_two_sided_color, true); diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c index 519fafe..b29a66a 100644 --- a/src/freedreno/ir3/ir3_shader.c +++ b/src/freedreno/ir3/ir3_shader.c @@ -356,6 +356,10 @@ ir3_setup_used_key(struct ir3_shader *shader) key->layer_zero = true; } + if (info->inputs_read & VARYING_BIT_VIEWPORT) { + key->view_zero = true; + } + if ((info->outputs_written & ~(FRAG_RESULT_DEPTH | FRAG_RESULT_STENCIL | FRAG_RESULT_SAMPLE_MASK)) != 0) { diff --git a/src/freedreno/ir3/ir3_shader.h b/src/freedreno/ir3/ir3_shader.h index db94e4f..b87b9b4 100644 --- a/src/freedreno/ir3/ir3_shader.h +++ b/src/freedreno/ir3/ir3_shader.h @@ -318,6 +318,9 @@ struct ir3_shader_key { /* 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; };