Add support for in-memory half float data. Fixes issue #10

This commit is contained in:
Matt Pharr
2011-07-21 15:55:45 +01:00
parent 96d40327d0
commit 8ef3df57c5
6 changed files with 349 additions and 2 deletions

21
tests/half-1.ispc Normal file
View File

@@ -0,0 +1,21 @@
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 (f == f && i != h)
++errors;
}
RET[programIndex] = errors;
}
export void result(uniform float RET[]) {
RET[programIndex] = 0;
}

21
tests/half.ispc Normal file
View File

@@ -0,0 +1,21 @@
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) {
unsigned int16 h = i;
float f = half_to_float(i);
h = float_to_half(f);
// may return a different value back for NaNs..
if (f == f && i != h)
++errors;
}
RET[programIndex] = errors;
}
export void result(uniform float RET[]) {
RET[programIndex] = 0;
}