Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 1 | /* |
| 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 |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 18 | * \brief Basic math functions |
Jason Sams | 044e2ee | 2011-08-08 16:52:30 -0700 | [diff] [blame] | 19 | * |
| 20 | * |
| 21 | */ |
| 22 | |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 23 | #ifndef __RS_CL_RSH__ |
| 24 | #define __RS_CL_RSH__ |
| 25 | |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 26 | // Conversions |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 27 | #define CVT_FUNC_2(typeout, typein) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 28 | _RS_RUNTIME typeout##2 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 29 | convert_##typeout##2(typein##2 v); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 30 | _RS_RUNTIME typeout##3 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 31 | convert_##typeout##3(typein##3 v); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 32 | _RS_RUNTIME typeout##4 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 33 | convert_##typeout##4(typein##4 v); |
| 34 | |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 35 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 36 | #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 Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 43 | |
| 44 | CVT_FUNC(char) |
| 45 | CVT_FUNC(uchar) |
| 46 | CVT_FUNC(short) |
| 47 | CVT_FUNC(ushort) |
| 48 | CVT_FUNC(int) |
| 49 | CVT_FUNC(uint) |
| 50 | CVT_FUNC(float) |
| 51 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 52 | // Float ops, 6.11.2 |
| 53 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 54 | #define FN_FUNC_FN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 55 | _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 Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 58 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 59 | #define IN_FUNC_FN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 60 | _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 Hines | 4741653 | 2011-01-11 14:38:18 -0800 | [diff] [blame] | 63 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 64 | #define FN_FUNC_FN_FN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 65 | _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 Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 68 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 69 | #define FN_FUNC_FN_F(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 70 | _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 Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 73 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 74 | #define FN_FUNC_FN_IN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 75 | _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 Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 78 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 79 | #define FN_FUNC_FN_I(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 80 | _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 Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 83 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 84 | #define FN_FUNC_FN_PFN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 85 | _RS_RUNTIME float2 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 86 | fnc(float2 v1, float2 *v2); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 87 | _RS_RUNTIME float3 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 88 | fnc(float3 v1, float3 *v2); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 89 | _RS_RUNTIME float4 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 90 | fnc(float4 v1, float4 *v2); |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 91 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 92 | #define FN_FUNC_FN_PIN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 93 | _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 Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 96 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 97 | #define FN_FUNC_FN_FN_FN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 98 | _RS_RUNTIME float2 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 99 | fnc(float2 v1, float2 v2, float2 v3); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 100 | _RS_RUNTIME float3 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 101 | fnc(float3 v1, float3 v2, float3 v3); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 102 | _RS_RUNTIME float4 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 103 | fnc(float4 v1, float4 v2, float4 v3); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 104 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 105 | #define FN_FUNC_FN_FN_PIN(fnc) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 106 | _RS_RUNTIME float2 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 107 | fnc(float2 v1, float2 v2, int2 *v3); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 108 | _RS_RUNTIME float3 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 109 | fnc(float3 v1, float3 v2, int3 *v3); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 110 | _RS_RUNTIME float4 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 111 | fnc(float4 v1, float4 v2, int4 *v3); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 112 | |
| 113 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Return the inverse cosine. |
| 116 | * |
| 117 | * Supports float, float2, float3, float4 |
| 118 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 119 | extern float __attribute__((overloadable)) acos(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 120 | FN_FUNC_FN(acos) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 121 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 122 | /** |
| 123 | * Return the inverse hyperbolic cosine. |
| 124 | * |
| 125 | * Supports float, float2, float3, float4 |
| 126 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 127 | extern float __attribute__((overloadable)) acosh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 128 | FN_FUNC_FN(acosh) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 129 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 130 | /** |
| 131 | * Return the inverse cosine divided by PI. |
| 132 | * |
| 133 | * Supports float, float2, float3, float4 |
| 134 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 135 | _RS_RUNTIME float __attribute__((overloadable)) acospi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 136 | FN_FUNC_FN(acospi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 137 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 138 | /** |
| 139 | * Return the inverse sine. |
| 140 | * |
| 141 | * Supports float, float2, float3, float4 |
| 142 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 143 | extern float __attribute__((overloadable)) asin(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 144 | FN_FUNC_FN(asin) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 145 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 146 | /** |
| 147 | * Return the inverse hyperbolic sine. |
| 148 | * |
| 149 | * Supports float, float2, float3, float4 |
| 150 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 151 | extern float __attribute__((overloadable)) asinh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 152 | FN_FUNC_FN(asinh) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 153 | |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 154 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 155 | /** |
| 156 | * Return the inverse sine divided by PI. |
| 157 | * |
| 158 | * Supports float, float2, float3, float4 |
| 159 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 160 | _RS_RUNTIME float __attribute__((overloadable)) asinpi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 161 | FN_FUNC_FN(asinpi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 162 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 163 | /** |
| 164 | * Return the inverse tangent. |
| 165 | * |
| 166 | * Supports float, float2, float3, float4 |
| 167 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 168 | extern float __attribute__((overloadable)) atan(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 169 | FN_FUNC_FN(atan) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 170 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 171 | /** |
| 172 | * Return the inverse tangent of y / x. |
| 173 | * |
| 174 | * Supports float, float2, float3, float4. Both arguments must be of the same |
| 175 | * type. |
| 176 | * |
| 177 | * @param y |
| 178 | * @param x |
| 179 | */ |
| 180 | extern float __attribute__((overloadable)) atan2(float y, float x); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 181 | FN_FUNC_FN_FN(atan2) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 182 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 183 | /** |
| 184 | * Return the inverse hyperbolic tangent. |
| 185 | * |
| 186 | * Supports float, float2, float3, float4 |
| 187 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 188 | extern float __attribute__((overloadable)) atanh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 189 | FN_FUNC_FN(atanh) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 190 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 191 | /** |
| 192 | * Return the inverse tangent divided by PI. |
| 193 | * |
| 194 | * Supports float, float2, float3, float4 |
| 195 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 196 | _RS_RUNTIME float __attribute__((overloadable)) atanpi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 197 | FN_FUNC_FN(atanpi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 198 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Return the inverse tangent of y / x, divided by PI. |
| 201 | * |
| 202 | * Supports float, float2, float3, float4. Both arguments must be of the same |
| 203 | * type. |
| 204 | * |
| 205 | * @param y |
| 206 | * @param x |
| 207 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 208 | _RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 209 | FN_FUNC_FN_FN(atan2pi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 210 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 211 | |
| 212 | /** |
| 213 | * Return the cube root. |
| 214 | * |
| 215 | * Supports float, float2, float3, float4. |
| 216 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 217 | extern float __attribute__((overloadable)) cbrt(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 218 | FN_FUNC_FN(cbrt) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 219 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 220 | /** |
| 221 | * Return the smallest integer not less than a value. |
| 222 | * |
| 223 | * Supports float, float2, float3, float4. |
| 224 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 225 | extern float __attribute__((overloadable)) ceil(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 226 | FN_FUNC_FN(ceil) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 227 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 228 | /** |
| 229 | * Copy the sign bit from y to x. |
| 230 | * |
| 231 | * Supports float, float2, float3, float4. Both arguments must be of the same |
| 232 | * type. |
| 233 | * |
| 234 | * @param x |
| 235 | * @param y |
| 236 | */ |
| 237 | extern float __attribute__((overloadable)) copysign(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 238 | FN_FUNC_FN_FN(copysign) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 239 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 240 | /** |
| 241 | * Return the cosine. |
| 242 | * |
| 243 | * Supports float, float2, float3, float4. |
| 244 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 245 | extern float __attribute__((overloadable)) cos(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 246 | FN_FUNC_FN(cos) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 247 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 248 | /** |
| 249 | * Return the hypebolic cosine. |
| 250 | * |
| 251 | * Supports float, float2, float3, float4. |
| 252 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 253 | extern float __attribute__((overloadable)) cosh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 254 | FN_FUNC_FN(cosh) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 255 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 256 | /** |
| 257 | * Return the cosine of the value * PI. |
| 258 | * |
| 259 | * Supports float, float2, float3, float4. |
| 260 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 261 | _RS_RUNTIME float __attribute__((overloadable)) cospi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 262 | FN_FUNC_FN(cospi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 263 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 264 | /** |
| 265 | * Return the complementary error function. |
| 266 | * |
| 267 | * Supports float, float2, float3, float4. |
| 268 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 269 | extern float __attribute__((overloadable)) erfc(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 270 | FN_FUNC_FN(erfc) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 271 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 272 | /** |
| 273 | * Return the error function. |
| 274 | * |
| 275 | * Supports float, float2, float3, float4. |
| 276 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 277 | extern float __attribute__((overloadable)) erf(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 278 | FN_FUNC_FN(erf) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 279 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 280 | /** |
| 281 | * Return e ^ value. |
| 282 | * |
| 283 | * Supports float, float2, float3, float4. |
| 284 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 285 | extern float __attribute__((overloadable)) exp(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 286 | FN_FUNC_FN(exp) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 287 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 288 | /** |
| 289 | * Return 2 ^ value. |
| 290 | * |
| 291 | * Supports float, float2, float3, float4. |
| 292 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 293 | extern float __attribute__((overloadable)) exp2(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 294 | FN_FUNC_FN(exp2) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 295 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 296 | /** |
| 297 | * Return x ^ y. |
| 298 | * |
| 299 | * Supports float, float2, float3, float4. Both arguments must be of the same |
| 300 | * type. |
| 301 | */ |
| 302 | extern float __attribute__((overloadable)) pow(float x, float y); |
| 303 | FN_FUNC_FN_FN(pow) |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 304 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 305 | /** |
| 306 | * Return 10 ^ value. |
| 307 | * |
| 308 | * Supports float, float2, float3, float4. |
| 309 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 310 | _RS_RUNTIME float __attribute__((overloadable)) exp10(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 311 | FN_FUNC_FN(exp10) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 312 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 313 | /** |
| 314 | * Return (e ^ value) - 1. |
| 315 | * |
| 316 | * Supports float, float2, float3, float4. |
| 317 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 318 | extern float __attribute__((overloadable)) expm1(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 319 | FN_FUNC_FN(expm1) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 320 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 321 | /** |
| 322 | * Return the absolute value of a value. |
| 323 | * |
| 324 | * Supports float, float2, float3, float4. |
| 325 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 326 | extern float __attribute__((overloadable)) fabs(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 327 | FN_FUNC_FN(fabs) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 328 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 329 | /** |
| 330 | * Return the positive difference between two values. |
| 331 | * |
| 332 | * Supports float, float2, float3, float4. Both arguments must be of the same |
| 333 | * type. |
| 334 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 335 | extern float __attribute__((overloadable)) fdim(float, float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 336 | FN_FUNC_FN_FN(fdim) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 337 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 338 | /** |
| 339 | * Return the smallest integer not greater than a value. |
| 340 | * |
| 341 | * Supports float, float2, float3, float4. |
| 342 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 343 | extern float __attribute__((overloadable)) floor(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 344 | FN_FUNC_FN(floor) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 345 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 346 | /** |
| 347 | * Return a*b + c. |
| 348 | * |
| 349 | * Supports float, float2, float3, float4. |
| 350 | */ |
| 351 | extern float __attribute__((overloadable)) fma(float a, float b, float c); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 352 | FN_FUNC_FN_FN_FN(fma) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 353 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 354 | /** |
| 355 | * Return (x < y ? y : x) |
| 356 | * |
| 357 | * Supports float, float2, float3, float4. |
| 358 | * @param x: may be float, float2, float3, float4 |
| 359 | * @param y: may be float or vector. If vector must match type of x. |
| 360 | */ |
| 361 | extern float __attribute__((overloadable)) fmax(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 362 | FN_FUNC_FN_FN(fmax); |
| 363 | FN_FUNC_FN_F(fmax); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 364 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 365 | /** |
| 366 | * Return (x > y ? y : x) |
| 367 | * |
| 368 | * @param x: may be float, float2, float3, float4 |
| 369 | * @param y: may be float or vector. If vector must match type of x. |
| 370 | */ |
| 371 | extern float __attribute__((overloadable)) fmin(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 372 | FN_FUNC_FN_FN(fmin); |
| 373 | FN_FUNC_FN_F(fmin); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 374 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 375 | /** |
| 376 | * Return the remainder from x / y |
| 377 | * |
| 378 | * Supports float, float2, float3, float4. |
| 379 | */ |
| 380 | extern float __attribute__((overloadable)) fmod(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 381 | FN_FUNC_FN_FN(fmod) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 382 | |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 383 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 384 | /** |
| 385 | * Return fractional part of v |
| 386 | * |
| 387 | * @param iptr iptr[0] will be set to the floor of the input value. |
| 388 | * Supports float, float2, float3, float4. |
| 389 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 390 | _RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr); |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 391 | FN_FUNC_FN_PFN(fract) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 392 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 393 | /** |
| 394 | * Return the mantissa and place the exponent into iptr[0] |
| 395 | * |
| 396 | * @param v Supports float, float2, float3, float4. |
| 397 | * @param iptr Must have the same vector size as v. |
| 398 | */ |
| 399 | extern float __attribute__((overloadable)) frexp(float v, int *iptr); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 400 | FN_FUNC_FN_PIN(frexp) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 401 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 402 | /** |
| 403 | * Return sqrt(x*x + y*y) |
| 404 | * |
| 405 | * Supports float, float2, float3, float4. |
| 406 | */ |
| 407 | extern float __attribute__((overloadable)) hypot(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 408 | FN_FUNC_FN_FN(hypot) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 409 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 410 | /** |
| 411 | * Return the integer exponent of a value |
| 412 | * |
| 413 | * Supports 1,2,3,4 components |
| 414 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 415 | extern int __attribute__((overloadable)) ilogb(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 416 | IN_FUNC_FN(ilogb) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 417 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 418 | /** |
| 419 | * Return (x * 2^y) |
| 420 | * |
| 421 | * @param x Supports 1,2,3,4 components |
| 422 | * @param y Supports single component or matching vector. |
| 423 | */ |
| 424 | extern float __attribute__((overloadable)) ldexp(float x, int y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 425 | FN_FUNC_FN_IN(ldexp) |
| 426 | FN_FUNC_FN_I(ldexp) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 427 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 428 | /** |
| 429 | * Return the log gamma |
| 430 | * |
| 431 | * Supports 1,2,3,4 components |
| 432 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 433 | extern float __attribute__((overloadable)) lgamma(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 434 | FN_FUNC_FN(lgamma) |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 435 | |
| 436 | /** |
| 437 | * Return the log gamma and sign |
| 438 | * |
| 439 | * @param x Supports 1,2,3,4 components |
| 440 | * @param y Supports matching vector. |
| 441 | */ |
| 442 | extern float __attribute__((overloadable)) lgamma(float x, int* y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 443 | FN_FUNC_FN_PIN(lgamma) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 444 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 445 | /** |
| 446 | * Return the natural logarithm |
| 447 | * |
| 448 | * Supports 1,2,3,4 components |
| 449 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 450 | extern float __attribute__((overloadable)) log(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 451 | FN_FUNC_FN(log) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 452 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 453 | /** |
| 454 | * Return the base 10 logarithm |
| 455 | * |
| 456 | * Supports 1,2,3,4 components |
| 457 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 458 | extern float __attribute__((overloadable)) log10(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 459 | FN_FUNC_FN(log10) |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 460 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 461 | /** |
| 462 | * Return the base 2 logarithm |
| 463 | * |
| 464 | * Supports 1,2,3,4 components |
| 465 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 466 | _RS_RUNTIME float __attribute__((overloadable)) log2(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 467 | FN_FUNC_FN(log2) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 468 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 469 | /** |
| 470 | * Return the natural logarithm of (v + 1.0f) |
| 471 | * |
| 472 | * Supports 1,2,3,4 components |
| 473 | */ |
| 474 | extern float __attribute__((overloadable)) log1p(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 475 | FN_FUNC_FN(log1p) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 476 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 477 | /** |
| 478 | * Compute the exponent of the value. |
| 479 | * |
| 480 | * Supports 1,2,3,4 components |
| 481 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 482 | extern float __attribute__((overloadable)) logb(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 483 | FN_FUNC_FN(logb) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 484 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 485 | /** |
| 486 | * Compute (a * b) + c |
| 487 | * |
| 488 | * Supports 1,2,3,4 components |
| 489 | */ |
| 490 | extern float __attribute__((overloadable)) mad(float a, float b, float c); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 491 | FN_FUNC_FN_FN_FN(mad) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 492 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 493 | /** |
| 494 | * Return the integral and fractional components of a number |
| 495 | * Supports 1,2,3,4 components |
| 496 | * |
| 497 | * @param x Source value |
| 498 | * @param iret iret[0] will be set to the integral portion of the number. |
| 499 | * @return The floating point portion of the value. |
| 500 | */ |
| 501 | extern float __attribute__((overloadable)) modf(float x, float *iret); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 502 | FN_FUNC_FN_PFN(modf); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 503 | |
Jason Sams | f31fa92 | 2012-03-30 18:26:31 -0700 | [diff] [blame] | 504 | extern float __attribute__((overloadable)) nan(uint); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 505 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 506 | /** |
| 507 | * Return the next floating point number from x towards y. |
| 508 | * |
| 509 | * Supports 1,2,3,4 components |
| 510 | */ |
| 511 | extern float __attribute__((overloadable)) nextafter(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 512 | FN_FUNC_FN_FN(nextafter) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 513 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 514 | /** |
| 515 | * Return (v ^ p). |
| 516 | * |
| 517 | * Supports 1,2,3,4 components |
| 518 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 519 | _RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p); |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 520 | FN_FUNC_FN_IN(pown) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 521 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 522 | /** |
| 523 | * Return (v ^ p). |
| 524 | * @param v must be greater than 0. |
| 525 | * |
| 526 | * Supports 1,2,3,4 components |
| 527 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 528 | _RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p); |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 529 | FN_FUNC_FN_FN(powr) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 530 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 531 | /** |
| 532 | * Return round x/y to the nearest integer then compute the remander. |
| 533 | * |
| 534 | * Supports 1,2,3,4 components |
| 535 | */ |
| 536 | extern float __attribute__((overloadable)) remainder(float x, float y); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 537 | FN_FUNC_FN_FN(remainder) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 538 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 539 | // document once we know the precision of bionic |
Stephen Hines | 4741653 | 2011-01-11 14:38:18 -0800 | [diff] [blame] | 540 | extern float __attribute__((overloadable)) remquo(float, float, int *); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 541 | FN_FUNC_FN_FN_PIN(remquo) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 542 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 543 | /** |
| 544 | * Round to the nearest integral value. |
| 545 | * |
| 546 | * Supports 1,2,3,4 components |
| 547 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 548 | extern float __attribute__((overloadable)) rint(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 549 | FN_FUNC_FN(rint) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 550 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 551 | /** |
| 552 | * Compute the Nth root of a value. |
| 553 | * |
| 554 | * Supports 1,2,3,4 components |
| 555 | */ |
| 556 | _RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int n); |
| 557 | FN_FUNC_FN_IN(rootn) |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 558 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 559 | /** |
| 560 | * Round to the nearest integral value. Half values are rounded away from zero. |
| 561 | * |
| 562 | * Supports 1,2,3,4 components |
| 563 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 564 | extern float __attribute__((overloadable)) round(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 565 | FN_FUNC_FN(round) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 566 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 567 | /** |
| 568 | * Return the square root of a value. |
| 569 | * |
| 570 | * Supports 1,2,3,4 components |
| 571 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 572 | extern float __attribute__((overloadable)) sqrt(float); |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 573 | FN_FUNC_FN(sqrt) |
| 574 | |
| 575 | /** |
| 576 | * Return (1 / sqrt(value)). |
| 577 | * |
| 578 | * @param v The incoming value in radians |
| 579 | * Supports 1,2,3,4 components |
| 580 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 581 | _RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 582 | FN_FUNC_FN(rsqrt) |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 583 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 584 | /** |
| 585 | * Return the sine of a value specified in radians. |
| 586 | * |
| 587 | * @param v The incoming value in radians |
| 588 | * Supports 1,2,3,4 components |
| 589 | */ |
| 590 | extern float __attribute__((overloadable)) sin(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 591 | FN_FUNC_FN(sin) |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 592 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 593 | /** |
| 594 | * Return the sine and cosine of a value. |
| 595 | * |
| 596 | * @return sine |
| 597 | * @param v The incoming value in radians |
| 598 | * @param *cosptr cosptr[0] will be set to the cosine value. |
| 599 | * |
| 600 | * Supports 1,2,3,4 components |
| 601 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 602 | _RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr); |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 603 | FN_FUNC_FN_PFN(sincos); |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 604 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 605 | /** |
| 606 | * Return the hyperbolic sine of a value specified in radians. |
| 607 | * |
| 608 | * Supports 1,2,3,4 components |
| 609 | */ |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 610 | extern float __attribute__((overloadable)) sinh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 611 | FN_FUNC_FN(sinh) |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 612 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 613 | /** |
| 614 | * Return the sin(v * PI). |
| 615 | * |
| 616 | * Supports 1,2,3,4 components |
| 617 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 618 | _RS_RUNTIME float __attribute__((overloadable)) sinpi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 619 | FN_FUNC_FN(sinpi) |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 620 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 621 | /** |
| 622 | * Return the tangent of a value. |
| 623 | * |
| 624 | * Supports 1,2,3,4 components |
| 625 | * @param v The incoming value in radians |
| 626 | */ |
| 627 | extern float __attribute__((overloadable)) tan(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 628 | FN_FUNC_FN(tan) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 629 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 630 | /** |
| 631 | * Return the hyperbolic tangent of a value. |
| 632 | * |
| 633 | * Supports 1,2,3,4 components |
| 634 | * @param v The incoming value in radians |
| 635 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 636 | extern float __attribute__((overloadable)) tanh(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 637 | FN_FUNC_FN(tanh) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 638 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 639 | /** |
| 640 | * Return tan(v * PI) |
| 641 | * |
| 642 | * Supports 1,2,3,4 components |
| 643 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 644 | _RS_RUNTIME float __attribute__((overloadable)) tanpi(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 645 | FN_FUNC_FN(tanpi) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 646 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 647 | /** |
| 648 | * Compute the gamma function of a value. |
| 649 | * |
| 650 | * Supports 1,2,3,4 components |
| 651 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 652 | extern float __attribute__((overloadable)) tgamma(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 653 | FN_FUNC_FN(tgamma) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 654 | |
Jason Sams | ef82364 | 2011-08-31 14:52:08 -0700 | [diff] [blame] | 655 | /** |
| 656 | * Round to integral using truncation. |
| 657 | * |
| 658 | * Supports 1,2,3,4 components |
| 659 | */ |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 660 | extern float __attribute__((overloadable)) trunc(float); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 661 | FN_FUNC_FN(trunc) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 662 | |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 663 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 664 | #define XN_FUNC_YN(typeout, fnc, typein) \ |
| 665 | extern typeout __attribute__((overloadable)) fnc(typein); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 666 | _RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v); \ |
| 667 | _RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v); \ |
| 668 | _RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 669 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 670 | #define UIN_FUNC_IN(fnc) \ |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 671 | XN_FUNC_YN(uchar, fnc, char) \ |
| 672 | XN_FUNC_YN(ushort, fnc, short) \ |
| 673 | XN_FUNC_YN(uint, fnc, int) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 674 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 675 | #define IN_FUNC_IN(fnc) \ |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 676 | XN_FUNC_YN(uchar, fnc, uchar) \ |
| 677 | XN_FUNC_YN(char, fnc, char) \ |
| 678 | XN_FUNC_YN(ushort, fnc, ushort) \ |
| 679 | XN_FUNC_YN(short, fnc, short) \ |
| 680 | XN_FUNC_YN(uint, fnc, uint) \ |
| 681 | XN_FUNC_YN(int, fnc, int) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 682 | |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 683 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 684 | #define XN_FUNC_XN_XN_BODY(type, fnc, body) \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 685 | _RS_RUNTIME type __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 686 | fnc(type v1, type v2); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 687 | _RS_RUNTIME type##2 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 688 | fnc(type##2 v1, type##2 v2); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 689 | _RS_RUNTIME type##3 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 690 | fnc(type##3 v1, type##3 v2); \ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 691 | _RS_RUNTIME type##4 __attribute__((overloadable)) \ |
Shih-wei Liao | edf2240 | 2011-01-26 04:03:30 -0800 | [diff] [blame] | 692 | fnc(type##4 v1, type##4 v2); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 693 | |
Stephen Hines | 47b1530 | 2011-01-19 18:06:34 -0800 | [diff] [blame] | 694 | #define IN_FUNC_IN_IN_BODY(fnc, body) \ |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 695 | XN_FUNC_XN_XN_BODY(uchar, fnc, body) \ |
| 696 | XN_FUNC_XN_XN_BODY(char, fnc, body) \ |
| 697 | XN_FUNC_XN_XN_BODY(ushort, fnc, body) \ |
| 698 | XN_FUNC_XN_XN_BODY(short, fnc, body) \ |
| 699 | XN_FUNC_XN_XN_BODY(uint, fnc, body) \ |
| 700 | XN_FUNC_XN_XN_BODY(int, fnc, body) \ |
| 701 | XN_FUNC_XN_XN_BODY(float, fnc, body) |
Stephen Hines | b902e4c | 2011-01-14 18:49:01 -0800 | [diff] [blame] | 702 | |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 703 | UIN_FUNC_IN(abs) |
| 704 | IN_FUNC_IN(clz) |
Stephen Hines | b902e4c | 2011-01-14 18:49:01 -0800 | [diff] [blame] | 705 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 706 | /** |
| 707 | * Return the minimum of two values. |
| 708 | * |
| 709 | * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float. |
| 710 | */ |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 711 | IN_FUNC_IN_IN_BODY(min, (v1 < v2 ? v1 : v2)) |
| 712 | FN_FUNC_FN_F(min) |
Stephen Hines | b902e4c | 2011-01-14 18:49:01 -0800 | [diff] [blame] | 713 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 714 | /** |
| 715 | * Return the maximum of two values. |
| 716 | * |
| 717 | * Supports 1,2,3,4 components of uchar, char, ushort, short, uint, int, float. |
| 718 | */ |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 719 | IN_FUNC_IN_IN_BODY(max, (v1 > v2 ? v1 : v2)) |
| 720 | FN_FUNC_FN_F(max) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 721 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 722 | /** |
| 723 | * Clamp a value to a specified high and low bound. |
| 724 | * |
| 725 | * @param amount value to be clamped. Supports 1,2,3,4 components |
| 726 | * @param low Lower bound, must be scalar or matching vector. |
| 727 | * @param high High bound, must match type of low |
| 728 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 729 | _RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high); |
| 730 | _RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float2 low, float2 high); |
| 731 | _RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float3 low, float3 high); |
| 732 | _RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float4 low, float4 high); |
| 733 | _RS_RUNTIME float2 __attribute__((overloadable)) clamp(float2 amount, float low, float high); |
| 734 | _RS_RUNTIME float3 __attribute__((overloadable)) clamp(float3 amount, float low, float high); |
| 735 | _RS_RUNTIME float4 __attribute__((overloadable)) clamp(float4 amount, float low, float high); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 736 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 737 | /** |
| 738 | * Convert from radians to degrees. |
| 739 | * |
| 740 | * Supports 1,2,3,4 components |
| 741 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 742 | _RS_RUNTIME float __attribute__((overloadable)) degrees(float radians); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 743 | FN_FUNC_FN(degrees) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 744 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 745 | /** |
| 746 | * return start + ((stop - start) * amount); |
| 747 | * |
| 748 | * Supports 1,2,3,4 components |
| 749 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 750 | _RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount); |
| 751 | _RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float2 amount); |
| 752 | _RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float3 amount); |
| 753 | _RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float4 amount); |
| 754 | _RS_RUNTIME float2 __attribute__((overloadable)) mix(float2 start, float2 stop, float amount); |
| 755 | _RS_RUNTIME float3 __attribute__((overloadable)) mix(float3 start, float3 stop, float amount); |
| 756 | _RS_RUNTIME float4 __attribute__((overloadable)) mix(float4 start, float4 stop, float amount); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 757 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 758 | /** |
| 759 | * Convert from degrees to radians. |
| 760 | * |
| 761 | * Supports 1,2,3,4 components |
| 762 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 763 | _RS_RUNTIME float __attribute__((overloadable)) radians(float degrees); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 764 | FN_FUNC_FN(radians) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 765 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 766 | /** |
| 767 | * if (v < edge) |
| 768 | * return 0.f; |
| 769 | * else |
| 770 | * return 1.f; |
| 771 | * |
| 772 | * Supports 1,2,3,4 components |
| 773 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 774 | _RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v); |
| 775 | _RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float2 v); |
| 776 | _RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float3 v); |
| 777 | _RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float4 v); |
| 778 | _RS_RUNTIME float2 __attribute__((overloadable)) step(float2 edge, float v); |
| 779 | _RS_RUNTIME float3 __attribute__((overloadable)) step(float3 edge, float v); |
| 780 | _RS_RUNTIME float4 __attribute__((overloadable)) step(float4 edge, float v); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 781 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 782 | // not implemented |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 783 | extern float __attribute__((overloadable)) smoothstep(float, float, float); |
| 784 | extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2); |
| 785 | extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3); |
| 786 | extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 787 | extern float2 __attribute__((overloadable)) smoothstep(float, float, float2); |
| 788 | extern float3 __attribute__((overloadable)) smoothstep(float, float, float3); |
| 789 | extern float4 __attribute__((overloadable)) smoothstep(float, float, float4); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 790 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 791 | /** |
| 792 | * if (v < 0) return -1.f; |
| 793 | * else if (v > 0) return 1.f; |
| 794 | * else return 0.f; |
| 795 | * |
| 796 | * Supports 1,2,3,4 components |
| 797 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 798 | _RS_RUNTIME float __attribute__((overloadable)) sign(float v); |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 799 | FN_FUNC_FN(sign) |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 800 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 801 | /** |
| 802 | * Compute the cross product of two vectors. |
| 803 | * |
| 804 | * Supports 3,4 components |
| 805 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 806 | _RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs); |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 807 | _RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 808 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 809 | /** |
| 810 | * Compute the dot product of two vectors. |
| 811 | * |
| 812 | * Supports 1,2,3,4 components |
| 813 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 814 | _RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs); |
| 815 | _RS_RUNTIME float __attribute__((overloadable)) dot(float2 lhs, float2 rhs); |
| 816 | _RS_RUNTIME float __attribute__((overloadable)) dot(float3 lhs, float3 rhs); |
| 817 | _RS_RUNTIME float __attribute__((overloadable)) dot(float4 lhs, float4 rhs); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 818 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 819 | /** |
| 820 | * Compute the length of a vector. |
| 821 | * |
| 822 | * Supports 1,2,3,4 components |
| 823 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 824 | _RS_RUNTIME float __attribute__((overloadable)) length(float v); |
| 825 | _RS_RUNTIME float __attribute__((overloadable)) length(float2 v); |
| 826 | _RS_RUNTIME float __attribute__((overloadable)) length(float3 v); |
| 827 | _RS_RUNTIME float __attribute__((overloadable)) length(float4 v); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 828 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 829 | /** |
| 830 | * Compute the distance between two points. |
| 831 | * |
| 832 | * Supports 1,2,3,4 components |
| 833 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 834 | _RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs); |
| 835 | _RS_RUNTIME float __attribute__((overloadable)) distance(float2 lhs, float2 rhs); |
| 836 | _RS_RUNTIME float __attribute__((overloadable)) distance(float3 lhs, float3 rhs); |
| 837 | _RS_RUNTIME float __attribute__((overloadable)) distance(float4 lhs, float4 rhs); |
Jason Sams | 22fa371 | 2010-05-19 17:22:57 -0700 | [diff] [blame] | 838 | |
Jason Sams | dc2c3e6 | 2011-08-31 16:44:18 -0700 | [diff] [blame] | 839 | /** |
| 840 | * Normalize a vector. |
| 841 | * |
| 842 | * Supports 1,2,3,4 components |
| 843 | */ |
Shih-wei Liao | e31775b | 2011-01-26 17:04:31 -0800 | [diff] [blame] | 844 | _RS_RUNTIME float __attribute__((overloadable)) normalize(float v); |
| 845 | _RS_RUNTIME float2 __attribute__((overloadable)) normalize(float2 v); |
| 846 | _RS_RUNTIME float3 __attribute__((overloadable)) normalize(float3 v); |
| 847 | _RS_RUNTIME float4 __attribute__((overloadable)) normalize(float4 v); |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 848 | |
Stephen Hines | 4741653 | 2011-01-11 14:38:18 -0800 | [diff] [blame] | 849 | #undef CVT_FUNC |
| 850 | #undef CVT_FUNC_2 |
Stephen Hines | 3e6482f | 2011-01-19 12:51:33 -0800 | [diff] [blame] | 851 | #undef FN_FUNC_FN |
| 852 | #undef IN_FUNC_FN |
| 853 | #undef FN_FUNC_FN_FN |
| 854 | #undef FN_FUNC_FN_F |
| 855 | #undef FN_FUNC_FN_IN |
| 856 | #undef FN_FUNC_FN_I |
| 857 | #undef FN_FUNC_FN_PFN |
| 858 | #undef FN_FUNC_FN_PIN |
| 859 | #undef FN_FUNC_FN_FN_FN |
| 860 | #undef FN_FUNC_FN_FN_PIN |
| 861 | #undef XN_FUNC_YN |
| 862 | #undef UIN_FUNC_IN |
| 863 | #undef IN_FUNC_IN |
| 864 | #undef XN_FUNC_XN_XN_BODY |
| 865 | #undef IN_FUNC_IN_IN_BODY |
Jason Sams | 1b937f5 | 2010-06-09 14:26:16 -0700 | [diff] [blame] | 866 | |
| 867 | #endif |