Files
ispc/tests/packed-store-2.ispc
Matt Pharr d2d5858be1 It is no longer legal to initialize arrays and structs with single
scalar values (that ispc used to smear across the array/struct
elements).  Now, initializers in variable declarations must be
{ }-delimited lists, with one element per struct member or array
element, respectively.

There were a few problems with the previous implementation of the
functionality to initialize from scalars.  First, the expression
would be evaluated once per value initialized, so if it had side-effects,
the wrong thing would happen.  Next, for large multidimensional arrays,
the generated code would be a long series of move instructions, rather
than loops (and this in turn made LLVM take a long time.)

While both of these problems are fixable, it's a non-trivial
amount of re-plumbing for a questionable feature anyway.

Fixes issue #50.
2011-07-01 13:45:58 +01:00

20 lines
554 B
Plaintext

export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
float a = aFOO[programIndex];
uniform int pack[2+programCount];
for (uniform int i = 0; i < 2+programCount; ++i)
pack[i] = 0;
if ((int)a & 1)
packed_store_active(pack, 2, a);
RET[programIndex] = pack[programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = 0;
uniform int val = 1;
for (uniform int i = 2; i < 2+programCount/2; ++i, val += 2)
RET[i] = val;
}