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