Now, if a struct member has an explicit 'uniform' or 'varying' qualifier, then that member has that variability, regardless of the variability of the struct's variability. Members without 'uniform' or 'varying' have unbound variability, and in turn inherit the variability of the struct. As a result of this, now structs can properly be 'varying' by default, just like all the other types, while still having sensible semantics.
35 lines
805 B
Plaintext
35 lines
805 B
Plaintext
|
|
struct Vector { float x, y, z; };
|
|
|
|
struct Ray { Vector o; float t; Vector d; };
|
|
|
|
export uniform int width() { return programCount; }
|
|
|
|
void init(varying Ray rays[], uniform int count, float v) {
|
|
for (uniform int i = 0; i < count; ++i) {
|
|
rays[i].o.x = programIndex;
|
|
rays[i].o.y = v;
|
|
rays[i].o.z = -1234;
|
|
rays[i].t = 42;
|
|
rays[i].d.x = 2*v;
|
|
rays[i].d.y = 3*v;
|
|
rays[i].d.z = 4*v;
|
|
}
|
|
}
|
|
|
|
void zero_dx(Ray &r) {
|
|
r.d.x = 0;
|
|
}
|
|
|
|
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
|
float v = aFOO[programIndex];
|
|
Ray rays[10];
|
|
init(rays, 10, v);
|
|
zero_dx(rays[b]);
|
|
RET[programIndex] = rays[5].d.x + rays[5].d.y;
|
|
}
|
|
|
|
export void result(uniform float RET[]) {
|
|
RET[programIndex] = 3 + 3*programIndex;
|
|
}
|