Files
ispc/tests/half-1.ispc
Matt Pharr 46716aada3 Switch to unordered floating point compares.
In particular, this gives us desired behavior for NaNs (all compares
involving a NaN evaluate to true).  This in turn allows writing the
canonical isnan() function as "v != v".

Added isnan() to the standard library as well.
2012-06-20 13:25:53 -07:00

22 lines
516 B
Plaintext

export uniform int width() { return programCount; }
export void f_v(uniform float RET[]) {
float sum = 0;
int errors = 0;
for (uniform int i = 0; i <= 0xffff; ++i) {
uniform unsigned int16 h = i;
uniform float f = half_to_float(i);
h = float_to_half(f);
// may return a different value back for NaNs..
if (!isnan(f) && i != h)
++errors;
}
RET[programIndex] = errors;
}
export void result(uniform float RET[]) {
RET[programIndex] = 0;
}