nir/clip_disable: write 0s instead of undefs for disabled clip planes
this should yield more reliable and ideally even correct results
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6563>
diff --git a/src/compiler/nir/nir_lower_clip_disable.c b/src/compiler/nir/nir_lower_clip_disable.c
index ae08645..102eab5 100644
--- a/src/compiler/nir/nir_lower_clip_disable.c
+++ b/src/compiler/nir/nir_lower_clip_disable.c
@@ -30,7 +30,7 @@
/**
* This pass uses the enabled clip planes from the rasterizer state to rewrite
- * vertex shader store operations and store an undef to the corresponding gl_ClipDistance[n]
+ * vertex shader store operations and store a 0 to the corresponding gl_ClipDistance[n]
* value if the plane is disabled
*/
@@ -45,7 +45,7 @@
if (clip_plane_enable & (1 << start))
nir_store_deref(b, deref, value, 1 << start);
else
- nir_store_deref(b, deref, nir_ssa_undef(b, 1, 32), 1 << start);
+ nir_store_deref(b, deref, nir_imm_int(b, 0), 1 << start);
return;
}
@@ -58,7 +58,7 @@
}
/* vulkan (and some drivers) provides no concept of enabling clip planes through api,
- * so we rewrite disabled clip planes to an undefined value in order to disable them
+ * so we rewrite disabled clip planes to a zero value in order to disable them
*/
static bool
lower_clip_plane_store(nir_intrinsic_instr *instr, unsigned clip_plane_enable, nir_builder *b)
@@ -84,7 +84,7 @@
if (clip_plane_enable & (1 << plane))
return false;
- nir_store_deref(b, deref, nir_ssa_undef(b, 1, 32), 1 << plane);
+ nir_store_deref(b, deref, nir_imm_int(b, 0), 1 << plane);
} else {
/* storing using a variable index */
nir_ssa_def *index = nir_ssa_for_src(b, deref->arr.index, 1);