Provide both signed and unsigned int variants of bitcode-based builtins.
When creating function Symbols for functions that were defined in LLVM bitcode for the standard library, if any of the function parameters are integer types, create two ispc-side Symbols: one where the integer types are all signed and the other where they are all unsigned. This allows us to provide, for example, both store_to_int16(reference int a[], uniform int offset, int val) as well as store_to_int16(reference unsigned int a[], uniform int offset, unsigned int val). functions.
Added some additional tests to exercise the new variants of these.
Also fixed some cases where the __{load,store}_int{8,16} builtins would read from/write to memory even if the mask was all off (which could cause crashes in some cases.)
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[]) {
|
||||
uniform int a[programCount];
|
||||
uniform unsigned int a[programCount];
|
||||
a[programIndex] = aFOO[programIndex];
|
||||
int aa;
|
||||
unsigned int aa;
|
||||
packed_load_active(a, 0, aa);
|
||||
RET[programIndex] = aa;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ export uniform int width() { return programCount; }
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[]) {
|
||||
float a = aFOO[programIndex];
|
||||
uniform int pack[programCount];
|
||||
uniform unsigned int pack[programCount];
|
||||
for (uniform int i = 0; i < programCount; ++i)
|
||||
pack[i] = 0;
|
||||
packed_store_active(pack, 0, a);
|
||||
packed_store_active(pack, 0, (unsigned int)a);
|
||||
RET[programIndex] = pack[programIndex];
|
||||
}
|
||||
|
||||
|
||||
13
tests/shuffle2.ispc
Normal file
13
tests/shuffle2.ispc
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
int32 aa = aFOO[programIndex];
|
||||
int32 bb = aa + programCount;
|
||||
int32 shuf = shuffle(aa, bb, 1);
|
||||
RET[programIndex] = shuf;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = 2;
|
||||
}
|
||||
16
tests/store-int16-1.ispc
Normal file
16
tests/store-int16-1.ispc
Normal file
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = 2+programIndex;
|
||||
RET[programCount-1] = (unsigned int)0xffffffff;
|
||||
}
|
||||
@@ -6,11 +6,11 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
x[i] = 0xffffffff;
|
||||
unsigned int val = aFOO[programIndex];
|
||||
store_to_int16(x, 5, val);
|
||||
unsigned int v = load_from_int16(x, 6);
|
||||
int v = load_from_int16(x, 6);
|
||||
RET[programIndex] = v;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = 2+programIndex;
|
||||
RET[programCount-1] = 0xffff;
|
||||
RET[programCount-1] = -1;
|
||||
}
|
||||
|
||||
16
tests/store-int8-1.ispc
Normal file
16
tests/store-int8-1.ispc
Normal file
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = programIndex;
|
||||
RET[0] = (unsigned int)0xff;
|
||||
}
|
||||
@@ -6,11 +6,11 @@ export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
x[i] = 0xffffffff;
|
||||
unsigned int val = aFOO[programIndex];
|
||||
store_to_int8(x, 2, val);
|
||||
unsigned int v = load_from_int8(x, 1);
|
||||
int v = load_from_int8(x, 1);
|
||||
RET[programIndex] = v;
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = programIndex;
|
||||
RET[0] = 0xff;
|
||||
RET[0] = -1.;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user