summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/tgsi
diff options
context:
space:
mode:
authorrconde <[email protected]>2014-09-17 18:30:23 +0200
committerRoland Scheidegger <[email protected]>2014-09-17 18:31:54 +0200
commitffeb77c7b0552a8624e46e65d6347240ac5ae84d (patch)
tree38ab1f9fe23e1310e018d7cc36ce7b84872cd31c /src/gallium/auxiliary/tgsi
parent4d996877ca8495dd9c683fd89f90c445781faf3b (diff)
gallivm,tgsi: fix idiv by zero crash
While the result of signed integer division by zero is undefined by glsl (and doesn't exist with d3d10), we must not crash, so need to make sure we don't get sigfpe much like udiv already does. Unlike udiv where we return 0xffffffff (as required by d3d10) there is no requirement right now to return anything specific so we use zero.
Diffstat (limited to 'src/gallium/auxiliary/tgsi')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 6dae3798a39..77948011ac7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -3343,10 +3343,10 @@ micro_idiv(union tgsi_exec_channel *dst,
const union tgsi_exec_channel *src0,
const union tgsi_exec_channel *src1)
{
- dst->i[0] = src0->i[0] / src1->i[0];
- dst->i[1] = src0->i[1] / src1->i[1];
- dst->i[2] = src0->i[2] / src1->i[2];
- dst->i[3] = src0->i[3] / src1->i[3];
+ dst->i[0] = src1->i[0] ? src0->i[0] / src1->i[0] : 0;
+ dst->i[1] = src1->i[1] ? src0->i[1] / src1->i[1] : 0;
+ dst->i[2] = src1->i[2] ? src0->i[2] / src1->i[2] : 0;
+ dst->i[3] = src1->i[3] ? src0->i[3] / src1->i[3] : 0;
}
static void