nir: Add a face_sysval argument to nir_lower_two_sided_color
authorIcecream95 <ixn@keemail.me>
Tue, 14 Jul 2020 10:17:34 +0000 (22:17 +1200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 17 Jul 2020 14:50:26 +0000 (14:50 +0000)
This is needed for handling drivers that use an input for loading the
face, for example Panfrost with Midgard GPUs.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: Urja Rannikko <urjaman@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5915>

src/broadcom/compiler/vir.c
src/compiler/nir/nir.h
src/compiler/nir/nir_lower_two_sided_color.c
src/freedreno/ir3/ir3_nir.c
src/gallium/drivers/vc4/vc4_program.c
src/mesa/state_tracker/st_program.c

index d26a3250ead0659a91e2d46111699181eade1d89..44ee75697df0e1a6a85812efd5949a07eb1ce310 100644 (file)
@@ -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);
index e0caedaf5f491a74ee3160672e8c8069bcd74fc8..281e290f447ed0e051d95eb686423c4bf618a141 100644 (file)
@@ -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);
 
index 04bb5d1ec76e7e23e7692cac75d67976b4259183..1cab733f5d497bcbe61f957cf9e90f6839cbee1e 100644 (file)
@@ -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,
index 74013aa3bd1255353766f78d3a81c032fc7e191d..c779a57f7c5176c85161137b5dffb50b15f2aa62 100644 (file)
@@ -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;
        }
 
index 3ad81a0590958d29b3258c7e90aa964b366cc57f..6a429d427b10a05a85b90f85c7e40820dbd104c1 100644 (file)
@@ -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);
index d0e16cf16a858d3604af5d7cbf7a54243b93a59b..97861cc404e7b9a52b66724e7a532369935e594b 100644 (file)
@@ -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;
       }