From 34d81fa522887343db9d2dfb969c84ca6fb2cbee Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 19 Apr 2012 10:33:33 -0700 Subject: [PATCH] Fix bugs in tests. These two tests were walking past the end of the aFOO[] array, which in turn was leading to failures with the generic-16/c++ output path. --- tests/foreach-mask-1.ispc | 6 ++++-- tests/foreach-mask.ispc | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/foreach-mask-1.ispc b/tests/foreach-mask-1.ispc index 2f462b48..ee4b1b1e 100644 --- a/tests/foreach-mask-1.ispc +++ b/tests/foreach-mask-1.ispc @@ -10,8 +10,10 @@ export void f_f(uniform float RET[], uniform float aFOO[]) { // make sure we reset the func mask in the foreach loop... if ((int)aFOO[programIndex] & 1) - foreach (i = 0 ... programCount+3) - val[i] += aFOO[i] - 1; + foreach (i = 0 ... programCount+3) { + int ic = min(i, programCount-1); + val[i] += aFOO[ic] - 1 + i-ic; + } RET[programIndex] = val[3+programIndex]; } diff --git a/tests/foreach-mask.ispc b/tests/foreach-mask.ispc index 0d01b16a..f6000a71 100644 --- a/tests/foreach-mask.ispc +++ b/tests/foreach-mask.ispc @@ -5,8 +5,10 @@ export uniform int width() { return programCount; } // make sure we reset the func mask in the foreach loop... void update(uniform float val[], const uniform float a[]) { - foreach (i = 0 ... programCount+3) - val[i] += a[i] - 1; + foreach (i = 0 ... programCount+3) { + int ic = min(i, programCount-1); + val[i] += a[ic] - 1 + i-ic; + } } export void f_f(uniform float RET[], uniform float aFOO[]) {