Saturation arithmetic (sub and add) was added for int32/int64.
This commit is contained in:
27
tests/padds_i32.ispc
Normal file
27
tests/padds_i32.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform int32 a_max = 2147483647, a_min = -2147483648; // max and min signed int32
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_add(a_min, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (uniform int32) 2147483647;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (uniform int32) -2147483648;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform int32) -2147483643;
|
||||
}
|
||||
}
|
||||
27
tests/padds_i64.ispc
Normal file
27
tests/padds_i64.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform int64 a_max = 9223372036854775807, a_min = -9223372036854775808; // max and min signed int64
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_add(a_min, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (uniform int64) 9223372036854775807;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (uniform int64) -9223372036854775808;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform int64) -9223372036854775803;
|
||||
}
|
||||
}
|
||||
27
tests/padds_vi32.ispc
Normal file
27
tests/padds_vi32.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying int32 a_max = 2147483647, a_min = -2147483648; // max and min signed int32
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_add(a_min, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (varying int32) 2147483647;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (varying int32) -2147483648;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying int32) -2147483643;
|
||||
}
|
||||
}
|
||||
27
tests/padds_vi64.ispc
Normal file
27
tests/padds_vi64.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying int64 a_max = 9223372036854775807, a_min = -9223372036854775808; // max and min signed int64
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_add(a_min, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (varying int64) 9223372036854775807;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (varying int64) -9223372036854775808;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying int64) -9223372036854775803;
|
||||
}
|
||||
}
|
||||
21
tests/paddus_i32.ispc
Normal file
21
tests/paddus_i32.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform unsigned int32 a_max = 4294967295, a_min = 0; // max and min unsigned int32
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (uniform unsigned int32) 4294967295;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform unsigned int32) 5;
|
||||
}
|
||||
}
|
||||
21
tests/paddus_i64.ispc
Normal file
21
tests/paddus_i64.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform unsigned int64 a_max = 18446744073709551615, a_min = 0; // max and min unsigned int64
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (uniform unsigned int64) 18446744073709551615;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform unsigned int64) 5;
|
||||
}
|
||||
}
|
||||
21
tests/paddus_vi32.ispc
Normal file
21
tests/paddus_vi32.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying unsigned int32 a_max = 4294967295, a_min = 0; // max and min unsigned int32
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (varying unsigned int32) 4294967295;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying unsigned int32) 5;
|
||||
}
|
||||
}
|
||||
21
tests/paddus_vi64.ispc
Normal file
21
tests/paddus_vi64.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying unsigned int64 a_max = 18446744073709551615, a_min = 0; // max and min unsigned int64
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_add(a_max, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_add(a_min, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (varying unsigned int64) 18446744073709551615;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying unsigned int64) 5;
|
||||
}
|
||||
}
|
||||
27
tests/psubs_i32.ispc
Normal file
27
tests/psubs_i32.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform int32 a_max = 2147483647, a_min = -2147483648; // max and min int32
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_sub(a_max, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (uniform int32) -2147483648;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (uniform int32) 2147483647;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform int32) 2147483642;
|
||||
}
|
||||
}
|
||||
27
tests/psubs_i64.ispc
Normal file
27
tests/psubs_i64.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform int64 a_max = 9223372036854775807, a_min = -9223372036854775808; // max and min int64
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_sub(a_max, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (uniform int64) -9223372036854775808;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (uniform int64) 9223372036854775807;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform int64) 9223372036854775802;
|
||||
}
|
||||
}
|
||||
27
tests/psubs_vi32.ispc
Normal file
27
tests/psubs_vi32.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying int32 a_max = 2147483647, a_min = -2147483648; // max and min int32
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_sub(a_max, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (varying int32) -2147483648;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (varying int32) 2147483647;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying int32) 2147483642;
|
||||
}
|
||||
}
|
||||
27
tests/psubs_vi64.ispc
Normal file
27
tests/psubs_vi64.ispc
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying int64 a_max = 9223372036854775807, a_min = -9223372036854775808; // max and min int64
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = saturating_sub(a_max, -b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 3 == 0) {
|
||||
RET[programIndex] = (varying int64) -9223372036854775808;
|
||||
}
|
||||
else if (programIndex % 3 == 1) {
|
||||
RET[programIndex] = (varying int64) 9223372036854775807;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying int64) 9223372036854775802;
|
||||
}
|
||||
}
|
||||
21
tests/psubus_i32.ispc
Normal file
21
tests/psubus_i32.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform unsigned int32 a_max = 4294967295, a_min = 0; // max and min unsigned int32
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (uniform unsigned int32) 0;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform unsigned int32) 4294967290;
|
||||
}
|
||||
}
|
||||
21
tests/psubus_i64.ispc
Normal file
21
tests/psubus_i64.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
uniform unsigned int64 a_max = 18446744073709551615, a_min = 0; // max and min unsigned int64
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (uniform unsigned int64) 0;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (uniform unsigned int64) 18446744073709551610;
|
||||
}
|
||||
}
|
||||
21
tests/psubus_vi32.ispc
Normal file
21
tests/psubus_vi32.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying unsigned int32 a_max = 4294967295, a_min = 0; // max and min unsigned int32
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (varying unsigned int32) 0;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying unsigned int32) 4294967290;
|
||||
}
|
||||
}
|
||||
21
tests/psubus_vi64.ispc
Normal file
21
tests/psubus_vi64.ispc
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) {
|
||||
varying unsigned int64 a_max = 18446744073709551615, a_min = 0; // max and min unsigned int64
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = saturating_sub(a_min, b);
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = saturating_sub(a_max, b);
|
||||
}
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
if (programIndex % 2 == 0) {
|
||||
RET[programIndex] = (varying unsigned int64) 0;
|
||||
}
|
||||
else {
|
||||
RET[programIndex] = (varying unsigned int64) 18446744073709551610;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user