diff --git a/ctx.cpp b/ctx.cpp index 37e85749..eeb500cd 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -1691,7 +1691,7 @@ FunctionEmitContext::LoadInst(llvm::Value *ptr, llvm::Value *mask, else { // Otherwise we should have a varying ptr and it's time for a // gather. - return gather(ptr, ptrType, mask, name); + return gather(ptr, ptrType, GetFullMask(), name); } } @@ -2055,7 +2055,7 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr, assert(ptrType->IsVaryingType()); // We have a varying ptr (an array of pointers), so it's time to // scatter - scatter(value, ptr, ptrType, mask); + scatter(value, ptr, ptrType, GetFullMask()); } } diff --git a/tests/scatter-mask-1.ispc b/tests/scatter-mask-1.ispc new file mode 100644 index 00000000..e035cc43 --- /dev/null +++ b/tests/scatter-mask-1.ispc @@ -0,0 +1,15 @@ + +export uniform int width() { return programCount; } + +uniform float a[programCount]; + +export void f_f(uniform float RET[], uniform float aFOO[]) { + int index = aFOO[programIndex]-1; + if (index & 1) + a[index] = 1; + RET[programIndex] = a[programIndex]; +} + +export void result(uniform float RET[]) { + RET[programIndex] = (programIndex & 1) ? 1 : 0; +} diff --git a/tests/scatter-mask-2.ispc b/tests/scatter-mask-2.ispc new file mode 100644 index 00000000..f5351d8b --- /dev/null +++ b/tests/scatter-mask-2.ispc @@ -0,0 +1,19 @@ + +export uniform int width() { return programCount; } + +uniform float a[programCount]; + +static void foo(int index) { + a[index] = 1; +} + +export void f_f(uniform float RET[], uniform float aFOO[]) { + int index = aFOO[programIndex]-1; + if (index & 1) + foo(index); + RET[programIndex] = a[programIndex]; +} + +export void result(uniform float RET[]) { + RET[programIndex] = (programIndex & 1) ? 1 : 0; +}