blob: d78e62e1d54a814a93e6281ba2df313fe7cb4ca9 [file] [log] [blame]
Jason Sams1b937f52010-06-09 14:26:16 -07001#ifndef __RS_CL_RSH__
2#define __RS_CL_RSH__
3
Shih-wei Liaoe31775b2011-01-26 17:04:31 -08004#define _RS_RUNTIME extern
Jason Sams1b937f52010-06-09 14:26:16 -07005
Jason Sams1b937f52010-06-09 14:26:16 -07006// Conversions
Stephen Hines47b15302011-01-19 18:06:34 -08007#define CVT_FUNC_2(typeout, typein) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -08008_RS_RUNTIME typeout##2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -08009 convert_##typeout##2(typein##2 v); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080010_RS_RUNTIME typeout##3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080011 convert_##typeout##3(typein##3 v); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080012_RS_RUNTIME typeout##4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080013 convert_##typeout##4(typein##4 v);
14
Jason Sams1b937f52010-06-09 14:26:16 -070015
Stephen Hines47b15302011-01-19 18:06:34 -080016#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \
17 CVT_FUNC_2(type, char) \
18 CVT_FUNC_2(type, ushort) \
19 CVT_FUNC_2(type, short) \
20 CVT_FUNC_2(type, uint) \
21 CVT_FUNC_2(type, int) \
22 CVT_FUNC_2(type, float)
Jason Sams1b937f52010-06-09 14:26:16 -070023
24CVT_FUNC(char)
25CVT_FUNC(uchar)
26CVT_FUNC(short)
27CVT_FUNC(ushort)
28CVT_FUNC(int)
29CVT_FUNC(uint)
30CVT_FUNC(float)
31
Jason Sams22fa3712010-05-19 17:22:57 -070032// Float ops, 6.11.2
33
Stephen Hines47b15302011-01-19 18:06:34 -080034#define FN_FUNC_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080035_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \
36_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \
37_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v);
Jason Sams1b937f52010-06-09 14:26:16 -070038
Stephen Hines47b15302011-01-19 18:06:34 -080039#define IN_FUNC_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080040_RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v); \
41_RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v); \
42_RS_RUNTIME int4 __attribute__((overloadable)) fnc(float4 v);
Stephen Hines47416532011-01-11 14:38:18 -080043
Stephen Hines47b15302011-01-19 18:06:34 -080044#define FN_FUNC_FN_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080045_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
46_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
47_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
Jason Sams1b937f52010-06-09 14:26:16 -070048
Stephen Hines47b15302011-01-19 18:06:34 -080049#define FN_FUNC_FN_F(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080050_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2); \
51_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2); \
52_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
Jason Sams1b937f52010-06-09 14:26:16 -070053
Stephen Hines47b15302011-01-19 18:06:34 -080054#define FN_FUNC_FN_IN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080055_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2); \
56_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2); \
57_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2); \
Stephen Hines3e6482f2011-01-19 12:51:33 -080058
Stephen Hines47b15302011-01-19 18:06:34 -080059#define FN_FUNC_FN_I(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080060_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int v2); \
61_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int v2); \
62_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
Stephen Hines3e6482f2011-01-19 12:51:33 -080063
Stephen Hines47b15302011-01-19 18:06:34 -080064#define FN_FUNC_FN_PFN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080065_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080066 fnc(float2 v1, float2 *v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080067_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080068 fnc(float3 v1, float3 *v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080069_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080070 fnc(float4 v1, float4 *v2);
Jason Sams1b937f52010-06-09 14:26:16 -070071
Stephen Hines47b15302011-01-19 18:06:34 -080072#define FN_FUNC_FN_PIN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080073_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2); \
74_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2); \
75_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
Stephen Hines3e6482f2011-01-19 12:51:33 -080076
Stephen Hines47b15302011-01-19 18:06:34 -080077#define FN_FUNC_FN_FN_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080078_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080079 fnc(float2 v1, float2 v2, float2 v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080080_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080081 fnc(float3 v1, float3 v2, float3 v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080082_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080083 fnc(float4 v1, float4 v2, float4 v3);
Stephen Hines3e6482f2011-01-19 12:51:33 -080084
Stephen Hines47b15302011-01-19 18:06:34 -080085#define FN_FUNC_FN_FN_PIN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080086_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080087 fnc(float2 v1, float2 v2, int2 *v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080088_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080089 fnc(float3 v1, float3 v2, int3 *v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080090_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080091 fnc(float4 v1, float4 v2, int4 *v3);
Stephen Hines3e6482f2011-01-19 12:51:33 -080092
93
Jason Sams22fa3712010-05-19 17:22:57 -070094extern float __attribute__((overloadable)) acos(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -080095FN_FUNC_FN(acos)
Jason Sams22fa3712010-05-19 17:22:57 -070096
97extern float __attribute__((overloadable)) acosh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -080098FN_FUNC_FN(acosh)
Jason Sams22fa3712010-05-19 17:22:57 -070099
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800100_RS_RUNTIME float __attribute__((overloadable)) acospi(float v);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800101
102
Stephen Hines3e6482f2011-01-19 12:51:33 -0800103FN_FUNC_FN(acospi)
Jason Sams22fa3712010-05-19 17:22:57 -0700104
105extern float __attribute__((overloadable)) asin(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800106FN_FUNC_FN(asin)
Jason Sams22fa3712010-05-19 17:22:57 -0700107
108extern float __attribute__((overloadable)) asinh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800109FN_FUNC_FN(asinh)
Jason Sams22fa3712010-05-19 17:22:57 -0700110
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800111
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800112_RS_RUNTIME float __attribute__((overloadable)) asinpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800113FN_FUNC_FN(asinpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700114
115extern float __attribute__((overloadable)) atan(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800116FN_FUNC_FN(atan)
Jason Sams22fa3712010-05-19 17:22:57 -0700117
118extern float __attribute__((overloadable)) atan2(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800119FN_FUNC_FN_FN(atan2)
Jason Sams22fa3712010-05-19 17:22:57 -0700120
121extern float __attribute__((overloadable)) atanh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800122FN_FUNC_FN(atanh)
Jason Sams22fa3712010-05-19 17:22:57 -0700123
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800124
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800125_RS_RUNTIME float __attribute__((overloadable)) atanpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800126FN_FUNC_FN(atanpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700127
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800128
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800129_RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800130FN_FUNC_FN_FN(atan2pi)
Jason Sams22fa3712010-05-19 17:22:57 -0700131
132extern float __attribute__((overloadable)) cbrt(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800133FN_FUNC_FN(cbrt)
Jason Sams22fa3712010-05-19 17:22:57 -0700134
135extern float __attribute__((overloadable)) ceil(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800136FN_FUNC_FN(ceil)
Jason Sams22fa3712010-05-19 17:22:57 -0700137
138extern float __attribute__((overloadable)) copysign(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800139FN_FUNC_FN_FN(copysign)
Jason Sams22fa3712010-05-19 17:22:57 -0700140
141extern float __attribute__((overloadable)) cos(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800142FN_FUNC_FN(cos)
Jason Sams22fa3712010-05-19 17:22:57 -0700143
144extern float __attribute__((overloadable)) cosh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800145FN_FUNC_FN(cosh)
Jason Sams22fa3712010-05-19 17:22:57 -0700146
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800147
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800148_RS_RUNTIME float __attribute__((overloadable)) cospi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800149FN_FUNC_FN(cospi)
Jason Sams22fa3712010-05-19 17:22:57 -0700150
151extern float __attribute__((overloadable)) erfc(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800152FN_FUNC_FN(erfc)
Jason Sams22fa3712010-05-19 17:22:57 -0700153
154extern float __attribute__((overloadable)) erf(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800155FN_FUNC_FN(erf)
Jason Sams22fa3712010-05-19 17:22:57 -0700156
157extern float __attribute__((overloadable)) exp(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800158FN_FUNC_FN(exp)
Jason Sams22fa3712010-05-19 17:22:57 -0700159
160extern float __attribute__((overloadable)) exp2(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800161FN_FUNC_FN(exp2)
Jason Sams22fa3712010-05-19 17:22:57 -0700162
Jason Sams1b937f52010-06-09 14:26:16 -0700163extern float __attribute__((overloadable)) pow(float, float);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800164
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800165_RS_RUNTIME float __attribute__((overloadable)) exp10(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800166FN_FUNC_FN(exp10)
Jason Sams22fa3712010-05-19 17:22:57 -0700167
168extern float __attribute__((overloadable)) expm1(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800169FN_FUNC_FN(expm1)
Jason Sams22fa3712010-05-19 17:22:57 -0700170
171extern float __attribute__((overloadable)) fabs(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800172FN_FUNC_FN(fabs)
Jason Sams22fa3712010-05-19 17:22:57 -0700173
174extern float __attribute__((overloadable)) fdim(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800175FN_FUNC_FN_FN(fdim)
Jason Sams22fa3712010-05-19 17:22:57 -0700176
177extern float __attribute__((overloadable)) floor(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800178FN_FUNC_FN(floor)
Jason Sams22fa3712010-05-19 17:22:57 -0700179
180extern float __attribute__((overloadable)) fma(float, float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800181FN_FUNC_FN_FN_FN(fma)
Jason Sams22fa3712010-05-19 17:22:57 -0700182
183extern float __attribute__((overloadable)) fmax(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800184FN_FUNC_FN_FN(fmax);
185FN_FUNC_FN_F(fmax);
Jason Sams22fa3712010-05-19 17:22:57 -0700186
187extern float __attribute__((overloadable)) fmin(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800188FN_FUNC_FN_FN(fmin);
189FN_FUNC_FN_F(fmin);
Jason Sams22fa3712010-05-19 17:22:57 -0700190
191extern float __attribute__((overloadable)) fmod(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800192FN_FUNC_FN_FN(fmod)
Jason Sams22fa3712010-05-19 17:22:57 -0700193
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800194
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800195_RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr);
Stephen Hines47b15302011-01-19 18:06:34 -0800196FN_FUNC_FN_PFN(fract)
Jason Sams22fa3712010-05-19 17:22:57 -0700197
Stephen Hines3e6482f2011-01-19 12:51:33 -0800198extern float __attribute__((overloadable)) frexp(float, int *);
199FN_FUNC_FN_PIN(frexp)
Jason Sams22fa3712010-05-19 17:22:57 -0700200
201extern float __attribute__((overloadable)) hypot(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800202FN_FUNC_FN_FN(hypot)
Jason Sams22fa3712010-05-19 17:22:57 -0700203
204extern int __attribute__((overloadable)) ilogb(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800205IN_FUNC_FN(ilogb)
Jason Sams22fa3712010-05-19 17:22:57 -0700206
207extern float __attribute__((overloadable)) ldexp(float, int);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800208FN_FUNC_FN_IN(ldexp)
209FN_FUNC_FN_I(ldexp)
Jason Sams22fa3712010-05-19 17:22:57 -0700210
211extern float __attribute__((overloadable)) lgamma(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800212FN_FUNC_FN(lgamma)
213extern float __attribute__((overloadable)) lgamma(float, int*);
214FN_FUNC_FN_PIN(lgamma)
Jason Sams22fa3712010-05-19 17:22:57 -0700215
216extern float __attribute__((overloadable)) log(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800217FN_FUNC_FN(log)
Jason Sams22fa3712010-05-19 17:22:57 -0700218
Jason Sams22fa3712010-05-19 17:22:57 -0700219
220extern float __attribute__((overloadable)) log10(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800221FN_FUNC_FN(log10)
Jason Sams1b937f52010-06-09 14:26:16 -0700222
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800223
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800224_RS_RUNTIME float __attribute__((overloadable)) log2(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800225FN_FUNC_FN(log2)
Jason Sams22fa3712010-05-19 17:22:57 -0700226
227extern float __attribute__((overloadable)) log1p(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800228FN_FUNC_FN(log1p)
Jason Sams22fa3712010-05-19 17:22:57 -0700229
230extern float __attribute__((overloadable)) logb(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800231FN_FUNC_FN(logb)
Jason Sams22fa3712010-05-19 17:22:57 -0700232
233extern float __attribute__((overloadable)) mad(float, float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800234FN_FUNC_FN_FN_FN(mad)
Jason Sams22fa3712010-05-19 17:22:57 -0700235
236extern float __attribute__((overloadable)) modf(float, float *);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800237FN_FUNC_FN_PFN(modf);
Jason Sams22fa3712010-05-19 17:22:57 -0700238
Jason Sams1b937f52010-06-09 14:26:16 -0700239//extern float __attribute__((overloadable)) nan(uint);
Jason Sams22fa3712010-05-19 17:22:57 -0700240
241extern float __attribute__((overloadable)) nextafter(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800242FN_FUNC_FN_FN(nextafter)
Jason Sams22fa3712010-05-19 17:22:57 -0700243
Stephen Hines3e6482f2011-01-19 12:51:33 -0800244FN_FUNC_FN_FN(pow)
Jason Sams22fa3712010-05-19 17:22:57 -0700245
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800246_RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p);
247_RS_RUNTIME float2 __attribute__((overloadable)) pown(float2 v, int2 p);
248_RS_RUNTIME float3 __attribute__((overloadable)) pown(float3 v, int3 p);
249_RS_RUNTIME float4 __attribute__((overloadable)) pown(float4 v, int4 p);
Jason Sams22fa3712010-05-19 17:22:57 -0700250
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800251_RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p);
252_RS_RUNTIME float2 __attribute__((overloadable)) powr(float2 v, float2 p);
253_RS_RUNTIME float3 __attribute__((overloadable)) powr(float3 v, float3 p);
254_RS_RUNTIME float4 __attribute__((overloadable)) powr(float4 v, float4 p);
Jason Sams22fa3712010-05-19 17:22:57 -0700255
256extern float __attribute__((overloadable)) remainder(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800257FN_FUNC_FN_FN(remainder)
Jason Sams22fa3712010-05-19 17:22:57 -0700258
Stephen Hines47416532011-01-11 14:38:18 -0800259extern float __attribute__((overloadable)) remquo(float, float, int *);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800260FN_FUNC_FN_FN_PIN(remquo)
Jason Sams22fa3712010-05-19 17:22:57 -0700261
262extern float __attribute__((overloadable)) rint(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800263FN_FUNC_FN(rint)
Jason Sams22fa3712010-05-19 17:22:57 -0700264
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800265
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800266_RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int r);
267_RS_RUNTIME float2 __attribute__((overloadable)) rootn(float2 v, int2 r);
268_RS_RUNTIME float3 __attribute__((overloadable)) rootn(float3 v, int3 r);
269_RS_RUNTIME float4 __attribute__((overloadable)) rootn(float4 v, int4 r);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800270
Jason Sams22fa3712010-05-19 17:22:57 -0700271
272extern float __attribute__((overloadable)) round(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800273FN_FUNC_FN(round)
Jason Sams22fa3712010-05-19 17:22:57 -0700274
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800275
Jason Sams22fa3712010-05-19 17:22:57 -0700276extern float __attribute__((overloadable)) sqrt(float);
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800277_RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800278FN_FUNC_FN(rsqrt)
Jason Sams1b937f52010-06-09 14:26:16 -0700279
280extern float __attribute__((overloadable)) sin(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800281FN_FUNC_FN(sin)
Jason Sams1b937f52010-06-09 14:26:16 -0700282
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800283_RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr);
284_RS_RUNTIME float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr);
285_RS_RUNTIME float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr);
286_RS_RUNTIME float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr);
Jason Sams1b937f52010-06-09 14:26:16 -0700287
288extern float __attribute__((overloadable)) sinh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800289FN_FUNC_FN(sinh)
Jason Sams1b937f52010-06-09 14:26:16 -0700290
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800291_RS_RUNTIME float __attribute__((overloadable)) sinpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800292FN_FUNC_FN(sinpi)
Jason Sams1b937f52010-06-09 14:26:16 -0700293
Stephen Hines3e6482f2011-01-19 12:51:33 -0800294FN_FUNC_FN(sqrt)
Jason Sams22fa3712010-05-19 17:22:57 -0700295
296extern float __attribute__((overloadable)) tan(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800297FN_FUNC_FN(tan)
Jason Sams22fa3712010-05-19 17:22:57 -0700298
299extern float __attribute__((overloadable)) tanh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800300FN_FUNC_FN(tanh)
Jason Sams22fa3712010-05-19 17:22:57 -0700301
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800302_RS_RUNTIME float __attribute__((overloadable)) tanpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800303FN_FUNC_FN(tanpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700304
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800305
Jason Sams22fa3712010-05-19 17:22:57 -0700306extern float __attribute__((overloadable)) tgamma(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800307FN_FUNC_FN(tgamma)
Jason Sams22fa3712010-05-19 17:22:57 -0700308
309extern float __attribute__((overloadable)) trunc(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800310FN_FUNC_FN(trunc)
Jason Sams22fa3712010-05-19 17:22:57 -0700311
312// Int ops (partial), 6.11.3
Jason Sams22fa3712010-05-19 17:22:57 -0700313
Stephen Hines47b15302011-01-19 18:06:34 -0800314#define XN_FUNC_YN(typeout, fnc, typein) \
315extern typeout __attribute__((overloadable)) fnc(typein); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800316_RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v); \
317_RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v); \
318_RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
Jason Sams22fa3712010-05-19 17:22:57 -0700319
Stephen Hines47b15302011-01-19 18:06:34 -0800320#define UIN_FUNC_IN(fnc) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800321XN_FUNC_YN(uchar, fnc, char) \
322XN_FUNC_YN(ushort, fnc, short) \
323XN_FUNC_YN(uint, fnc, int)
Jason Sams22fa3712010-05-19 17:22:57 -0700324
Stephen Hines47b15302011-01-19 18:06:34 -0800325#define IN_FUNC_IN(fnc) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800326XN_FUNC_YN(uchar, fnc, uchar) \
327XN_FUNC_YN(char, fnc, char) \
328XN_FUNC_YN(ushort, fnc, ushort) \
329XN_FUNC_YN(short, fnc, short) \
330XN_FUNC_YN(uint, fnc, uint) \
331XN_FUNC_YN(int, fnc, int)
Jason Sams22fa3712010-05-19 17:22:57 -0700332
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800333
Stephen Hines47b15302011-01-19 18:06:34 -0800334#define XN_FUNC_XN_XN_BODY(type, fnc, body) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800335_RS_RUNTIME type __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800336 fnc(type v1, type v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800337_RS_RUNTIME type##2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800338 fnc(type##2 v1, type##2 v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800339_RS_RUNTIME type##3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800340 fnc(type##3 v1, type##3 v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800341_RS_RUNTIME type##4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800342 fnc(type##4 v1, type##4 v2);
Jason Sams22fa3712010-05-19 17:22:57 -0700343
Stephen Hines47b15302011-01-19 18:06:34 -0800344#define IN_FUNC_IN_IN_BODY(fnc, body) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800345XN_FUNC_XN_XN_BODY(uchar, fnc, body) \
346XN_FUNC_XN_XN_BODY(char, fnc, body) \
347XN_FUNC_XN_XN_BODY(ushort, fnc, body) \
348XN_FUNC_XN_XN_BODY(short, fnc, body) \
349XN_FUNC_XN_XN_BODY(uint, fnc, body) \
350XN_FUNC_XN_XN_BODY(int, fnc, body) \
351XN_FUNC_XN_XN_BODY(float, fnc, body)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800352
Stephen Hines3e6482f2011-01-19 12:51:33 -0800353UIN_FUNC_IN(abs)
354IN_FUNC_IN(clz)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800355
Stephen Hines3e6482f2011-01-19 12:51:33 -0800356IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2))
357FN_FUNC_FN_F(min)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800358
Stephen Hines3e6482f2011-01-19 12:51:33 -0800359IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2))
360FN_FUNC_FN_F(max)
Jason Sams22fa3712010-05-19 17:22:57 -0700361
362// 6.11.4
363
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800364_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
365_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high);
366_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high);
367_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high);
368_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high);
369_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high);
370_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high);
Jason Sams22fa3712010-05-19 17:22:57 -0700371
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800372_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800373FN_FUNC_FN(degrees)
Jason Sams22fa3712010-05-19 17:22:57 -0700374
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800375_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
376_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount);
377_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount);
378_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount);
379_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount);
380_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount);
381_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount);
Jason Sams22fa3712010-05-19 17:22:57 -0700382
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800383_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800384FN_FUNC_FN(radians)
Jason Sams22fa3712010-05-19 17:22:57 -0700385
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800386_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
387_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v);
388_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v);
389_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float4 v);
390_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float v);
391_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v);
392_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v);
Jason Sams22fa3712010-05-19 17:22:57 -0700393
394extern float __attribute__((overloadable)) smoothstep(float, float, float);
395extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
396extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
397extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
Jason Sams22fa3712010-05-19 17:22:57 -0700398extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
399extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
400extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
Jason Sams22fa3712010-05-19 17:22:57 -0700401
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800402_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800403FN_FUNC_FN(sign)
Jason Sams22fa3712010-05-19 17:22:57 -0700404
405// 6.11.5
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800406_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700407
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800408_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700409
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800410_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
411_RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs);
412_RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs);
413_RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700414
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800415_RS_RUNTIME float __attribute__((overloadable)) length(float v);
416_RS_RUNTIME float __attribute__((overloadable)) length(float2 v);
417_RS_RUNTIME float __attribute__((overloadable)) length(float3 v);
418_RS_RUNTIME float __attribute__((overloadable)) length(float4 v);
Jason Sams22fa3712010-05-19 17:22:57 -0700419
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800420_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
421_RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs);
422_RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs);
423_RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700424
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800425_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
426_RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v);
427_RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v);
428_RS_RUNTIME float4 __attribute__((overloadable)) normalize(float4 v);
Jason Sams1b937f52010-06-09 14:26:16 -0700429
Stephen Hines47416532011-01-11 14:38:18 -0800430#undef CVT_FUNC
431#undef CVT_FUNC_2
Stephen Hines3e6482f2011-01-19 12:51:33 -0800432#undef FN_FUNC_FN
433#undef IN_FUNC_FN
434#undef FN_FUNC_FN_FN
435#undef FN_FUNC_FN_F
436#undef FN_FUNC_FN_IN
437#undef FN_FUNC_FN_I
438#undef FN_FUNC_FN_PFN
439#undef FN_FUNC_FN_PIN
440#undef FN_FUNC_FN_FN_FN
441#undef FN_FUNC_FN_FN_PIN
442#undef XN_FUNC_YN
443#undef UIN_FUNC_IN
444#undef IN_FUNC_IN
445#undef XN_FUNC_XN_XN_BODY
446#undef IN_FUNC_IN_IN_BODY
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800447#undef _RS_RUNTIME
Jason Sams1b937f52010-06-09 14:26:16 -0700448
449#endif