Add support for int8/int16 types. Addresses issues #9 and #42.

This commit is contained in:
Matt Pharr
2011-07-21 06:57:40 +01:00
parent 2d573acd17
commit bba7211654
64 changed files with 2317 additions and 885 deletions

View File

@@ -8,7 +8,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform float x[47][47];
for (uniform int i = 0; i < 47; ++i)
for (uniform int j = 0; j < 47; ++j)
x[i][j] = 2;
x[i][j] = 2+b-5;
// all are 2 except (3,4) = 0, (1,4) = 1, (2,4) = 1, (4,4) = 1
if (a == 3.)

View File

@@ -7,7 +7,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform float x[47][47];
for (uniform int i = 0; i < 47; ++i)
for (uniform int j = 0; j < 47; ++j)
x[i][j] = 2;
x[i][j] = 2+b-5;
// all are 2 except (4,2) = 0, (4,...) = 1, (4,programCount-1)=2
if (a == 3.)

View File

@@ -8,7 +8,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform float x[47][47];
for (uniform int i = 0; i < 47; ++i)
for (uniform int j = 0; j < 47; ++j)
x[i][j] = 2;
x[i][j] = 2+b-5;
x[a][b-1] = 0;
RET[programIndex] = x[2][a];

12
tests/broadcast-2.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
int16 a = aFOO[programIndex];
int16 b = broadcast(a, 2);
RET[programIndex] = b;
}
export void result(uniform float RET[]) {
RET[programIndex] = 3;
}

12
tests/broadcast-3.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 a = aFOO[programIndex];
int8 br = broadcast(a, (uniform int)b-2);
RET[programIndex] = br;
}
export void result(uniform float RET[]) {
RET[programIndex] = 4;
}

19
tests/gather-int16-1.ispc Normal file
View File

@@ -0,0 +1,19 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int16 x[programCount];
x[programIndex] = programIndex;
int a = aFOO[programIndex]-1;
unsigned int16 v;
if (programIndex < 2)
v = x[a];
else
v = 2;
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2;
RET[0] = 0;
RET[1] = 1;
}

13
tests/gather-int16.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int16 x[programCount];
x[programIndex] = programIndex;
int a = aFOO[programIndex]-1;
unsigned int16 v = x[a];
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = programIndex;
}

19
tests/gather-int8-1.ispc Normal file
View File

@@ -0,0 +1,19 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int8 x[programCount];
x[programIndex] = programIndex;
int a = aFOO[programIndex]-1;
unsigned int8 v;
if (programIndex < 2)
v = x[a];
else
v = 2;
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2;
RET[0] = 0;
RET[1] = 1;
}

13
tests/gather-int8.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int8 x[programCount];
x[programIndex] = programIndex;
int a = aFOO[programIndex]-1;
unsigned int8 v = x[a];
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = programIndex;
}

12
tests/int16-wrap.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float bb) {
unsigned int16 a = aFOO[programIndex], b = bb;
RET[programIndex] = ((unsigned int16)4000*a)+b;
}
export void result(uniform float RET[]) {
RET[programIndex] = (((4000*(programIndex+1))&0xffff)+5)&0xffff;
}

12
tests/int8-wrap.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float bb) {
unsigned int8 a = aFOO[programIndex], b = bb;
RET[programIndex] = ((unsigned int8)100*a)+b;
}
export void result(uniform float RET[]) {
RET[programIndex] = (((100*(programIndex+1))&0xff)+5)&0xff;
}

View File

@@ -1,13 +1,17 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[9] = { 0x00020001, 0x00040003, 0x00060005, 0x00080007,
0x000a0009, 0x000c000b, 0x000e000d, 0x0010000f,
0x00120011 };
unsigned int v = load_from_int16(x, 1);
uniform int16 x[programCount];
x[programIndex] = aFOO[programIndex];
unsigned int16 v = 0;
if (programIndex & 1)
v = x[programIndex];
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2+programIndex;
if (programIndex & 1)
RET[programIndex] = 1+programIndex;
else
RET[programIndex] = 0;
}

View File

@@ -1,9 +1,9 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[8] = { 0x00020001, 0x00040003, 0x00060005, 0x00080007,
0x000a0009, 0x000c000b, 0x000e000d, 0x0010000f };
unsigned int v = load_from_int16(x, 0);
uniform int16 x[programCount];
x[programIndex] = aFOO[programIndex];
unsigned int16 v = x[programIndex];
RET[programIndex] = v;
}

View File

