diff --git a/expr.cpp b/expr.cpp index f62d5497..cdf4388c 100644 --- a/expr.cpp +++ b/expr.cpp @@ -3794,7 +3794,7 @@ IndexExpr::GetType() const { elementType = sequentialType->GetElementType(); } - if (indexType->IsUniformType()) + if (indexType->IsUniformType() && baseExprType->IsUniformType()) // If the index is uniform, the resulting type is just whatever the // element type is return elementType; @@ -3904,7 +3904,8 @@ IndexExpr::GetLValueType() const { const PointerType *pt = dynamic_cast(baseExprLValueType->GetBaseType()); Assert(pt != NULL); - if (baseExprLValueType->IsUniformType() && indexType->IsUniformType()) + if (baseExprLValueType->IsUniformType() && indexType->IsUniformType() && + pt->IsVaryingType() == false) return PointerType::GetUniform(pt->GetBaseType()); else return PointerType::GetVarying(pt->GetBaseType()); diff --git a/tests/ptr-varying-unif-index.ispc b/tests/ptr-varying-unif-index.ispc new file mode 100644 index 00000000..9be232a4 --- /dev/null +++ b/tests/ptr-varying-unif-index.ispc @@ -0,0 +1,14 @@ + +export uniform int width() { return programCount; } + + +export void f_f(uniform float RET[], uniform float aFOO[]) { + uniform float buf[programCount]; + uniform float * varying ptr = &buf[programCount - 1 - programIndex]; + ptr[0] = programIndex; + RET[programIndex] = buf[programIndex]; +} + +export void result(uniform float RET[]) { + RET[programIndex] = programCount - 1 - programIndex; +}