Pointers can be either uniform or varying, and behave correspondingly. e.g.: "uniform float * varying" is a varying pointer to uniform float data in memory, and "float * uniform" is a uniform pointer to varying data in memory. Like other types, pointers are varying by default. Pointer-based expressions, & and *, sizeof, ->, pointer arithmetic, and the array/pointer duality all bahave as in C. Array arguments to functions are converted to pointers, also like C. There is a built-in NULL for a null pointer value; conversion from compile-time constant 0 values to NULL still needs to be implemented. Other changes: - Syntax for references has been updated to be C++ style; a useful warning is now issued if the "reference" keyword is used. - It is now illegal to pass a varying lvalue as a reference parameter to a function; references are essentially uniform pointers. This case had previously been handled via special case call by value return code. That path has been removed, now that varying pointers are available to handle this use case (and much more). - Some stdlib routines have been updated to take pointers as arguments where appropriate (e.g. prefetch and the atomics). A number of others still need attention. - All of the examples have been updated - Many new tests TODO: documentation
28 lines
696 B
Plaintext
28 lines
696 B
Plaintext
|
|
export uniform int width() { return programCount; }
|
|
|
|
export void f_v(uniform float RET[]) {
|
|
#define width 3
|
|
#define maxProgramCount 16
|
|
//CO const uniform int width = 3;
|
|
//CO const uniform int maxProgramCount = 16;
|
|
uniform float a[width*maxProgramCount], r[width*maxProgramCount];
|
|
for (uniform int i = 0; i < width*maxProgramCount; ++i)
|
|
a[i] = i;
|
|
|
|
float x=-1, y=-1, z=-1;
|
|
aos_to_soa3(a, 0, &x, &y, &z);
|
|
|
|
int errs = 0;
|
|
if (x != width * programIndex) ++errs;
|
|
if (y != 1 + width * programIndex) ++errs;
|
|
if (z != 2 + width * programIndex) ++errs;
|
|
|
|
RET[programIndex] = errs;
|
|
}
|
|
|
|
export void result(uniform float RET[]) {
|
|
RET[programIndex] = 0;
|
|
}
|
|
|