aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-09-06 14:01:51 -0400
committerMarek Olšák <[email protected]>2019-09-11 10:59:27 -0400
commitb97c5edd7aa31fb531a330742a9e20064591fec2 (patch)
tree76f3c793aad9b7980bab417571a096b15a269491
parent1bb26562767ea2f623952d1a1db08bb9e70c1762 (diff)
prog_to_nir, tgsi_to_nir: make sure kill doesn't discard NaNs
Reviewed-by: Connor Abbott <[email protected]>
-rw-r--r--src/gallium/auxiliary/nir/tgsi_to_nir.c4
-rw-r--r--src/mesa/program/prog_to_nir.c3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index b70e608ddf7..a8c798f9015 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -1109,7 +1109,11 @@ ttn_kill(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
static void
ttn_kill_if(nir_builder *b, nir_op op, nir_alu_dest dest, nir_ssa_def **src)
{
+ /* flt must be exact, because NaN shouldn't discard. (apps rely on this) */
+ b->exact = true;
nir_ssa_def *cmp = nir_bany(b, nir_flt(b, src[0], nir_imm_float(b, 0.0)));
+ b->exact = false;
+
nir_intrinsic_instr *discard =
nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if);
discard->src[0] = nir_src_for_ssa(cmp);
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index a5ac37af908..84ba708d0be 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -456,7 +456,10 @@ ptn_lrp(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src)
static void
ptn_kil(nir_builder *b, nir_ssa_def **src)
{
+ /* flt must be exact, because NaN shouldn't discard. (apps rely on this) */
+ b->exact = true;
nir_ssa_def *cmp = nir_bany(b, nir_flt(b, src[0], nir_imm_float(b, 0.0)));
+ b->exact = false;
nir_intrinsic_instr *discard =
nir_intrinsic_instr_create(b->shader, nir_intrinsic_discard_if);