Mesa (master): freedreno/ir3: add view_zero to shader key
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Sep 15 16:32:22 UTC 2020
Module: Mesa
Branch: master
Commit: 52534c3a865298015711c948bc9f3408c5485aa4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=52534c3a865298015711c948bc9f3408c5485aa4
Author: Jonathan Marek <jonathan at marek.ca>
Date: Thu Jul 9 16:15:18 2020 -0400
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 <jonathan at marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5832>
---
src/freedreno/ir3/ir3_nir.c | 22 +++++++++++++---------
src/freedreno/ir3/ir3_shader.c | 4 ++++
src/freedreno/ir3/ir3_shader.h | 3 +++
3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 46c1d1cf7ba..f10ec8b9e87 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 519fafec900..b29a66a0071 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 db94e4f52c8..b87b9b437d0 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;
};
More information about the mesa-commit
mailing list