From 88db6f0a73cd988b14e95e5f506b4e5ac355f065 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 10 Apr 2013 15:25:18 -0700 Subject: tgsi/exec: fix the udiv and umod instructions Same as with llvmpipe: we can't be divind/moding by zero and we need to make sure that dividing/moding by zero produces 0xffffffff. Signed-off-by: Zack Rusin Reviewed-by: Brian Paul Reviewed-by: Jose Fonseca --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 05f749ed6c1..3de15730e75 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -3445,10 +3445,10 @@ micro_udiv(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, const union tgsi_exec_channel *src1) { - dst->u[0] = src0->u[0] / src1->u[0]; - dst->u[1] = src0->u[1] / src1->u[1]; - dst->u[2] = src0->u[2] / src1->u[2]; - dst->u[3] = src0->u[3] / src1->u[3]; + dst->u[0] = src1->u[0] ? src0->u[0] / src1->u[0] : ~0u; + dst->u[1] = src1->u[1] ? src0->u[1] / src1->u[1] : ~0u; + dst->u[2] = src1->u[2] ? src0->u[2] / src1->u[2] : ~0u; + dst->u[3] = src1->u[3] ? src0->u[3] / src1->u[3] : ~0u; } static void @@ -3490,10 +3490,10 @@ micro_umod(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, const union tgsi_exec_channel *src1) { - dst->u[0] = src0->u[0] % src1->u[0]; - dst->u[1] = src0->u[1] % src1->u[1]; - dst->u[2] = src0->u[2] % src1->u[2]; - dst->u[3] = src0->u[3] % src1->u[3]; + dst->u[0] = src1->u[0] ? src0->u[0] % src1->u[0] : ~0u; + dst->u[1] = src1->u[1] ? src0->u[1] % src1->u[1] : ~0u; + dst->u[2] = src1->u[2] ? src0->u[2] % src1->u[2] : ~0u; + dst->u[3] = src1->u[3] ? src0->u[3] % src1->u[3] : ~0u; } static void -- cgit v1.2.3