compiler/nir: check whether var is an input in lower_fragcoord_wtrans
authorGert Wollny <gert.wollny@collabora.com>
Sun, 2 May 2021 12:41:21 +0000 (14:41 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 14 May 2021 13:26:13 +0000 (13:26 +0000)
Otherwise the lowering pass might try to lower any other load from
a deref if its data.location value happens to be zero.

Fixes: 418c4c0d7d48a42f475df1ffb93b3a33763e7a4a
  compiler/nir: extend lower_fragcoord_wtrans to support VARYING_SLOT_POS

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10577>

src/compiler/nir/nir_lower_fragcoord_wtrans.c

index ed630bb..25f93b4 100644 (file)
@@ -46,6 +46,9 @@ lower_fragcoord_wtrans_filter(const nir_instr *instr, UNUSED const void *_option
       return false;
 
    nir_variable *var = nir_intrinsic_get_var(intr, 0);
+   if (var->data.mode != nir_var_shader_in)
+      return false;
+
    return var->data.location == VARYING_SLOT_POS;
 }