We now follow C's approach of evaluating these: we don't evaluate the second expression in the operator if the value of the first one determines the overall result. Thus, these can now be used idiomatically like (index < limit && array[index] > 0) and such. For varying expressions, the mask is set appropriately when evaluating the second expression. (For expressions that can be determined to be both simple and safe to evaluate with the mask all off, we still evaluate both sides and compute the logical op result directly, which saves a number of branches and tests. However, the effect of this should never be visible to the programmer.) Issue #4.
25 lines
535 B
Plaintext
25 lines
535 B
Plaintext
|
|
export uniform int width() { return programCount; }
|
|
|
|
uniform int * uniform ptr;
|
|
|
|
bool crashEven() {
|
|
if (programIndex & 1)
|
|
return true;
|
|
else
|
|
return (*ptr > 0);
|
|
}
|
|
|
|
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
|
float a = aFOO[programIndex];
|
|
float a0 = aFOO[0], a1 = aFOO[1];
|
|
if (((programIndex & 1) == 0) || crashEven())
|
|
RET[programIndex] = 1;
|
|
else
|
|
RET[programIndex] = 0;
|
|
}
|
|
|
|
export void result(uniform float RET[]) {
|
|
RET[programIndex] = 1;
|
|
}
|