Remove float8/16 from RS type list.
We will not have time to work through ABI issues for these types
on arm for our ship date. Can be re-added later.
Change-Id: I957758be7e900a1c55eff9cb5aeb16fa636bd9a0
diff --git a/scriptc/rs_cl.rsh b/scriptc/rs_cl.rsh
index 6d578db..c84cdff 100644
--- a/scriptc/rs_cl.rsh
+++ b/scriptc/rs_cl.rsh
@@ -1,473 +1,429 @@
+#ifndef __RS_CL_RSH__
+#define __RS_CL_RSH__
+
+#define M_PI 3.14159265358979323846264338327950288f /* pi */
+
+
+// Conversions
+#define CVT_FUNC_2(typeout, typein) \
+static typeout##2 __attribute__((overloadable)) convert_##typeout##2(typein##2 v) { \
+ typeout##2 r = {v.x, v.y}; \
+ return r; \
+} \
+static typeout##3 __attribute__((overloadable)) convert_##typeout##3(typein##3 v) { \
+ typeout##3 r = {v.x, v.y, v.z}; \
+ return r; \
+} \
+static typeout##4 __attribute__((overloadable)) convert_##typeout##4(typein##4 v) { \
+ typeout##4 r = {v.x, v.y, v.z, v.w}; \
+ return r; \
+}
+
+#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \
+ CVT_FUNC_2(type, char) \
+ CVT_FUNC_2(type, ushort) \
+ CVT_FUNC_2(type, short) \
+ CVT_FUNC_2(type, int) \
+ CVT_FUNC_2(type, uint) \
+ CVT_FUNC_2(type, float)
+
+CVT_FUNC(char)
+CVT_FUNC(uchar)
+CVT_FUNC(short)
+CVT_FUNC(ushort)
+CVT_FUNC(int)
+CVT_FUNC(uint)
+CVT_FUNC(float)
+
+
+
// Float ops, 6.11.2
+#define DEF_FUNC_1(fnc) \
+static float2 __attribute__((overloadable)) fnc(float2 v) { \
+ float2 r; \
+ r.x = fnc(v.x); \
+ r.y = fnc(v.y); \
+ return r; \
+} \
+static float3 __attribute__((overloadable)) fnc(float3 v) { \
+ float3 r; \
+ r.x = fnc(v.x); \
+ r.y = fnc(v.y); \
+ r.z = fnc(v.z); \
+ return r; \
+} \
+static float4 __attribute__((overloadable)) fnc(float4 v) { \
+ float4 r; \
+ r.x = fnc(v.x); \
+ r.y = fnc(v.y); \
+ r.z = fnc(v.z); \
+ r.w = fnc(v.w); \
+ return r; \
+}
+
+#define DEF_FUNC_2(fnc) \
+static float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2) { \
+ float2 r; \
+ r.x = fnc(v1.x, v2.x); \
+ r.y = fnc(v1.y, v2.y); \
+ return r; \
+} \
+static float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2) { \
+ float3 r; \
+ r.x = fnc(v1.x, v2.x); \
+ r.y = fnc(v1.y, v2.y); \
+ r.z = fnc(v1.z, v2.z); \
+ return r; \
+} \
+static float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2) { \
+ float4 r; \
+ r.x = fnc(v1.x, v2.x); \
+ r.y = fnc(v1.y, v2.y); \
+ r.z = fnc(v1.z, v2.z); \
+ r.w = fnc(v1.w, v2.z); \
+ return r; \
+}
+
+#define DEF_FUNC_2F(fnc) \
+static float2 __attribute__((overloadable)) fnc(float2 v1, float v2) { \
+ float2 r; \
+ r.x = fnc(v1.x, v2); \
+ r.y = fnc(v1.y, v2); \
+ return r; \
+} \
+static float3 __attribute__((overloadable)) fnc(float3 v1, float v2) { \
+ float3 r; \
+ r.x = fnc(v1.x, v2); \
+ r.y = fnc(v1.y, v2); \
+ r.z = fnc(v1.z, v2); \
+ return r; \
+} \
+static float4 __attribute__((overloadable)) fnc(float4 v1, float v2) { \
+ float4 r; \
+ r.x = fnc(v1.x, v2); \
+ r.y = fnc(v1.y, v2); \
+ r.z = fnc(v1.z, v2); \
+ r.w = fnc(v1.w, v2); \
+ return r; \
+}
+
+
extern float __attribute__((overloadable)) acos(float);
-extern float2 __attribute__((overloadable)) acos(float2);
-extern float3 __attribute__((overloadable)) acos(float3);
-extern float4 __attribute__((overloadable)) acos(float4);
-extern float8 __attribute__((overloadable)) acos(float8);
-extern float16 __attribute__((overloadable)) acos(float16);
+DEF_FUNC_1(acos)
extern float __attribute__((overloadable)) acosh(float);
-extern float2 __attribute__((overloadable)) acosh(float2);
-extern float3 __attribute__((overloadable)) acosh(float3);
-extern float4 __attribute__((overloadable)) acosh(float4);
-extern float8 __attribute__((overloadable)) acosh(float8);
-extern float16 __attribute__((overloadable)) acosh(float16);
+DEF_FUNC_1(acosh)
-extern float __attribute__((overloadable)) acospi(float);
-extern float2 __attribute__((overloadable)) acospi(float2);
-extern float3 __attribute__((overloadable)) acospi(float3);
-extern float4 __attribute__((overloadable)) acospi(float4);
-extern float8 __attribute__((overloadable)) acospi(float8);
-extern float16 __attribute__((overloadable)) acospi(float16);
+static float __attribute__((overloadable)) acospi(float v) {
+ return acos(v) / M_PI;
+}
+DEF_FUNC_1(acospi)
extern float __attribute__((overloadable)) asin(float);
-extern float2 __attribute__((overloadable)) asin(float2);
-extern float3 __attribute__((overloadable)) asin(float3);
-extern float4 __attribute__((overloadable)) asin(float4);
-extern float8 __attribute__((overloadable)) asin(float8);
-extern float16 __attribute__((overloadable)) asin(float16);
+DEF_FUNC_1(asin)
extern float __attribute__((overloadable)) asinh(float);
-extern float2 __attribute__((overloadable)) asinh(float2);
-extern float3 __attribute__((overloadable)) asinh(float3);
-extern float4 __attribute__((overloadable)) asinh(float4);
-extern float8 __attribute__((overloadable)) asinh(float8);
-extern float16 __attribute__((overloadable)) asinh(float16);
+DEF_FUNC_1(asinh)
-extern float __attribute__((overloadable)) asinpi(float);
-extern float2 __attribute__((overloadable)) asinpi(float2);
-extern float3 __attribute__((overloadable)) asinpi(float3);
-extern float4 __attribute__((overloadable)) asinpi(float4);
-extern float8 __attribute__((overloadable)) asinpi(float8);
-extern float16 __attribute__((overloadable)) asinpi(float16);
+static float __attribute__((overloadable)) asinpi(float v) {
+ return asin(v) / M_PI;
+}
+DEF_FUNC_1(asinpi)
extern float __attribute__((overloadable)) atan(float);
-extern float2 __attribute__((overloadable)) atan(float2);
-extern float3 __attribute__((overloadable)) atan(float3);
-extern float4 __attribute__((overloadable)) atan(float4);
-extern float8 __attribute__((overloadable)) atan(float8);
-extern float16 __attribute__((overloadable)) atan(float16);
+DEF_FUNC_1(atan)
extern float __attribute__((overloadable)) atan2(float, float);
-extern float2 __attribute__((overloadable)) atan2(float2, float2);
-extern float3 __attribute__((overloadable)) atan2(float3, float3);
-extern float4 __attribute__((overloadable)) atan2(float4, float4);
-extern float8 __attribute__((overloadable)) atan2(float8, float8);
-extern float16 __attribute__((overloadable)) atan2(float16, float16);
+DEF_FUNC_2(atan2)
extern float __attribute__((overloadable)) atanh(float);
-extern float2 __attribute__((overloadable)) atanh(float2);
-extern float3 __attribute__((overloadable)) atanh(float3);
-extern float4 __attribute__((overloadable)) atanh(float4);
-extern float8 __attribute__((overloadable)) atanh(float8);
-extern float16 __attribute__((overloadable)) atanh(float16);
+DEF_FUNC_1(atanh)
-extern float __attribute__((overloadable)) atanpi(float);
-extern float2 __attribute__((overloadable)) atanpi(float2);
-extern float3 __attribute__((overloadable)) atanpi(float3);
-extern float4 __attribute__((overloadable)) atanpi(float4);
-extern float8 __attribute__((overloadable)) atanpi(float8);
-extern float16 __attribute__((overloadable)) atanpi(float16);
+static float __attribute__((overloadable)) atanpi(float v) {
+ return atan(v) / M_PI;
+}
+DEF_FUNC_1(atanpi)
-extern float __attribute__((overloadable)) atan2pi(float, float);
-extern float2 __attribute__((overloadable)) atan2pi(float2, float2);
-extern float3 __attribute__((overloadable)) atan2pi(float3, float3);
-extern float4 __attribute__((overloadable)) atan2pi(float4, float4);
-extern float8 __attribute__((overloadable)) atan2pi(float8, float8);
-extern float16 __attribute__((overloadable)) atan2pi(float16, float16);
+static float __attribute__((overloadable)) atan2pi(float y, float x) {
+ return atan2(y, x) / M_PI;
+}
+DEF_FUNC_2(atan2pi)
extern float __attribute__((overloadable)) cbrt(float);
-extern float2 __attribute__((overloadable)) cbrt(float2);
-extern float3 __attribute__((overloadable)) cbrt(float3);
-extern float4 __attribute__((overloadable)) cbrt(float4);
-extern float8 __attribute__((overloadable)) cbrt(float8);
-extern float16 __attribute__((overloadable)) cbrt(float16);
+DEF_FUNC_1(cbrt)
extern float __attribute__((overloadable)) ceil(float);
-extern float2 __attribute__((overloadable)) ceil(float2);
-extern float3 __attribute__((overloadable)) ceil(float3);
-extern float4 __attribute__((overloadable)) ceil(float4);
-extern float8 __attribute__((overloadable)) ceil(float8);
-extern float16 __attribute__((overloadable)) ceil(float16);
+DEF_FUNC_1(ceil)
extern float __attribute__((overloadable)) copysign(float, float);
-extern float2 __attribute__((overloadable)) copysign(float2, float2);
-extern float3 __attribute__((overloadable)) copysign(float3, float3);
-extern float4 __attribute__((overloadable)) copysign(float4, float4);
-extern float8 __attribute__((overloadable)) copysign(float8, float8);
-extern float16 __attribute__((overloadable)) copysign(float16, float16);
+DEF_FUNC_2(copysign)
extern float __attribute__((overloadable)) cos(float);
-extern float2 __attribute__((overloadable)) cos(float2);
-extern float3 __attribute__((overloadable)) cos(float3);
-extern float4 __attribute__((overloadable)) cos(float4);
-extern float8 __attribute__((overloadable)) cos(float8);
-extern float16 __attribute__((overloadable)) cos(float16);
+DEF_FUNC_1(cos)
extern float __attribute__((overloadable)) cosh(float);
-extern float2 __attribute__((overloadable)) cosh(float2);
-extern float3 __attribute__((overloadable)) cosh(float3);
-extern float4 __attribute__((overloadable)) cosh(float4);
-extern float8 __attribute__((overloadable)) cosh(float8);
-extern float16 __attribute__((overloadable)) cosh(float16);
+DEF_FUNC_1(cosh)
-extern float __attribute__((overloadable)) cospi(float);
-extern float2 __attribute__((overloadable)) cospi(float2);
-extern float3 __attribute__((overloadable)) cospi(float3);
-extern float4 __attribute__((overloadable)) cospi(float4);
-extern float8 __attribute__((overloadable)) cospi(float8);
-extern float16 __attribute__((overloadable)) cospi(float16);
+static float __attribute__((overloadable)) cospi(float v) {
+ return cos(v * M_PI);
+}
+DEF_FUNC_1(cospi)
extern float __attribute__((overloadable)) erfc(float);
-extern float2 __attribute__((overloadable)) erfc(float2);
-extern float3 __attribute__((overloadable)) erfc(float3);
-extern float4 __attribute__((overloadable)) erfc(float4);
-extern float8 __attribute__((overloadable)) erfc(float8);
-extern float16 __attribute__((overloadable)) erfc(float16);
+DEF_FUNC_1(erfc)
extern float __attribute__((overloadable)) erf(float);
-extern float2 __attribute__((overloadable)) erf(float2);
-extern float3 __attribute__((overloadable)) erf(float3);
-extern float4 __attribute__((overloadable)) erf(float4);
-extern float8 __attribute__((overloadable)) erf(float8);
-extern float16 __attribute__((overloadable)) erf(float16);
+DEF_FUNC_1(erf)
extern float __attribute__((overloadable)) exp(float);
-extern float2 __attribute__((overloadable)) exp(float2);
-extern float3 __attribute__((overloadable)) exp(float3);
-extern float4 __attribute__((overloadable)) exp(float4);
-extern float8 __attribute__((overloadable)) exp(float8);
-extern float16 __attribute__((overloadable)) exp(float16);
+DEF_FUNC_1(exp)
extern float __attribute__((overloadable)) exp2(float);
-extern float2 __attribute__((overloadable)) exp2(float2);
-extern float3 __attribute__((overloadable)) exp2(float3);
-extern float4 __attribute__((overloadable)) exp2(float4);
-extern float8 __attribute__((overloadable)) exp2(float8);
-extern float16 __attribute__((overloadable)) exp2(float16);
+DEF_FUNC_1(exp2)
-extern float __attribute__((overloadable)) exp10(float);
-extern float2 __attribute__((overloadable)) exp10(float2);
-extern float3 __attribute__((overloadable)) exp10(float3);
-extern float4 __attribute__((overloadable)) exp10(float4);
-extern float8 __attribute__((overloadable)) exp10(float8);
-extern float16 __attribute__((overloadable)) exp10(float16);
+extern float __attribute__((overloadable)) pow(float, float);
+static float __attribute__((overloadable)) exp10(float v) {
+ return pow(10.f, v);
+}
+DEF_FUNC_1(exp10)
extern float __attribute__((overloadable)) expm1(float);
-extern float2 __attribute__((overloadable)) expm1(float2);
-extern float3 __attribute__((overloadable)) expm1(float3);
-extern float4 __attribute__((overloadable)) expm1(float4);
-extern float8 __attribute__((overloadable)) expm1(float8);
-extern float16 __attribute__((overloadable)) expm1(float16);
+DEF_FUNC_1(expm1)
extern float __attribute__((overloadable)) fabs(float);
-extern float2 __attribute__((overloadable)) fabs(float2);
-extern float3 __attribute__((overloadable)) fabs(float3);
-extern float4 __attribute__((overloadable)) fabs(float4);
-extern float8 __attribute__((overloadable)) fabs(float8);
-extern float16 __attribute__((overloadable)) fabs(float16);
+DEF_FUNC_1(fabs)
extern float __attribute__((overloadable)) fdim(float, float);
-extern float2 __attribute__((overloadable)) fdim(float2, float2);
-extern float3 __attribute__((overloadable)) fdim(float3, float3);
-extern float4 __attribute__((overloadable)) fdim(float4, float4);
-extern float8 __attribute__((overloadable)) fdim(float8, float8);
-extern float16 __attribute__((overloadable)) fdim(float16, float16);
+DEF_FUNC_2(fdim)
extern float __attribute__((overloadable)) floor(float);
-extern float2 __attribute__((overloadable)) floor(float2);
-extern float3 __attribute__((overloadable)) floor(float3);
-extern float4 __attribute__((overloadable)) floor(float4);
-extern float8 __attribute__((overloadable)) floor(float8);
-extern float16 __attribute__((overloadable)) floor(float16);
+DEF_FUNC_1(floor)
extern float __attribute__((overloadable)) fma(float, float, float);
extern float2 __attribute__((overloadable)) fma(float2, float2, float2);
extern float3 __attribute__((overloadable)) fma(float3, float3, float3);
extern float4 __attribute__((overloadable)) fma(float4, float4, float4);
-extern float8 __attribute__((overloadable)) fma(float8, float8, float8);
-extern float16 __attribute__((overloadable)) fma(float16, float16, float16);
extern float __attribute__((overloadable)) fmax(float, float);
-extern float2 __attribute__((overloadable)) fmax(float2, float2);
-extern float3 __attribute__((overloadable)) fmax(float3, float3);
-extern float4 __attribute__((overloadable)) fmax(float4, float4);
-extern float8 __attribute__((overloadable)) fmax(float8, float8);
-extern float16 __attribute__((overloadable)) fmax(float16, float16);
-extern float2 __attribute__((overloadable)) fmax(float2, float);
-extern float3 __attribute__((overloadable)) fmax(float3, float);
-extern float4 __attribute__((overloadable)) fmax(float4, float);
-extern float8 __attribute__((overloadable)) fmax(float8, float);
-extern float16 __attribute__((overloadable)) fmax(float16, float);
+DEF_FUNC_2(fmax);
+DEF_FUNC_2F(fmax);
extern float __attribute__((overloadable)) fmin(float, float);
-extern float2 __attribute__((overloadable)) fmin(float2, float2);
-extern float3 __attribute__((overloadable)) fmin(float3, float3);
-extern float4 __attribute__((overloadable)) fmin(float4, float4);
-extern float8 __attribute__((overloadable)) fmin(float8, float8);
-extern float16 __attribute__((overloadable)) fmin(float16, float16);
-extern float2 __attribute__((overloadable)) fmin(float2, float);
-extern float3 __attribute__((overloadable)) fmin(float3, float);
-extern float4 __attribute__((overloadable)) fmin(float4, float);
-extern float8 __attribute__((overloadable)) fmin(float8, float);
-extern float16 __attribute__((overloadable)) fmin(float16, float);
+DEF_FUNC_2(fmin);
+DEF_FUNC_2F(fmin);
extern float __attribute__((overloadable)) fmod(float, float);
-extern float2 __attribute__((overloadable)) fmod(float2, float2);
-extern float3 __attribute__((overloadable)) fmod(float3, float3);
-extern float4 __attribute__((overloadable)) fmod(float4, float4);
-extern float8 __attribute__((overloadable)) fmod(float8, float8);
-extern float16 __attribute__((overloadable)) fmod(float16, float16);
+DEF_FUNC_2(fmod)
-extern float __attribute__((overloadable)) fract(float, float *);
-extern float2 __attribute__((overloadable)) fract(float2, float2 *);
-extern float3 __attribute__((overloadable)) fract(float3, float3 *);
-extern float4 __attribute__((overloadable)) fract(float4, float4 *);
-extern float8 __attribute__((overloadable)) fract(float8, float8 *);
-extern float16 __attribute__((overloadable)) fract(float16, float16 *);
+static float __attribute__((overloadable)) fract(float v, float *iptr) {
+ int i = (int)floor(v);
+ iptr[0] = i;
+ return fmin(v - i, 0x1.fffffep-1f);
+}
+static float2 __attribute__((overloadable)) fract(float2 v, float2 *iptr) {
+ float t[2];
+ float2 r;
+ r.x = fract(v.x, &t[0]);
+ r.y = fract(v.y, &t[1]);
+ iptr[0] = t[0];
+ iptr[1] = t[1];
+ return r;
+}
+static float3 __attribute__((overloadable)) fract(float3 v, float3 *iptr) {
+ float t[3];
+ float3 r;
+ r.x = fract(v.x, &t[0]);
+ r.y = fract(v.y, &t[1]);
+ r.z = fract(v.z, &t[2]);
+ iptr[0] = t[0];
+ iptr[1] = t[1];
+ iptr[2] = t[2];
+ return r;
+}
+static float4 __attribute__((overloadable)) fract(float4 v, float4 *iptr) {
+ float t[4];
+ float4 r;
+ r.x = fract(v.x, &t[0]);
+ r.y = fract(v.y, &t[1]);
+ r.z = fract(v.z, &t[2]);
+ r.w = fract(v.w, &t[3]);
+ iptr[0] = t[0];
+ iptr[1] = t[1];
+ iptr[2] = t[2];
+ iptr[3] = t[3];
+ return r;
+}
extern float __attribute__((overloadable)) frexp(float, float *);
extern float2 __attribute__((overloadable)) frexp(float2, float2 *);
extern float3 __attribute__((overloadable)) frexp(float3, float3 *);
extern float4 __attribute__((overloadable)) frexp(float4, float4 *);
-extern float8 __attribute__((overloadable)) frexp(float8, float8 *);
-extern float16 __attribute__((overloadable)) frexp(float16, float16 *);
extern float __attribute__((overloadable)) hypot(float, float);
-extern float2 __attribute__((overloadable)) hypot(float2, float2);
-extern float3 __attribute__((overloadable)) hypot(float3, float3);
-extern float4 __attribute__((overloadable)) hypot(float4, float4);
-extern float8 __attribute__((overloadable)) hypot(float8, float8);
-extern float16 __attribute__((overloadable)) hypot(float16, float16);
+DEF_FUNC_2(hypot)
extern int __attribute__((overloadable)) ilogb(float);
-extern int2 __attribute__((overloadable)) ilogb(float2);
-extern int3 __attribute__((overloadable)) ilogb(float3);
-extern int4 __attribute__((overloadable)) ilogb(float4);
-extern int8 __attribute__((overloadable)) ilogb(float8);
-extern int16 __attribute__((overloadable)) ilogb(float16);
+DEF_FUNC_1(ilogb)
extern float __attribute__((overloadable)) ldexp(float, int);
extern float2 __attribute__((overloadable)) ldexp(float2, int2);
extern float3 __attribute__((overloadable)) ldexp(float3, int3);
extern float4 __attribute__((overloadable)) ldexp(float4, int4);
-extern float8 __attribute__((overloadable)) ldexp(float8, int8);
-extern float16 __attribute__((overloadable)) ldexp(float16, int16);
extern float2 __attribute__((overloadable)) ldexp(float2, int);
extern float3 __attribute__((overloadable)) ldexp(float3, int);
extern float4 __attribute__((overloadable)) ldexp(float4, int);
-extern float8 __attribute__((overloadable)) ldexp(float8, int);
-extern float16 __attribute__((overloadable)) ldexp(float16, int);
extern float __attribute__((overloadable)) lgamma(float);
-extern float2 __attribute__((overloadable)) lgamma(float2);
-extern float3 __attribute__((overloadable)) lgamma(float3);
-extern float4 __attribute__((overloadable)) lgamma(float4);
-extern float8 __attribute__((overloadable)) lgamma(float8);
-extern float16 __attribute__((overloadable)) lgamma(float16);
+DEF_FUNC_1(lgamma)
extern float __attribute__((overloadable)) lgamma(float, float *);
extern float2 __attribute__((overloadable)) lgamma(float2, float2 *);
extern float3 __attribute__((overloadable)) lgamma(float3, float3 *);
extern float4 __attribute__((overloadable)) lgamma(float4, float4 *);
-extern float8 __attribute__((overloadable)) lgamma(float8, float8 *);
-extern float16 __attribute__((overloadable)) lgamma(float16, float16 *);
extern float __attribute__((overloadable)) log(float);
-extern float2 __attribute__((overloadable)) log(float2);
-extern float3 __attribute__((overloadable)) log(float3);
-extern float4 __attribute__((overloadable)) log(float4);
-extern float8 __attribute__((overloadable)) log(float8);
-extern float16 __attribute__((overloadable)) log(float16);
+DEF_FUNC_1(log)
-extern float __attribute__((overloadable)) log2(float);
-extern float2 __attribute__((overloadable)) log2(float2);
-extern float3 __attribute__((overloadable)) log2(float3);
-extern float4 __attribute__((overloadable)) log2(float4);
-extern float8 __attribute__((overloadable)) log2(float8);
-extern float16 __attribute__((overloadable)) log2(float16);
extern float __attribute__((overloadable)) log10(float);
-extern float2 __attribute__((overloadable)) log10(float2);
-extern float3 __attribute__((overloadable)) log10(float3);
-extern float4 __attribute__((overloadable)) log10(float4);
-extern float8 __attribute__((overloadable)) log10(float8);
-extern float16 __attribute__((overloadable)) log10(float16);
+DEF_FUNC_1(log10)
+
+static float __attribute__((overloadable)) log2(float v) {
+ return log10(v) / log10(2.f);
+}
+DEF_FUNC_1(log2)
extern float __attribute__((overloadable)) log1p(float);
-extern float2 __attribute__((overloadable)) log1p(float2);
-extern float3 __attribute__((overloadable)) log1p(float3);
-extern float4 __attribute__((overloadable)) log1p(float4);
-extern float8 __attribute__((overloadable)) log1p(float8);
-extern float16 __attribute__((overloadable)) log1p(float16);
+DEF_FUNC_1(log1p)
extern float __attribute__((overloadable)) logb(float);
-extern float2 __attribute__((overloadable)) logb(float2);
-extern float3 __attribute__((overloadable)) logb(float3);
-extern float4 __attribute__((overloadable)) logb(float4);
-extern float8 __attribute__((overloadable)) logb(float8);
-extern float16 __attribute__((overloadable)) logb(float16);
+DEF_FUNC_1(logb)
extern float __attribute__((overloadable)) mad(float, float, float);
extern float2 __attribute__((overloadable)) mad(float2, float2, float2);
extern float3 __attribute__((overloadable)) mad(float3, float3, float3);
extern float4 __attribute__((overloadable)) mad(float4, float4, float4);
-extern float8 __attribute__((overloadable)) mad(float8, float8, float8);
-extern float16 __attribute__((overloadable)) mad(float16, float16, float16);
extern float __attribute__((overloadable)) modf(float, float *);
extern float2 __attribute__((overloadable)) modf(float2, float2 *);
extern float3 __attribute__((overloadable)) modf(float3, float3 *);
extern float4 __attribute__((overloadable)) modf(float4, float4 *);
-extern float8 __attribute__((overloadable)) modf(float8, float8 *);
-extern float16 __attribute__((overloadable)) modf(float16, float16 *);
-extern float __attribute__((overloadable)) nan(uint);
-extern float2 __attribute__((overloadable)) nan(uint2);
-extern float3 __attribute__((overloadable)) nan(uint3);
-extern float4 __attribute__((overloadable)) nan(uint4);
-extern float8 __attribute__((overloadable)) nan(uint8);
-extern float16 __attribute__((overloadable)) nan(uint16);
+//extern float __attribute__((overloadable)) nan(uint);
extern float __attribute__((overloadable)) nextafter(float, float);
-extern float2 __attribute__((overloadable)) nextafter(float2, float2);
-extern float3 __attribute__((overloadable)) nextafter(float3, float3);
-extern float4 __attribute__((overloadable)) nextafter(float4, float4);
-extern float8 __attribute__((overloadable)) nextafter(float8, float8);
-extern float16 __attribute__((overloadable)) nextafter(float16, float16);
+DEF_FUNC_2(nextafter)
-extern float __attribute__((overloadable)) pow(float, float);
-extern float2 __attribute__((overloadable)) pow(float2, float2);
-extern float3 __attribute__((overloadable)) pow(float3, float3);
-extern float4 __attribute__((overloadable)) pow(float4, float4);
-extern float8 __attribute__((overloadable)) pow(float8, float8);
-extern float16 __attribute__((overloadable)) pow(float16, float16);
+DEF_FUNC_2(pow)
-extern float __attribute__((overloadable)) pown(float, int);
-extern float2 __attribute__((overloadable)) pown(float2, int2);
-extern float3 __attribute__((overloadable)) pown(float3, int3);
-extern float4 __attribute__((overloadable)) pown(float4, int4);
-extern float8 __attribute__((overloadable)) pown(float8, int8);
-extern float16 __attribute__((overloadable)) pown(float16, int16);
+static float __attribute__((overloadable)) pown(float v, int p) {
+ return pow(v, (float)p);
+}
+static float2 __attribute__((overloadable)) pown(float2 v, int2 p) {
+ return pow(v, (float2)p);
+}
+static float3 __attribute__((overloadable)) pown(float3 v, int3 p) {
+ return pow(v, (float3)p);
+}
+static float4 __attribute__((overloadable)) pown(float4 v, int4 p) {
+ return pow(v, (float4)p);
+}
-extern float __attribute__((overloadable)) powr(float, float);
-extern float2 __attribute__((overloadable)) powr(float2, float2);
-extern float3 __attribute__((overloadable)) powr(float3, float3);
-extern float4 __attribute__((overloadable)) powr(float4, float4);
-extern float8 __attribute__((overloadable)) powr(float8, float8);
-extern float16 __attribute__((overloadable)) powr(float16, float16);
+static float __attribute__((overloadable)) powr(float v, float p) {
+ return pow(v, p);
+}
+static float2 __attribute__((overloadable)) powr(float2 v, float2 p) {
+ return pow(v, p);
+}
+static float3 __attribute__((overloadable)) powr(float3 v, float3 p) {
+ return pow(v, p);
+}
+static float4 __attribute__((overloadable)) powr(float4 v, float4 p) {
+ return pow(v, p);
+}
extern float __attribute__((overloadable)) remainder(float, float);
-extern float2 __attribute__((overloadable)) remainder(float2, float2);
-extern float3 __attribute__((overloadable)) remainder(float3, float3);
-extern float4 __attribute__((overloadable)) remainder(float4, float4);
-extern float8 __attribute__((overloadable)) remainder(float8, float8);
-extern float16 __attribute__((overloadable)) remainder(float16, float16);
+DEF_FUNC_2(remainder)
extern float __attribute__((overloadable)) remquo(float, float, float *);
extern float2 __attribute__((overloadable)) remquo(float2, float2, float2 *);
extern float3 __attribute__((overloadable)) remquo(float3, float3, float3 *);
extern float4 __attribute__((overloadable)) remquo(float4, float4, float4 *);
-extern float8 __attribute__((overloadable)) remquo(float8, float8, float8 *);
-extern float16 __attribute__((overloadable)) remquo(float16, float16, float16 *);
extern float __attribute__((overloadable)) rint(float);
-extern float2 __attribute__((overloadable)) rint(float2);
-extern float3 __attribute__((overloadable)) rint(float3);
-extern float4 __attribute__((overloadable)) rint(float4);
-extern float8 __attribute__((overloadable)) rint(float8);
-extern float16 __attribute__((overloadable)) rint(float16);
+DEF_FUNC_1(rint)
-extern float __attribute__((overloadable)) rootn(float, int);
-extern float2 __attribute__((overloadable)) rootn(float2, int2);
-extern float3 __attribute__((overloadable)) rootn(float3, int3);
-extern float4 __attribute__((overloadable)) rootn(float4, int4);
-extern float8 __attribute__((overloadable)) rootn(float8, int8);
-extern float16 __attribute__((overloadable)) rootn(float16, int16);
+static float __attribute__((overloadable)) rootn(float v, int r) {
+ return pow(v, 1.f / r);
+}
+static float2 __attribute__((overloadable)) rootn(float2 v, int2 r) {
+ float2 t = {1.f / r.x, 1.f / r.y};
+ return pow(v, t);
+}
+static float3 __attribute__((overloadable)) rootn(float3 v, int3 r) {
+ float3 t = {1.f / r.x, 1.f / r.y, 1.f / r.z};
+ return pow(v, t);
+}
+static float4 __attribute__((overloadable)) rootn(float4 v, int4 r) {
+ float4 t = {1.f / r.x, 1.f / r.y, 1.f / r.z, 1.f / r.w};
+ return pow(v, t);
+}
extern float __attribute__((overloadable)) round(float);
-extern float2 __attribute__((overloadable)) round(float2);
-extern float3 __attribute__((overloadable)) round(float3);
-extern float4 __attribute__((overloadable)) round(float4);
-extern float8 __attribute__((overloadable)) round(float8);
-extern float16 __attribute__((overloadable)) round(float16);
-
-extern float __attribute__((overloadable)) rsqrt(float);
-extern float2 __attribute__((overloadable)) rsqrt(float2);
-extern float3 __attribute__((overloadable)) rsqrt(float3);
-extern float4 __attribute__((overloadable)) rsqrt(float4);
-extern float8 __attribute__((overloadable)) rsqrt(float8);
-extern float16 __attribute__((overloadable)) rsqrt(float16);
-
-extern float __attribute__((overloadable)) sin(float);
-extern float2 __attribute__((overloadable)) sin(float2);
-extern float3 __attribute__((overloadable)) sin(float3);
-extern float4 __attribute__((overloadable)) sin(float4);
-extern float8 __attribute__((overloadable)) sin(float8);
-extern float16 __attribute__((overloadable)) sin(float16);
-
-extern float __attribute__((overloadable)) sincos(float, float *);
-extern float2 __attribute__((overloadable)) sincos(float2, float2 *);
-extern float3 __attribute__((overloadable)) sincos(float3, float3 *);
-extern float4 __attribute__((overloadable)) sincos(float4, float4 *);
-extern float8 __attribute__((overloadable)) sincos(float8, float8 *);
-extern float16 __attribute__((overloadable)) sincos(float16, float16 *);
-
-extern float __attribute__((overloadable)) sinh(float);
-extern float2 __attribute__((overloadable)) sinh(float2);
-extern float3 __attribute__((overloadable)) sinh(float3);
-extern float4 __attribute__((overloadable)) sinh(float4);
-extern float8 __attribute__((overloadable)) sinh(float8);
-extern float16 __attribute__((overloadable)) sinh(float16);
-
-extern float __attribute__((overloadable)) sinpi(float);
-extern float2 __attribute__((overloadable)) sinpi(float2);
-extern float3 __attribute__((overloadable)) sinpi(float3);
-extern float4 __attribute__((overloadable)) sinpi(float4);
-extern float8 __attribute__((overloadable)) sinpi(float8);
-extern float16 __attribute__((overloadable)) sinpi(float16);
+DEF_FUNC_1(round)
extern float __attribute__((overloadable)) sqrt(float);
-extern float2 __attribute__((overloadable)) sqrt(float2);
-extern float3 __attribute__((overloadable)) sqrt(float3);
-extern float4 __attribute__((overloadable)) sqrt(float4);
-extern float8 __attribute__((overloadable)) sqrt(float8);
-extern float16 __attribute__((overloadable)) sqrt(float16);
+static float __attribute__((overloadable)) rsqrt(float v) {
+ return 1.f / sqrt(v);
+}
+DEF_FUNC_1(rsqrt)
+
+extern float __attribute__((overloadable)) sin(float);
+DEF_FUNC_1(sin)
+
+static float __attribute__((overloadable)) sincos(float v, float *cosptr) {
+ *cosptr = cos(v);
+ return sin(v);
+}
+static float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr) {
+ *cosptr = cos(v);
+ return sin(v);
+}
+static float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr) {
+ *cosptr = cos(v);
+ return sin(v);
+}
+static float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr) {
+ *cosptr = cos(v);
+ return sin(v);
+}
+
+extern float __attribute__((overloadable)) sinh(float);
+DEF_FUNC_1(sinh)
+
+static float __attribute__((overloadable)) sinpi(float v) {
+ return sin(v * M_PI);
+}
+DEF_FUNC_1(sinpi)
+
+DEF_FUNC_1(sqrt)
extern float __attribute__((overloadable)) tan(float);
-extern float2 __attribute__((overloadable)) tan(float2);
-extern float3 __attribute__((overloadable)) tan(float3);
-extern float4 __attribute__((overloadable)) tan(float4);
-extern float8 __attribute__((overloadable)) tan(float8);
-extern float16 __attribute__((overloadable)) tan(float16);
+DEF_FUNC_1(tan)
extern float __attribute__((overloadable)) tanh(float);
-extern float2 __attribute__((overloadable)) tanh(float2);
-extern float3 __attribute__((overloadable)) tanh(float3);
-extern float4 __attribute__((overloadable)) tanh(float4);
-extern float8 __attribute__((overloadable)) tanh(float8);
-extern float16 __attribute__((overloadable)) tanh(float16);
+DEF_FUNC_1(tanh)
-extern float __attribute__((overloadable)) tanpi(float);
-extern float2 __attribute__((overloadable)) tanpi(float2);
-extern float3 __attribute__((overloadable)) tanpi(float3);
-extern float4 __attribute__((overloadable)) tanpi(float4);
-extern float8 __attribute__((overloadable)) tanpi(float8);
-extern float16 __attribute__((overloadable)) tanpi(float16);
+static float __attribute__((overloadable)) tanpi(float v) {
+ return tan(v * M_PI);
+}
+DEF_FUNC_1(tanpi)
extern float __attribute__((overloadable)) tgamma(float);
-extern float2 __attribute__((overloadable)) tgamma(float2);
-extern float3 __attribute__((overloadable)) tgamma(float3);
-extern float4 __attribute__((overloadable)) tgamma(float4);
-extern float8 __attribute__((overloadable)) tgamma(float8);
-extern float16 __attribute__((overloadable)) tgamma(float16);
+DEF_FUNC_1(tgamma)
extern float __attribute__((overloadable)) trunc(float);
-extern float2 __attribute__((overloadable)) trunc(float2);
-extern float3 __attribute__((overloadable)) trunc(float3);
-extern float4 __attribute__((overloadable)) trunc(float4);
-extern float8 __attribute__((overloadable)) trunc(float8);
-extern float16 __attribute__((overloadable)) trunc(float16);
+DEF_FUNC_1(trunc)
// Int ops (partial), 6.11.3
extern uint __attribute__((overloadable)) abs(int);
@@ -481,140 +437,349 @@
extern uchar __attribute__((overloadable)) clz(uchar);
extern char __attribute__((overloadable)) clz(char);
-extern uint __attribute__((overloadable)) min(uint, uint);
-extern int __attribute__((overloadable)) min(int, int);
-extern ushort __attribute__((overloadable)) min(ushort, ushort);
-extern short __attribute__((overloadable)) min(short, short);
-extern uchar __attribute__((overloadable)) min(uchar, uchar);
-extern char __attribute__((overloadable)) min(char, char);
+static uint __attribute__((overloadable)) min(uint v1, uint v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static int __attribute__((overloadable)) min(int v1, int v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static ushort __attribute__((overloadable)) min(ushort v1, ushort v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static short __attribute__((overloadable)) min(short v1, short v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static uchar __attribute__((overloadable)) min(uchar v1, uchar v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static char __attribute__((overloadable)) min(char v1, char v2) {
+ return v1 < v2 ? v1 : v2;
+}
-extern uint __attribute__((overloadable)) max(uint, uint);
-extern int __attribute__((overloadable)) max(int, int);
-extern ushort __attribute__((overloadable)) max(ushort, ushort);
-extern short __attribute__((overloadable)) max(short, short);
-extern uchar __attribute__((overloadable)) max(uchar, uchar);
-extern char __attribute__((overloadable)) max(char, char);
+static uint __attribute__((overloadable)) max(uint v1, uint v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static int __attribute__((overloadable)) max(int v1, int v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static ushort __attribute__((overloadable)) max(ushort v1, ushort v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static short __attribute__((overloadable)) max(short v1, short v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static uchar __attribute__((overloadable)) max(uchar v1, uchar v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static char __attribute__((overloadable)) max(char v1, char v2) {
+ return v1 > v2 ? v1 : v2;
+}
// 6.11.4
-extern float __attribute__((overloadable)) clamp(float, float, float);
-extern float2 __attribute__((overloadable)) clamp(float2, float2, float2);
-extern float3 __attribute__((overloadable)) clamp(float3, float3, float3);
-extern float4 __attribute__((overloadable)) clamp(float4, float4, float4);
-extern float8 __attribute__((overloadable)) clamp(float8, float8, float8);
-extern float16 __attribute__((overloadable)) clamp(float16, float16, float16);
-extern float2 __attribute__((overloadable)) clamp(float2, float, float);
-extern float3 __attribute__((overloadable)) clamp(float3, float, float);
-extern float4 __attribute__((overloadable)) clamp(float4, float, float);
-extern float8 __attribute__((overloadable)) clamp(float8, float, float);
-extern float16 __attribute__((overloadable)) clamp(float16, float, float);
+static float __attribute__((overloadable)) clamp(float amount, float low, float high) {
+ return amount < low ? low : (amount > high ? high : amount);
+}
+static float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high) {
+ float2 r;
+ r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
+ r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
+ return r;
+}
+static float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high) {
+ float3 r;
+ r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
+ r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
+ r.z = amount.z < low.z ? low.z : (amount.z > high.z ? high.z : amount.z);
+ return r;
+}
+static float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high) {
+ float4 r;
+ r.x = amount.x < low.x ? low.x : (amount.x > high.x ? high.x : amount.x);
+ r.y = amount.y < low.y ? low.y : (amount.y > high.y ? high.y : amount.y);
+ r.z = amount.z < low.z ? low.z : (amount.z > high.z ? high.z : amount.z);
+ r.w = amount.w < low.w ? low.w : (amount.w > high.w ? high.w : amount.w);
+ return r;
+}
+static float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high) {
+ float2 r;
+ r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
+ r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
+ return r;
+}
+static float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high) {
+ float3 r;
+ r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
+ r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
+ r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
+ return r;
+}
+static float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high) {
+ float4 r;
+ r.x = amount.x < low ? low : (amount.x > high ? high : amount.x);
+ r.y = amount.y < low ? low : (amount.y > high ? high : amount.y);
+ r.z = amount.z < low ? low : (amount.z > high ? high : amount.z);
+ r.w = amount.w < low ? low : (amount.w > high ? high : amount.w);
+ return r;
+}
-extern float __attribute__((overloadable)) degrees(float);
-extern float2 __attribute__((overloadable)) degrees(float2);
-extern float3 __attribute__((overloadable)) degrees(float3);
-extern float4 __attribute__((overloadable)) degrees(float4);
-extern float8 __attribute__((overloadable)) degrees(float8);
-extern float16 __attribute__((overloadable)) degrees(float16);
+static float __attribute__((overloadable)) degrees(float radians) {
+ return radians * (180.f / M_PI);
+}
+DEF_FUNC_1(degrees)
-extern float __attribute__((overloadable)) max(float, float);
-extern float2 __attribute__((overloadable)) max(float2, float2);
-extern float3 __attribute__((overloadable)) max(float3, float3);
-extern float4 __attribute__((overloadable)) max(float4, float4);
-extern float8 __attribute__((overloadable)) max(float8, float8);
-extern float16 __attribute__((overloadable)) max(float16, float16);
-extern float2 __attribute__((overloadable)) max(float2, float);
-extern float3 __attribute__((overloadable)) max(float3, float);
-extern float4 __attribute__((overloadable)) max(float4, float);
-extern float8 __attribute__((overloadable)) max(float8, float);
-extern float16 __attribute__((overloadable)) max(float16, float);
+static float __attribute__((overloadable)) max(float v1, float v2) {
+ return v1 > v2 ? v1 : v2;
+}
+static float2 __attribute__((overloadable)) max(float2 v1, float2 v2) {
+ float2 r;
+ r.x = v1.x > v2.x ? v1.x : v2.x;
+ r.y = v1.y > v2.y ? v1.y : v2.y;
+ return r;
+}
+static float3 __attribute__((overloadable)) max(float3 v1, float3 v2) {
+ float3 r;
+ r.x = v1.x > v2.x ? v1.x : v2.x;
+ r.y = v1.y > v2.y ? v1.y : v2.y;
+ r.z = v1.z > v2.z ? v1.z : v2.z;
+ return r;
+}
+static float4 __attribute__((overloadable)) max(float4 v1, float4 v2) {
+ float4 r;
+ r.x = v1.x > v2.x ? v1.x : v2.x;
+ r.y = v1.y > v2.y ? v1.y : v2.y;
+ r.z = v1.z > v2.z ? v1.z : v2.z;
+ r.w = v1.w > v2.w ? v1.w : v2.w;
+ return r;
+}
+static float2 __attribute__((overloadable)) max(float2 v1, float v2) {
+ float2 r;
+ r.x = v1.x > v2 ? v1.x : v2;
+ r.y = v1.y > v2 ? v1.y : v2;
+ return r;
+}
+static float3 __attribute__((overloadable)) max(float3 v1, float v2) {
+ float3 r;
+ r.x = v1.x > v2 ? v1.x : v2;
+ r.y = v1.y > v2 ? v1.y : v2;
+ r.z = v1.z > v2 ? v1.z : v2;
+ return r;
+}
+static float4 __attribute__((overloadable)) max(float4 v1, float v2) {
+ float4 r;
+ r.x = v1.x > v2 ? v1.x : v2;
+ r.y = v1.y > v2 ? v1.y : v2;
+ r.z = v1.z > v2 ? v1.z : v2;
+ r.w = v1.w > v2 ? v1.w : v2;
+ return r;
+}
-extern float __attribute__((overloadable)) min(float, float);
-extern float2 __attribute__((overloadable)) min(float2, float2);
-extern float3 __attribute__((overloadable)) min(float3, float3);
-extern float4 __attribute__((overloadable)) min(float4, float4);
-extern float8 __attribute__((overloadable)) min(float8, float8);
-extern float16 __attribute__((overloadable)) min(float16, float16);
-extern float2 __attribute__((overloadable)) min(float2, float);
-extern float3 __attribute__((overloadable)) min(float3, float);
-extern float4 __attribute__((overloadable)) min(float4, float);
-extern float8 __attribute__((overloadable)) min(float8, float);
-extern float16 __attribute__((overloadable)) min(float16, float);
+static float __attribute__((overloadable)) min(float v1, float v2) {
+ return v1 < v2 ? v1 : v2;
+}
+static float2 __attribute__((overloadable)) min(float2 v1, float2 v2) {
+ float2 r;
+ r.x = v1.x < v2.x ? v1.x : v2.x;
+ r.y = v1.y < v2.y ? v1.y : v2.y;
+ return r;
+}
+static float3 __attribute__((overloadable)) min(float3 v1, float3 v2) {
+ float3 r;
+ r.x = v1.x < v2.x ? v1.x : v2.x;
+ r.y = v1.y < v2.y ? v1.y : v2.y;
+ r.z = v1.z < v2.z ? v1.z : v2.z;
+ return r;
+}
+static float4 __attribute__((overloadable)) min(float4 v1, float4 v2) {
+ float4 r;
+ r.x = v1.x < v2.x ? v1.x : v2.x;
+ r.y = v1.y < v2.y ? v1.y : v2.y;
+ r.z = v1.z < v2.z ? v1.z : v2.z;
+ r.w = v1.w < v2.w ? v1.w : v2.w;
+ return r;
+}
+static float2 __attribute__((overloadable)) min(float2 v1, float v2) {
+ float2 r;
+ r.x = v1.x < v2 ? v1.x : v2;
+ r.y = v1.y < v2 ? v1.y : v2;
+ return r;
+}
+static float3 __attribute__((overloadable)) min(float3 v1, float v2) {
+ float3 r;
+ r.x = v1.x < v2 ? v1.x : v2;
+ r.y = v1.y < v2 ? v1.y : v2;
+ r.z = v1.z < v2 ? v1.z : v2;
+ return r;
+}
+static float4 __attribute__((overloadable)) min(float4 v1, float v2) {
+ float4 r;
+ r.x = v1.x < v2 ? v1.x : v2;
+ r.y = v1.y < v2 ? v1.y : v2;
+ r.z = v1.z < v2 ? v1.z : v2;
+ r.w = v1.w < v2 ? v1.w : v2;
+ return r;
+}
-extern float __attribute__((overloadable)) mix(float, float, float);
-extern float2 __attribute__((overloadable)) mix(float2, float2, float2);
-extern float3 __attribute__((overloadable)) mix(float3, float3, float3);
-extern float4 __attribute__((overloadable)) mix(float4, float4, float4);
-extern float8 __attribute__((overloadable)) mix(float8, float8, float8);
-extern float16 __attribute__((overloadable)) mix(float16, float16, float16);
-extern float2 __attribute__((overloadable)) mix(float2, float2, float);
-extern float3 __attribute__((overloadable)) mix(float3, float3, float);
-extern float4 __attribute__((overloadable)) mix(float4, float4, float);
-extern float8 __attribute__((overloadable)) mix(float8, float8, float);
-extern float16 __attribute__((overloadable)) mix(float16, float16, float);
+static float __attribute__((overloadable)) mix(float start, float stop, float amount) {
+ return start + (stop - start) * amount;
+}
+static float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount) {
+ return start + (stop - start) * amount;
+}
+static float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount) {
+ return start + (stop - start) * amount;
+}
+static float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount) {
+ return start + (stop - start) * amount;
+}
+static float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount) {
+ return start + (stop - start) * amount;
+}
+static float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount) {
+ return start + (stop - start) * amount;
+}
+static float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount) {
+ return start + (stop - start) * amount;
+}
-extern float __attribute__((overloadable)) radians(float);
-extern float2 __attribute__((overloadable)) radians(float2);
-extern float3 __attribute__((overloadable)) radians(float3);
-extern float4 __attribute__((overloadable)) radians(float4);
-extern float8 __attribute__((overloadable)) radians(float8);
-extern float16 __attribute__((overloadable)) radians(float16);
+static float __attribute__((overloadable)) radians(float degrees) {
+ return degrees * (M_PI / 180.f);
+}
+DEF_FUNC_1(radians)
-extern float __attribute__((overloadable)) step(float, float);
-extern float2 __attribute__((overloadable)) step(float2, float2);
-extern float3 __attribute__((overloadable)) step(float3, float3);
-extern float4 __attribute__((overloadable)) step(float4, float4);
-extern float8 __attribute__((overloadable)) step(float8, float8);
-extern float16 __attribute__((overloadable)) step(float16, float16);
-extern float2 __attribute__((overloadable)) step(float, float2);
-extern float3 __attribute__((overloadable)) step(float, float3);
-extern float4 __attribute__((overloadable)) step(float, float4);
-extern float8 __attribute__((overloadable)) step(float, float8);
-extern float16 __attribute__((overloadable)) step(float, float16);
+static float __attribute__((overloadable)) step(float edge, float v) {
+ return (v < edge) ? 0.f : 1.f;
+}
+static float2 __attribute__((overloadable)) step(float2 edge, float2 v) {
+ float2 r;
+ r.x = (v.x < edge.x) ? 0.f : 1.f;
+ r.y = (v.y < edge.y) ? 0.f : 1.f;
+ return r;
+}
+static float3 __attribute__((overloadable)) step(float3 edge, float3 v) {
+ float3 r;
+ r.x = (v.x < edge.x) ? 0.f : 1.f;
+ r.y = (v.y < edge.y) ? 0.f : 1.f;
+ r.z = (v.z < edge.z) ? 0.f : 1.f;
+ return r;
+}
+static float4 __attribute__((overloadable)) step(float4 edge, float4 v) {
+ float4 r;
+ r.x = (v.x < edge.x) ? 0.f : 1.f;
+ r.y = (v.y < edge.y) ? 0.f : 1.f;
+ r.z = (v.z < edge.z) ? 0.f : 1.f;
+ r.w = (v.w < edge.w) ? 0.f : 1.f;
+ return r;
+}
+static float2 __attribute__((overloadable)) step(float2 edge, float v) {
+ float2 r;
+ r.x = (v < edge.x) ? 0.f : 1.f;
+ r.y = (v < edge.y) ? 0.f : 1.f;
+ return r;
+}
+static float3 __attribute__((overloadable)) step(float3 edge, float v) {
+ float3 r;
+ r.x = (v < edge.x) ? 0.f : 1.f;
+ r.y = (v < edge.y) ? 0.f : 1.f;
+ r.z = (v < edge.z) ? 0.f : 1.f;
+ return r;
+}
+static float4 __attribute__((overloadable)) step(float4 edge, float v) {
+ float4 r;
+ r.x = (v < edge.x) ? 0.f : 1.f;
+ r.y = (v < edge.y) ? 0.f : 1.f;
+ r.z = (v < edge.z) ? 0.f : 1.f;
+ r.w = (v < edge.w) ? 0.f : 1.f;
+ return r;
+}
extern float __attribute__((overloadable)) smoothstep(float, float, float);
extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
-extern float8 __attribute__((overloadable)) smoothstep(float8, float8, float8);
-extern float16 __attribute__((overloadable)) smoothstep(float16, float16, float16);
extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
-extern float8 __attribute__((overloadable)) smoothstep(float, float, float8);
-extern float16 __attribute__((overloadable)) smoothstep(float, float, float16);
-extern float __attribute__((overloadable)) sign(float);
-extern float2 __attribute__((overloadable)) sign(float2);
-extern float3 __attribute__((overloadable)) sign(float3);
-extern float4 __attribute__((overloadable)) sign(float4);
-extern float8 __attribute__((overloadable)) sign(float8);
-extern float16 __attribute__((overloadable)) sign(float16);
+static float __attribute__((overloadable)) sign(float v) {
+ if (v > 0) return 1.f;
+ if (v < 0) return -1.f;
+ return v;
+}
+DEF_FUNC_1(sign)
// 6.11.5
-extern float3 __attribute__((overloadable)) cross(float2, float2);
-extern float3 __attribute__((overloadable)) cross(float3, float3);
-extern float4 __attribute__((overloadable)) cross(float4, float4);
+static float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs) {
+ float3 r;
+ r.x = lhs.y * rhs.z - lhs.z * rhs.y;
+ r.y = lhs.z * rhs.x - lhs.x * rhs.z;
+ r.z = lhs.x * rhs.y - lhs.y * rhs.x;
+ return r;
+}
-extern float __attribute__((overloadable)) dot(float, float);
-extern float __attribute__((overloadable)) dot(float2, float2);
-extern float __attribute__((overloadable)) dot(float3, float3);
-extern float __attribute__((overloadable)) dot(float4, float4);
+static float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs) {
+ float4 r;
+ r.x = lhs.y * rhs.z - lhs.z * rhs.y;
+ r.y = lhs.z * rhs.x - lhs.x * rhs.z;
+ r.z = lhs.x * rhs.y - lhs.y * rhs.x;
+ r.w = 0.f;
+ return r;
+}
-extern float __attribute__((overloadable)) distance(float, float);
-extern float __attribute__((overloadable)) distance(float2, float2);
-extern float __attribute__((overloadable)) distance(float3, float3);
-extern float __attribute__((overloadable)) distance(float4, float4);
+static float __attribute__((overloadable)) dot(float lhs, float rhs) {
+ return lhs * rhs;
+}
+static float __attribute__((overloadable)) dot(float2 lhs, float2 rhs) {
+ return lhs.x*rhs.x + lhs.y*rhs.y;
+}
+static float __attribute__((overloadable)) dot(float3 lhs, float3 rhs) {
+ return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z;
+}
+static float __attribute__((overloadable)) dot(float4 lhs, float4 rhs) {
+ return lhs.x*rhs.x + lhs.y*rhs.y + lhs.z*rhs.z + lhs.w*rhs.w;
+}
-extern float __attribute__((overloadable)) length(float);
-extern float __attribute__((overloadable)) length(float2);
-extern float __attribute__((overloadable)) length(float3);
-extern float __attribute__((overloadable)) length(float4);
+static float __attribute__((overloadable)) length(float v) {
+ return v;
+}
+static float __attribute__((overloadable)) length(float2 v) {
+ return sqrt(v.x*v.x + v.y*v.y);
+}
+static float __attribute__((overloadable)) length(float3 v) {
+ return sqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+}
+static float __attribute__((overloadable)) length(float4 v) {
+ return sqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w);
+}
-extern float __attribute__((overloadable)) normalize(float);
-extern float2 __attribute__((overloadable)) normalize(float2);
-extern float3 __attribute__((overloadable)) normalize(float3);
-extern float4 __attribute__((overloadable)) normalize(float4);
+static float __attribute__((overloadable)) distance(float lhs, float rhs) {
+ return length(lhs - rhs);
+}
+static float __attribute__((overloadable)) distance(float2 lhs, float2 rhs) {
+ return length(lhs - rhs);
+}
+static float __attribute__((overloadable)) distance(float3 lhs, float3 rhs) {
+ return length(lhs - rhs);
+}
+static float __attribute__((overloadable)) distance(float4 lhs, float4 rhs) {
+ return length(lhs - rhs);
+}
+static float __attribute__((overloadable)) normalize(float v) {
+ return 1.f;
+}
+static float2 __attribute__((overloadable)) normalize(float2 v) {
+ return v / length(v);
+}
+static float3 __attribute__((overloadable)) normalize(float3 v) {
+ return v / length(v);
+}
+static float4 __attribute__((overloadable)) normalize(float4 v) {
+ return v / length(v);
+}
+
+
+#endif