compiler/nir: extend lower_fragcoord_wtrans to support VARYING_SLOT_POS
authorGert Wollny <gert.wollny@collabora.com>
Mon, 6 Jul 2020 07:41:25 +0000 (09:41 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 17 Aug 2020 12:38:05 +0000 (12:38 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6220>

src/compiler/nir/nir_lower_fragcoord_wtrans.c

index f469b95539635188fc0621f472fd5306821ca656..ed630bb7c213df5e3f70070a7bb8bfb16436839e 100644 (file)
@@ -30,8 +30,6 @@
  *    gl_FragCoord.xyz = gl_FragCoord_orig.xyz
  *    gl_FragCoord.w = 1.0 / gl_FragCoord_orig.w
  *
- * To trigger the transformation, gl_FragCoord currently has to be treated
- * as a system value with PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL enabled.
  */
 
 static bool
@@ -41,7 +39,14 @@ lower_fragcoord_wtrans_filter(const nir_instr *instr, UNUSED const void *_option
       return false;
 
    nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-   return intr->intrinsic == nir_intrinsic_load_frag_coord;
+   if (intr->intrinsic == nir_intrinsic_load_frag_coord)
+      return true;
+
+   if (intr->intrinsic != nir_intrinsic_load_deref)
+      return false;
+
+   nir_variable *var = nir_intrinsic_get_var(intr, 0);
+   return var->data.location == VARYING_SLOT_POS;
 }
 
 static nir_ssa_def *