Mesa (master): compiler/nir: extend lower_fragcoord_wtrans to support VARYING_SLOT_POS

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 17 12:59:41 UTC 2020


Module: Mesa
Branch: master
Commit: 418c4c0d7d48a42f475df1ffb93b3a33763e7a4a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=418c4c0d7d48a42f475df1ffb93b3a33763e7a4a

Author: Gert Wollny <gert.wollny at collabora.com>
Date:   Mon Jul  6 09:41:25 2020 +0200

compiler/nir: extend lower_fragcoord_wtrans to support VARYING_SLOT_POS

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
Reviewed-by: Andreas Baierl <ichgeh at imkreisrum.de>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6220>

---

 src/compiler/nir/nir_lower_fragcoord_wtrans.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_lower_fragcoord_wtrans.c b/src/compiler/nir/nir_lower_fragcoord_wtrans.c
index f469b955396..ed630bb7c21 100644
--- a/src/compiler/nir/nir_lower_fragcoord_wtrans.c
+++ b/src/compiler/nir/nir_lower_fragcoord_wtrans.c
@@ -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 *



More information about the mesa-commit mailing list