[Mesa-dev] [PATCH 1/2] tgsi/exec: fix the udiv and umod instructions
Zack Rusin
zackr at vmware.com
Wed Apr 10 15:33:27 PDT 2013
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 <zackr at vmware.com>
---
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 8579d8a..b8de5fb 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] : -1;
+ dst->u[1] = src1->u[1] ? src0->u[1] / src1->u[1] : -1;
+ dst->u[2] = src1->u[2] ? src0->u[2] / src1->u[2] : -1;
+ dst->u[3] = src1->u[3] ? src0->u[3] / src1->u[3] : -1;
}
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] : -1;
+ dst->u[1] = src1->u[1] ? src0->u[1] % src1->u[1] : -1;
+ dst->u[2] = src1->u[2] ? src0->u[2] % src1->u[2] : -1;
+ dst->u[3] = src1->u[3] ? src0->u[3] % src1->u[3] : -1;
}
static void
--
1.7.10.4
More information about the mesa-dev
mailing list