@@ -1,12 +1,17 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[5] = { 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d,
0x14131211 };
unsigned int v = load_from_int8(x, 2);
uniform int8 x[programCount];
x[programIndex] = aFOO[programIndex];
unsigned int8 v = 0;
if (programIndex & 1)
v = x[programIndex];
RET[programIndex] = v;
}
export void result(uniform float RET[]) {
RET[programIndex] = 3+programIndex;
if (programIndex & 1)
RET[programIndex] = 1+programIndex;
else
RET[programIndex] = 0;
}

View File

@@ -1,8 +1,9 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[4] = { 0x04030201, 0x08070605, 0x0c0b0a09, 0x100f0e0d };
unsigned int v = load_from_int8(x, 0);
uniform int8 x[programCount];
x[programIndex] = aFOO[programIndex];
unsigned int8 v = x[programIndex];
RET[programIndex] = v;
}

View File

@@ -16,7 +16,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform Bar bar;
for (uniform int i = 0; i < 6; ++i)
for (uniform int j = 0; j < 18; ++j)
bar.foo[i].f[j] = 2.;
bar.foo[i].f[j] = 2.+b-5;
bar.foo[5].f[a] = a;
RET[programIndex] = bar.foo[b].f[a];

View File

@@ -1,8 +1,6 @@
export uniform int width() { return programCount; }
struct Foo {
float f[6];
};
@@ -16,7 +14,7 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform Bar bar;
for (uniform int i = 0; i < 6; ++i)
for (uniform int j = 0; j < 6; ++j)
bar.foo[i].f[j] = 2.;
bar.foo[i].f[j] = 2.+b-5;
RET[programIndex] = bar.foo[b].f[b];
}

View File

@@ -4,7 +4,7 @@ export uniform int width() { return programCount; }
export void f_fu(uniform float ret[], uniform float aa[], uniform float b) {
uniform float foo[16];
for (uniform int i = 0; i < 16; ++i)
foo[i] = 1;
foo[i] = i;
uniform int i = 0;
foo[i++] += 1;

View File

@@ -6,10 +6,10 @@ void inc(reference float v) { ++v; }
export void f_fu(uniform float ret[], uniform float aa[], uniform float b) {
uniform float foo[32];
for (uniform int i = 0; i < 32; ++i)
foo[i] = 10;
foo[i] = 10+i;
int a = (int)aa[programIndex];
inc(foo[a]);
ret[programIndex] = foo[programIndex];
ret[programIndex] = foo[programIndex]-programIndex;
}
export void result(uniform float ret[]) {

12
tests/rotate-5.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 a = aFOO[programIndex];
int8 rot = rotate(a, 2);
RET[programIndex] = rot;
}
export void result(uniform float RET[]) {
RET[programIndex] = 1 + (programIndex + 2) % programCount;
}

12
tests/rotate-6.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int16 a = aFOO[programIndex];
int16 rot = rotate(a, -1);
RET[programIndex] = rot;
}
export void result(uniform float RET[]) {
RET[programIndex] = 1 + (programIndex + programCount - 1) % programCount;
}

View File

@@ -0,0 +1,17 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int16 x[programCount];
x[programIndex] = -1;
int a = aFOO[programIndex]-1;
if (programIndex < 3)
x[a] = programIndex;
RET[programIndex] = x[programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = -1;
RET[0] = 0;
RET[1] = 1;
RET[2] = 2;
}

13
tests/scatter-int16.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int16 x[programCount];
x[programIndex] = 0;
int a = aFOO[programIndex]-1;
x[a] = programIndex;
RET[programIndex] = x[programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = programIndex;
}

17
tests/scatter-int8-1.ispc Normal file
View File

@@ -0,0 +1,17 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int8 x[programCount];
x[programIndex] = -1;
int a = aFOO[programIndex]-1;
if (programIndex < 3)
x[a] = programIndex;
RET[programIndex] = x[programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = -1;
RET[0] = 0;
RET[1] = 1;
RET[2] = 2;
}

13
tests/scatter-int8.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int8 x[programCount];
x[programIndex] = 0;
int a = aFOO[programIndex]-1;
x[a] = programIndex;
RET[programIndex] = x[programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = programIndex;
}

12
tests/shuffle-3.ispc Normal file
View File

@@ -0,0 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 a = aFOO[programIndex];
int8 shuf = shuffle(a, 1);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2;
}

13
tests/shuffle-4.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int16 a = aFOO[programIndex];
int reverse = programCount - 1 - programIndex;
int16 shuf = shuffle(a, reverse);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = programCount - programIndex;
}

13
tests/shuffle-5.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 a = aFOO[programIndex];
int reverse = programCount - 1 - programIndex + (int)b - 5;
int8 shuf = shuffle(a, reverse);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = programCount - programIndex;
}

