support of operators
This commit is contained in:
51
tests/operators2.ispc
Normal file
51
tests/operators2.ispc
Normal file
@@ -0,0 +1,51 @@
|
||||
int off;
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
struct S {
|
||||
float a;
|
||||
};
|
||||
|
||||
struct S operator+(struct S rr, struct S rv) {
|
||||
struct S c;
|
||||
c.a = rr.a / rv.a + 3;
|
||||
if (off == 1)
|
||||
c.a = 22;
|
||||
return c;
|
||||
}
|
||||
|
||||
struct S operator/(struct S rr, struct S rv) {
|
||||
struct S c;
|
||||
c.a = rr.a + rv.a + 10;
|
||||
if (off == 1)
|
||||
c.a = 33;
|
||||
return c;
|
||||
}
|
||||
|
||||
struct S a;
|
||||
struct S b;
|
||||
struct S d;
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[]) {
|
||||
int T = programIndex;
|
||||
a.a = aFOO[programIndex];
|
||||
b.a = -aFOO[programIndex];
|
||||
if (programIndex == 3)
|
||||
off = 1;
|
||||
else
|
||||
off = 0;
|
||||
if (T % 2)
|
||||
d = a + b;
|
||||
else
|
||||
d = a / b;
|
||||
|
||||
RET[programIndex] = d.a;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[4]) {
|
||||
if (programIndex % 2)
|
||||
RET[programIndex] = 2;
|
||||
else
|
||||
RET[programIndex] = 10;
|
||||
RET[3] = 22;
|
||||
}
|
||||
Reference in New Issue
Block a user