For values above integer accuracy in floats, val - floor(val) might
actually produce a value greater than 1. For such large floats, it's
reasonable to be imprecise, but it's unreasonable for FRC to return a
value that is not between 0 and 1.

Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 41b91e8..e5b767f 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -2512,7 +2512,8 @@ Converter::handleInstruction(const struct 
tgsi_full_instruction *insn)
          src0 = fetchSrc(0, c);
          val0 = getScratch();
          mkOp1(OP_FLOOR, TYPE_F32, val0, src0);
-         mkOp2(OP_SUB, TYPE_F32, dst0[c], src0, val0);
+         mkOp2(OP_SUB, TYPE_F32, val0, src0, val0);
+         mkOp1(OP_SAT, TYPE_F32, dst0[c], val0);
       }
       break;
    case TGSI_OPCODE_ROUND:
-- 
2.0.4

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

Reply via email to