From: Icecream95 Date: Tue, 14 Jul 2020 10:17:34 +0000 (+1200) Subject: nir: Add a face_sysval argument to nir_lower_two_sided_color X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=314ba5e17450c8c14c2191bcd5675a9eaaac69d8;p=mesa.git nir: Add a face_sysval argument to nir_lower_two_sided_color This is needed for handling drivers that use an input for loading the face, for example Panfrost with Midgard GPUs. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rob Clark Tested-by: Urja Rannikko Part-of: --- diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c index d26a3250ead..44ee75697df 100644 --- a/src/broadcom/compiler/vir.c +++ b/src/broadcom/compiler/vir.c @@ -939,7 +939,7 @@ static void v3d_nir_lower_fs_late(struct v3d_compile *c) { if (c->fs_key->light_twoside) - NIR_PASS_V(c->s, nir_lower_two_sided_color); + NIR_PASS_V(c->s, nir_lower_two_sided_color, true); if (c->fs_key->clamp_color) NIR_PASS_V(c->s, nir_lower_clamp_color_outputs); diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index e0caedaf5f4..281e290f447 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4374,7 +4374,7 @@ void nir_lower_point_size_mov(nir_shader *shader, bool nir_lower_frexp(nir_shader *nir); -void nir_lower_two_sided_color(nir_shader *shader); +void nir_lower_two_sided_color(nir_shader *shader, bool face_sysval); bool nir_lower_clamp_color_outputs(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_two_sided_color.c b/src/compiler/nir/nir_lower_two_sided_color.c index 04bb5d1ec76..1cab733f5d4 100644 --- a/src/compiler/nir/nir_lower_two_sided_color.c +++ b/src/compiler/nir/nir_lower_two_sided_color.c @@ -195,7 +195,7 @@ nir_lower_two_sided_color_impl(nir_function_impl *impl, } void -nir_lower_two_sided_color(nir_shader *shader) +nir_lower_two_sided_color(nir_shader *shader, bool face_sysval) { lower_2side_state state = { .shader = shader, diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index 74013aa3bd1..c779a57f7c5 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -412,7 +412,7 @@ ir3_nir_lower_variant(struct ir3_shader_variant *so, nir_shader *s) progress |= OPT(s, ir3_nir_lower_layer_id); } if (so->key.color_two_side) { - OPT_V(s, nir_lower_two_sided_color); + OPT_V(s, nir_lower_two_sided_color, true); progress = true; } diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 3ad81a05909..6a429d427b1 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -2304,7 +2304,7 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage, NIR_PASS_V(c->s, nir_lower_tex, &tex_options); if (c->fs_key && c->fs_key->light_twoside) - NIR_PASS_V(c->s, nir_lower_two_sided_color); + NIR_PASS_V(c->s, nir_lower_two_sided_color, true); if (c->vs_key && c->vs_key->clamp_color) NIR_PASS_V(c->s, nir_lower_clamp_color_outputs); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index d0e16cf16a8..97861cc404e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1278,7 +1278,8 @@ st_create_fp_variant(struct st_context *st, } if (key->lower_two_sided_color) { - NIR_PASS_V(state.ir.nir, nir_lower_two_sided_color); + bool face_sysval = st->ctx->Const.GLSLFrontFacingIsSysVal; + NIR_PASS_V(state.ir.nir, nir_lower_two_sided_color, face_sysval); finalize = true; }