prog_to_nir, tgsi_to_nir: make sure kill doesn't discard NaNs
authorMarek Olšák <marek.olsak@amd.com>
Fri, 6 Sep 2019 18:01:51 +0000 (14:01 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 11 Sep 2019 14:59:27 +0000 (10:59 -0400)
Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/gallium/auxiliary/nir/tgsi_to_nir.c
src/mesa/program/prog_to_nir.c

index b70e608ddf73d24d070016cb096816378ed8ebe6..a8c798f9015fbdeb719a510c91bd8d6a419cfe95 100644 (file)
@@ -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);
index a5ac37af9089ced7108cd9b50830190a1cf5833a..84ba708d0bec2d1cb7f77948c050be291dbcf5d1 100644 (file)
@@ -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);