blob: e402b86864c99e1d7e70a3fa5f159318c0ec3235 [file] [log] [blame]
Jason Sams044e2ee2011-08-08 16:52:30 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/** @file rs_cl.rsh
18 * \brief Additional compute routines
19 *
20 *
21 */
22
Jason Sams1b937f52010-06-09 14:26:16 -070023#ifndef __RS_CL_RSH__
24#define __RS_CL_RSH__
25
Jason Sams1b937f52010-06-09 14:26:16 -070026// Conversions
Stephen Hines47b15302011-01-19 18:06:34 -080027#define CVT_FUNC_2(typeout, typein) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080028_RS_RUNTIME typeout##2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080029 convert_##typeout##2(typein##2 v); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080030_RS_RUNTIME typeout##3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080031 convert_##typeout##3(typein##3 v); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080032_RS_RUNTIME typeout##4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080033 convert_##typeout##4(typein##4 v);
34
Jason Sams1b937f52010-06-09 14:26:16 -070035
Stephen Hines47b15302011-01-19 18:06:34 -080036#define CVT_FUNC(type) CVT_FUNC_2(type, uchar) \
37 CVT_FUNC_2(type, char) \
38 CVT_FUNC_2(type, ushort) \
39 CVT_FUNC_2(type, short) \
40 CVT_FUNC_2(type, uint) \
41 CVT_FUNC_2(type, int) \
42 CVT_FUNC_2(type, float)
Jason Sams1b937f52010-06-09 14:26:16 -070043
44CVT_FUNC(char)
45CVT_FUNC(uchar)
46CVT_FUNC(short)
47CVT_FUNC(ushort)
48CVT_FUNC(int)
49CVT_FUNC(uint)
50CVT_FUNC(float)
51
Jason Sams22fa3712010-05-19 17:22:57 -070052// Float ops, 6.11.2
53
Stephen Hines47b15302011-01-19 18:06:34 -080054#define FN_FUNC_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080055_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \
56_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \
57_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v);
Jason Sams1b937f52010-06-09 14:26:16 -070058
Stephen Hines47b15302011-01-19 18:06:34 -080059#define IN_FUNC_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080060_RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v); \
61_RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v); \
62_RS_RUNTIME int4 __attribute__((overloadable)) fnc(float4 v);
Stephen Hines47416532011-01-11 14:38:18 -080063
Stephen Hines47b15302011-01-19 18:06:34 -080064#define FN_FUNC_FN_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080065_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
66_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
67_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
Jason Sams1b937f52010-06-09 14:26:16 -070068
Stephen Hines47b15302011-01-19 18:06:34 -080069#define FN_FUNC_FN_F(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080070_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2); \
71_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2); \
72_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
Jason Sams1b937f52010-06-09 14:26:16 -070073
Stephen Hines47b15302011-01-19 18:06:34 -080074#define FN_FUNC_FN_IN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080075_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2); \
76_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2); \
77_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2); \
Stephen Hines3e6482f2011-01-19 12:51:33 -080078
Stephen Hines47b15302011-01-19 18:06:34 -080079#define FN_FUNC_FN_I(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080080_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int v2); \
81_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int v2); \
82_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
Stephen Hines3e6482f2011-01-19 12:51:33 -080083
Stephen Hines47b15302011-01-19 18:06:34 -080084#define FN_FUNC_FN_PFN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080085_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080086 fnc(float2 v1, float2 *v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080087_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080088 fnc(float3 v1, float3 *v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080089_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080090 fnc(float4 v1, float4 *v2);
Jason Sams1b937f52010-06-09 14:26:16 -070091
Stephen Hines47b15302011-01-19 18:06:34 -080092#define FN_FUNC_FN_PIN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080093_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2); \
94_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2); \
95_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
Stephen Hines3e6482f2011-01-19 12:51:33 -080096
Stephen Hines47b15302011-01-19 18:06:34 -080097#define FN_FUNC_FN_FN_FN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -080098_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -080099 fnc(float2 v1, float2 v2, float2 v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800100_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800101 fnc(float3 v1, float3 v2, float3 v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800102_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800103 fnc(float4 v1, float4 v2, float4 v3);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800104
Stephen Hines47b15302011-01-19 18:06:34 -0800105#define FN_FUNC_FN_FN_PIN(fnc) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800106_RS_RUNTIME float2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800107 fnc(float2 v1, float2 v2, int2 *v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800108_RS_RUNTIME float3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800109 fnc(float3 v1, float3 v2, int3 *v3); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800110_RS_RUNTIME float4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800111 fnc(float4 v1, float4 v2, int4 *v3);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800112
113
Jason Sams22fa3712010-05-19 17:22:57 -0700114extern float __attribute__((overloadable)) acos(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800115FN_FUNC_FN(acos)
Jason Sams22fa3712010-05-19 17:22:57 -0700116
117extern float __attribute__((overloadable)) acosh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800118FN_FUNC_FN(acosh)
Jason Sams22fa3712010-05-19 17:22:57 -0700119
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800120_RS_RUNTIME float __attribute__((overloadable)) acospi(float v);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800121
122
Stephen Hines3e6482f2011-01-19 12:51:33 -0800123FN_FUNC_FN(acospi)
Jason Sams22fa3712010-05-19 17:22:57 -0700124
125extern float __attribute__((overloadable)) asin(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800126FN_FUNC_FN(asin)
Jason Sams22fa3712010-05-19 17:22:57 -0700127
128extern float __attribute__((overloadable)) asinh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800129FN_FUNC_FN(asinh)
Jason Sams22fa3712010-05-19 17:22:57 -0700130
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800131
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800132_RS_RUNTIME float __attribute__((overloadable)) asinpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800133FN_FUNC_FN(asinpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700134
135extern float __attribute__((overloadable)) atan(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800136FN_FUNC_FN(atan)
Jason Sams22fa3712010-05-19 17:22:57 -0700137
138extern float __attribute__((overloadable)) atan2(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800139FN_FUNC_FN_FN(atan2)
Jason Sams22fa3712010-05-19 17:22:57 -0700140
141extern float __attribute__((overloadable)) atanh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800142FN_FUNC_FN(atanh)
Jason Sams22fa3712010-05-19 17:22:57 -0700143
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800144
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800145_RS_RUNTIME float __attribute__((overloadable)) atanpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800146FN_FUNC_FN(atanpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700147
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800148
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800149_RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800150FN_FUNC_FN_FN(atan2pi)
Jason Sams22fa3712010-05-19 17:22:57 -0700151
152extern float __attribute__((overloadable)) cbrt(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800153FN_FUNC_FN(cbrt)
Jason Sams22fa3712010-05-19 17:22:57 -0700154
155extern float __attribute__((overloadable)) ceil(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800156FN_FUNC_FN(ceil)
Jason Sams22fa3712010-05-19 17:22:57 -0700157
158extern float __attribute__((overloadable)) copysign(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800159FN_FUNC_FN_FN(copysign)
Jason Sams22fa3712010-05-19 17:22:57 -0700160
161extern float __attribute__((overloadable)) cos(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800162FN_FUNC_FN(cos)
Jason Sams22fa3712010-05-19 17:22:57 -0700163
164extern float __attribute__((overloadable)) cosh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800165FN_FUNC_FN(cosh)
Jason Sams22fa3712010-05-19 17:22:57 -0700166
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800167
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800168_RS_RUNTIME float __attribute__((overloadable)) cospi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800169FN_FUNC_FN(cospi)
Jason Sams22fa3712010-05-19 17:22:57 -0700170
171extern float __attribute__((overloadable)) erfc(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800172FN_FUNC_FN(erfc)
Jason Sams22fa3712010-05-19 17:22:57 -0700173
174extern float __attribute__((overloadable)) erf(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800175FN_FUNC_FN(erf)
Jason Sams22fa3712010-05-19 17:22:57 -0700176
177extern float __attribute__((overloadable)) exp(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800178FN_FUNC_FN(exp)
Jason Sams22fa3712010-05-19 17:22:57 -0700179
180extern float __attribute__((overloadable)) exp2(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800181FN_FUNC_FN(exp2)
Jason Sams22fa3712010-05-19 17:22:57 -0700182
Jason Sams1b937f52010-06-09 14:26:16 -0700183extern float __attribute__((overloadable)) pow(float, float);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800184
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800185_RS_RUNTIME float __attribute__((overloadable)) exp10(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800186FN_FUNC_FN(exp10)
Jason Sams22fa3712010-05-19 17:22:57 -0700187
188extern float __attribute__((overloadable)) expm1(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800189FN_FUNC_FN(expm1)
Jason Sams22fa3712010-05-19 17:22:57 -0700190
191extern float __attribute__((overloadable)) fabs(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800192FN_FUNC_FN(fabs)
Jason Sams22fa3712010-05-19 17:22:57 -0700193
194extern float __attribute__((overloadable)) fdim(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800195FN_FUNC_FN_FN(fdim)
Jason Sams22fa3712010-05-19 17:22:57 -0700196
197extern float __attribute__((overloadable)) floor(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800198FN_FUNC_FN(floor)
Jason Sams22fa3712010-05-19 17:22:57 -0700199
200extern float __attribute__((overloadable)) fma(float, float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800201FN_FUNC_FN_FN_FN(fma)
Jason Sams22fa3712010-05-19 17:22:57 -0700202
203extern float __attribute__((overloadable)) fmax(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800204FN_FUNC_FN_FN(fmax);
205FN_FUNC_FN_F(fmax);
Jason Sams22fa3712010-05-19 17:22:57 -0700206
207extern float __attribute__((overloadable)) fmin(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800208FN_FUNC_FN_FN(fmin);
209FN_FUNC_FN_F(fmin);
Jason Sams22fa3712010-05-19 17:22:57 -0700210
211extern float __attribute__((overloadable)) fmod(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800212FN_FUNC_FN_FN(fmod)
Jason Sams22fa3712010-05-19 17:22:57 -0700213
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800214
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800215_RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr);
Stephen Hines47b15302011-01-19 18:06:34 -0800216FN_FUNC_FN_PFN(fract)
Jason Sams22fa3712010-05-19 17:22:57 -0700217
Stephen Hines3e6482f2011-01-19 12:51:33 -0800218extern float __attribute__((overloadable)) frexp(float, int *);
219FN_FUNC_FN_PIN(frexp)
Jason Sams22fa3712010-05-19 17:22:57 -0700220
221extern float __attribute__((overloadable)) hypot(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800222FN_FUNC_FN_FN(hypot)
Jason Sams22fa3712010-05-19 17:22:57 -0700223
224extern int __attribute__((overloadable)) ilogb(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800225IN_FUNC_FN(ilogb)
Jason Sams22fa3712010-05-19 17:22:57 -0700226
227extern float __attribute__((overloadable)) ldexp(float, int);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800228FN_FUNC_FN_IN(ldexp)
229FN_FUNC_FN_I(ldexp)
Jason Sams22fa3712010-05-19 17:22:57 -0700230
231extern float __attribute__((overloadable)) lgamma(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800232FN_FUNC_FN(lgamma)
233extern float __attribute__((overloadable)) lgamma(float, int*);
234FN_FUNC_FN_PIN(lgamma)
Jason Sams22fa3712010-05-19 17:22:57 -0700235
236extern float __attribute__((overloadable)) log(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800237FN_FUNC_FN(log)
Jason Sams22fa3712010-05-19 17:22:57 -0700238
Jason Sams22fa3712010-05-19 17:22:57 -0700239
240extern float __attribute__((overloadable)) log10(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800241FN_FUNC_FN(log10)
Jason Sams1b937f52010-06-09 14:26:16 -0700242
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800243
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800244_RS_RUNTIME float __attribute__((overloadable)) log2(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800245FN_FUNC_FN(log2)
Jason Sams22fa3712010-05-19 17:22:57 -0700246
247extern float __attribute__((overloadable)) log1p(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800248FN_FUNC_FN(log1p)
Jason Sams22fa3712010-05-19 17:22:57 -0700249
250extern float __attribute__((overloadable)) logb(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800251FN_FUNC_FN(logb)
Jason Sams22fa3712010-05-19 17:22:57 -0700252
253extern float __attribute__((overloadable)) mad(float, float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800254FN_FUNC_FN_FN_FN(mad)
Jason Sams22fa3712010-05-19 17:22:57 -0700255
256extern float __attribute__((overloadable)) modf(float, float *);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800257FN_FUNC_FN_PFN(modf);
Jason Sams22fa3712010-05-19 17:22:57 -0700258
Jason Sams1b937f52010-06-09 14:26:16 -0700259//extern float __attribute__((overloadable)) nan(uint);
Jason Sams22fa3712010-05-19 17:22:57 -0700260
261extern float __attribute__((overloadable)) nextafter(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800262FN_FUNC_FN_FN(nextafter)
Jason Sams22fa3712010-05-19 17:22:57 -0700263
Stephen Hines3e6482f2011-01-19 12:51:33 -0800264FN_FUNC_FN_FN(pow)
Jason Sams22fa3712010-05-19 17:22:57 -0700265
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800266_RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p);
267_RS_RUNTIME float2 __attribute__((overloadable)) pown(float2 v, int2 p);
268_RS_RUNTIME float3 __attribute__((overloadable)) pown(float3 v, int3 p);
269_RS_RUNTIME float4 __attribute__((overloadable)) pown(float4 v, int4 p);
Jason Sams22fa3712010-05-19 17:22:57 -0700270
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800271_RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p);
272_RS_RUNTIME float2 __attribute__((overloadable)) powr(float2 v, float2 p);
273_RS_RUNTIME float3 __attribute__((overloadable)) powr(float3 v, float3 p);
274_RS_RUNTIME float4 __attribute__((overloadable)) powr(float4 v, float4 p);
Jason Sams22fa3712010-05-19 17:22:57 -0700275
276extern float __attribute__((overloadable)) remainder(float, float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800277FN_FUNC_FN_FN(remainder)
Jason Sams22fa3712010-05-19 17:22:57 -0700278
Stephen Hines47416532011-01-11 14:38:18 -0800279extern float __attribute__((overloadable)) remquo(float, float, int *);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800280FN_FUNC_FN_FN_PIN(remquo)
Jason Sams22fa3712010-05-19 17:22:57 -0700281
282extern float __attribute__((overloadable)) rint(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800283FN_FUNC_FN(rint)
Jason Sams22fa3712010-05-19 17:22:57 -0700284
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800285
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800286_RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int r);
287_RS_RUNTIME float2 __attribute__((overloadable)) rootn(float2 v, int2 r);
288_RS_RUNTIME float3 __attribute__((overloadable)) rootn(float3 v, int3 r);
289_RS_RUNTIME float4 __attribute__((overloadable)) rootn(float4 v, int4 r);
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800290
Jason Sams22fa3712010-05-19 17:22:57 -0700291
292extern float __attribute__((overloadable)) round(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800293FN_FUNC_FN(round)
Jason Sams22fa3712010-05-19 17:22:57 -0700294
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800295
Jason Sams22fa3712010-05-19 17:22:57 -0700296extern float __attribute__((overloadable)) sqrt(float);
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800297_RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800298FN_FUNC_FN(rsqrt)
Jason Sams1b937f52010-06-09 14:26:16 -0700299
300extern float __attribute__((overloadable)) sin(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800301FN_FUNC_FN(sin)
Jason Sams1b937f52010-06-09 14:26:16 -0700302
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800303_RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr);
304_RS_RUNTIME float2 __attribute__((overloadable)) sincos(float2 v, float2 *cosptr);
305_RS_RUNTIME float3 __attribute__((overloadable)) sincos(float3 v, float3 *cosptr);
306_RS_RUNTIME float4 __attribute__((overloadable)) sincos(float4 v, float4 *cosptr);
Jason Sams1b937f52010-06-09 14:26:16 -0700307
308extern float __attribute__((overloadable)) sinh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800309FN_FUNC_FN(sinh)
Jason Sams1b937f52010-06-09 14:26:16 -0700310
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800311_RS_RUNTIME float __attribute__((overloadable)) sinpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800312FN_FUNC_FN(sinpi)
Jason Sams1b937f52010-06-09 14:26:16 -0700313
Stephen Hines3e6482f2011-01-19 12:51:33 -0800314FN_FUNC_FN(sqrt)
Jason Sams22fa3712010-05-19 17:22:57 -0700315
316extern float __attribute__((overloadable)) tan(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800317FN_FUNC_FN(tan)
Jason Sams22fa3712010-05-19 17:22:57 -0700318
319extern float __attribute__((overloadable)) tanh(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800320FN_FUNC_FN(tanh)
Jason Sams22fa3712010-05-19 17:22:57 -0700321
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800322_RS_RUNTIME float __attribute__((overloadable)) tanpi(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800323FN_FUNC_FN(tanpi)
Jason Sams22fa3712010-05-19 17:22:57 -0700324
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800325
Jason Sams22fa3712010-05-19 17:22:57 -0700326extern float __attribute__((overloadable)) tgamma(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800327FN_FUNC_FN(tgamma)
Jason Sams22fa3712010-05-19 17:22:57 -0700328
329extern float __attribute__((overloadable)) trunc(float);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800330FN_FUNC_FN(trunc)
Jason Sams22fa3712010-05-19 17:22:57 -0700331
332// Int ops (partial), 6.11.3
Jason Sams22fa3712010-05-19 17:22:57 -0700333
Stephen Hines47b15302011-01-19 18:06:34 -0800334#define XN_FUNC_YN(typeout, fnc, typein) \
335extern typeout __attribute__((overloadable)) fnc(typein); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800336_RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v); \
337_RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v); \
338_RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
Jason Sams22fa3712010-05-19 17:22:57 -0700339
Stephen Hines47b15302011-01-19 18:06:34 -0800340#define UIN_FUNC_IN(fnc) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800341XN_FUNC_YN(uchar, fnc, char) \
342XN_FUNC_YN(ushort, fnc, short) \
343XN_FUNC_YN(uint, fnc, int)
Jason Sams22fa3712010-05-19 17:22:57 -0700344
Stephen Hines47b15302011-01-19 18:06:34 -0800345#define IN_FUNC_IN(fnc) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800346XN_FUNC_YN(uchar, fnc, uchar) \
347XN_FUNC_YN(char, fnc, char) \
348XN_FUNC_YN(ushort, fnc, ushort) \
349XN_FUNC_YN(short, fnc, short) \
350XN_FUNC_YN(uint, fnc, uint) \
351XN_FUNC_YN(int, fnc, int)
Jason Sams22fa3712010-05-19 17:22:57 -0700352
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800353
Stephen Hines47b15302011-01-19 18:06:34 -0800354#define XN_FUNC_XN_XN_BODY(type, fnc, body) \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800355_RS_RUNTIME type __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800356 fnc(type v1, type v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800357_RS_RUNTIME type##2 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800358 fnc(type##2 v1, type##2 v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800359_RS_RUNTIME type##3 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800360 fnc(type##3 v1, type##3 v2); \
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800361_RS_RUNTIME type##4 __attribute__((overloadable)) \
Shih-wei Liaoedf22402011-01-26 04:03:30 -0800362 fnc(type##4 v1, type##4 v2);
Jason Sams22fa3712010-05-19 17:22:57 -0700363
Stephen Hines47b15302011-01-19 18:06:34 -0800364#define IN_FUNC_IN_IN_BODY(fnc, body) \
Stephen Hines3e6482f2011-01-19 12:51:33 -0800365XN_FUNC_XN_XN_BODY(uchar, fnc, body) \
366XN_FUNC_XN_XN_BODY(char, fnc, body) \
367XN_FUNC_XN_XN_BODY(ushort, fnc, body) \
368XN_FUNC_XN_XN_BODY(short, fnc, body) \
369XN_FUNC_XN_XN_BODY(uint, fnc, body) \
370XN_FUNC_XN_XN_BODY(int, fnc, body) \
371XN_FUNC_XN_XN_BODY(float, fnc, body)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800372
Stephen Hines3e6482f2011-01-19 12:51:33 -0800373UIN_FUNC_IN(abs)
374IN_FUNC_IN(clz)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800375
Stephen Hines3e6482f2011-01-19 12:51:33 -0800376IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2))
377FN_FUNC_FN_F(min)
Stephen Hinesb902e4c2011-01-14 18:49:01 -0800378
Stephen Hines3e6482f2011-01-19 12:51:33 -0800379IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2))
380FN_FUNC_FN_F(max)
Jason Sams22fa3712010-05-19 17:22:57 -0700381
382// 6.11.4
383
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800384_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
385_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high);
386_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high);
387_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high);
388_RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high);
389_RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high);
390_RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high);
Jason Sams22fa3712010-05-19 17:22:57 -0700391
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800392_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800393FN_FUNC_FN(degrees)
Jason Sams22fa3712010-05-19 17:22:57 -0700394
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800395_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
396_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount);
397_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount);
398_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount);
399_RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount);
400_RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount);
401_RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount);
Jason Sams22fa3712010-05-19 17:22:57 -0700402
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800403_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800404FN_FUNC_FN(radians)
Jason Sams22fa3712010-05-19 17:22:57 -0700405
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800406_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
407_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v);
408_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v);
409_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float4 v);
410_RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float v);
411_RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v);
412_RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v);
Jason Sams22fa3712010-05-19 17:22:57 -0700413
414extern float __attribute__((overloadable)) smoothstep(float, float, float);
415extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
416extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
417extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
Jason Sams22fa3712010-05-19 17:22:57 -0700418extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
419extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
420extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
Jason Sams22fa3712010-05-19 17:22:57 -0700421
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800422_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
Stephen Hines3e6482f2011-01-19 12:51:33 -0800423FN_FUNC_FN(sign)
Jason Sams22fa3712010-05-19 17:22:57 -0700424
425// 6.11.5
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800426_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700427
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800428_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700429
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800430_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
431_RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs);
432_RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs);
433_RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700434
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800435_RS_RUNTIME float __attribute__((overloadable)) length(float v);
436_RS_RUNTIME float __attribute__((overloadable)) length(float2 v);
437_RS_RUNTIME float __attribute__((overloadable)) length(float3 v);
438_RS_RUNTIME float __attribute__((overloadable)) length(float4 v);
Jason Sams22fa3712010-05-19 17:22:57 -0700439
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800440_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
441_RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs);
442_RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs);
443_RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs);
Jason Sams22fa3712010-05-19 17:22:57 -0700444
Shih-wei Liaoe31775b2011-01-26 17:04:31 -0800445_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
446_RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v);
447_RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v);
448_RS_RUNTIME float4 __attribute__((overloadable)) normalize(float4 v);
Jason Sams1b937f52010-06-09 14:26:16 -0700449
Stephen Hines47416532011-01-11 14:38:18 -0800450#undef CVT_FUNC
451#undef CVT_FUNC_2
Stephen Hines3e6482f2011-01-19 12:51:33 -0800452#undef FN_FUNC_FN
453#undef IN_FUNC_FN
454#undef FN_FUNC_FN_FN
455#undef FN_FUNC_FN_F
456#undef FN_FUNC_FN_IN
457#undef FN_FUNC_FN_I
458#undef FN_FUNC_FN_PFN
459#undef FN_FUNC_FN_PIN
460#undef FN_FUNC_FN_FN_FN
461#undef FN_FUNC_FN_FN_PIN
462#undef XN_FUNC_YN
463#undef UIN_FUNC_IN
464#undef IN_FUNC_IN
465#undef XN_FUNC_XN_XN_BODY
466#undef IN_FUNC_IN_IN_BODY
Jason Sams1b937f52010-06-09 14:26:16 -0700467
468#endif