13
tests/shuffle2-11.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int16 aa = aFOO[programIndex];
int16 bb = aa + programCount;
int16 shuf = shuffle(aa, bb, 2*programIndex);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 1 + 2*programIndex;
}

13
tests/shuffle2-6.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 aa = aFOO[programIndex];
int8 bb = aa + programCount;
int8 shuf = shuffle(aa, bb, 1);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2;
}

13
tests/shuffle2-7.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int16 aa = aFOO[programIndex];
int16 bb = aa + programCount;
int16 shuf = shuffle(aa, bb, programCount + 1);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 2 + programCount;
}

13
tests/shuffle2-8.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int8 aa = aFOO[programIndex];
int8 bb = aa + programCount;
int8 shuf = shuffle(aa, bb, programIndex + 2);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 3 + programIndex;
}

13
tests/shuffle2-9.ispc Normal file
View File

@@ -0,0 +1,13 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
int16 aa = aFOO[programIndex];
int16 bb = aa + programCount;
int16 shuf = shuffle(aa, bb, programIndex + 2 + (int)b - 5);
RET[programIndex] = shuf;
}
export void result(uniform float RET[]) {
RET[programIndex] = 3 + programIndex;
}

View File

@@ -1,16 +1,15 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[16];
for (uniform int i = 0; i < 16; ++i)
x[i] = 0xffffffff;
unsigned int val = aFOO[programIndex];
store_to_int16(x, 5, val);
unsigned int v = load_from_int16(x, 6);
RET[programIndex] = v;
uniform unsigned int16 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xffff;
unsigned int16 val = aFOO[programIndex];
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = 2+programIndex;
RET[programCount-1] = (unsigned int)0xffffffff;
RET[programIndex] = programIndex;
RET[0] = 65535;
}

19
tests/store-int16-2.ispc Normal file
View File

@@ -0,0 +1,19 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform unsigned int16 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xffff;
unsigned int16 val = aFOO[programIndex];
if (programIndex & 1)
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {
if (programIndex & 1)
RET[programIndex] = 65535;
else
RET[programIndex] = programIndex;
RET[0] = 65535;
}

View File

@@ -1,16 +1,15 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[16];
for (uniform int i = 0; i < 16; ++i)
x[i] = 0xffffffff;
unsigned int val = aFOO[programIndex];
store_to_int16(x, 5, val);
int v = load_from_int16(x, 6);
RET[programIndex] = v;
uniform int16 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xffff;
unsigned int8 val = aFOO[programIndex];
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = 2+programIndex;
RET[programCount-1] = -1;
RET[programIndex] = programIndex;
RET[0] = -1.;
}

View File

@@ -1,16 +1,15 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform unsigned int x[8];
for (uniform int i = 0; i < 8; ++i)
x[i] = 0xffffffff;
unsigned int val = aFOO[programIndex];
store_to_uint8(x, 2, val);
unsigned int v = load_from_uint8(x, 1);
RET[programIndex] = v;
uniform unsigned int8 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xff;
unsigned int8 val = aFOO[programIndex];
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {
RET[programIndex] = programIndex;
RET[0] = (unsigned int)0xff;
RET[0] = 255;
}

19
tests/store-int8-2.ispc Normal file
View File

@@ -0,0 +1,19 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform unsigned int8 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xff;
unsigned int8 val = aFOO[programIndex];
if (programIndex & 1)
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {
if (programIndex & 1)
RET[programIndex] = 255;
else
RET[programIndex] = programIndex;
RET[0] = 255;
}

View File

@@ -1,13 +1,12 @@
export uniform int width() { return programCount; }
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
uniform int x[8];
for (uniform int i = 0; i < 8; ++i)
x[i] = 0xffffffff;
unsigned int val = aFOO[programIndex];
store_to_int8(x, 2, val);
int v = load_from_int8(x, 1);
RET[programIndex] = v;
uniform int8 x[2*programCount];
for (uniform int i = 0; i < 2*programCount; ++i)
x[i] = 0xff;
unsigned int8 val = aFOO[programIndex];
x[2+programIndex] = val;
RET[programIndex] = x[1+programIndex];
}
export void result(uniform float RET[]) {

View File

@@ -4,12 +4,12 @@ export uniform int width() { return programCount; }
export void f_fu(uniform float ret[], uniform float aa[], uniform float b) {
uniform int foo[10];
for (uniform int i = 0; i < 10; ++i)
foo[i] = 10;
foo[i] = 10+i;
int bb = b;
foo[bb] = 0;
ret[programIndex] = foo[4] + foo[5];
}
export void result(uniform float ret[]) {
ret[programIndex] = 10;
ret[programIndex] = 14;
}