1 /* 2 * Copyright (C) 2015 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 // Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh. 18 19 /* 20 * rs_vector_math.rsh: Vector Math Functions 21 * 22 * These functions interpret the input arguments as representation of vectors in 23 * n-dimensional space. 24 * 25 * The precision of the mathematical operations on 32 bit floats is affected by the pragmas 26 * rs_fp_relaxed and rs_fp_full. See Mathematical Constants and Functions for details. 27 * 28 * Different precision/speed tradeoffs can be achieved by using variants of the common math 29 * functions. Functions with a name starting with 30 * - native_: May have custom hardware implementations with weaker precision. Additionally, 31 * subnormal values may be flushed to zero, rounding towards zero may be used, and NaN and 32 * infinity input may not be handled correctly. 33 * - fast_: May perform internal computations using 16 bit floats. Additionally, subnormal 34 * values may be flushed to zero, and rounding towards zero may be used. 35 * 36 */ 37 38 #ifndef RENDERSCRIPT_RS_VECTOR_MATH_RSH 39 #define RENDERSCRIPT_RS_VECTOR_MATH_RSH 40 41 /* 42 * cross: Cross product of two vectors 43 * 44 * Computes the cross product of two vectors. 45 */ 46 extern float3 __attribute__((const, overloadable)) 47 cross(float3 left_vector, float3 right_vector); 48 49 extern float4 __attribute__((const, overloadable)) 50 cross(float4 left_vector, float4 right_vector); 51 52 /* 53 * distance: Distance between two points 54 * 55 * Compute the distance between two points. 56 * 57 * See also fast_distance(), native_distance(). 58 */ 59 extern float __attribute__((const, overloadable)) 60 distance(float left_vector, float right_vector); 61 62 extern float __attribute__((const, overloadable)) 63 distance(float2 left_vector, float2 right_vector); 64 65 extern float __attribute__((const, overloadable)) 66 distance(float3 left_vector, float3 right_vector); 67 68 extern float __attribute__((const, overloadable)) 69 distance(float4 left_vector, float4 right_vector); 70 71 /* 72 * dot: Dot product of two vectors 73 * 74 * Computes the dot product of two vectors. 75 */ 76 extern float __attribute__((const, overloadable)) 77 dot(float left_vector, float right_vector); 78 79 extern float __attribute__((const, overloadable)) 80 dot(float2 left_vector, float2 right_vector); 81 82 extern float __attribute__((const, overloadable)) 83 dot(float3 left_vector, float3 right_vector); 84 85 extern float __attribute__((const, overloadable)) 86 dot(float4 left_vector, float4 right_vector); 87 88 /* 89 * fast_distance: Approximate distance between two points 90 * 91 * Computes the approximate distance between two points. 92 * 93 * The precision is what would be expected from doing the computation using 16 bit floating 94 * point values. 95 * 96 * See also distance(), native_distance(). 97 */ 98 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 99 extern float __attribute__((const, overloadable)) 100 fast_distance(float left_vector, float right_vector); 101 #endif 102 103 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 104 extern float __attribute__((const, overloadable)) 105 fast_distance(float2 left_vector, float2 right_vector); 106 #endif 107 108 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 109 extern float __attribute__((const, overloadable)) 110 fast_distance(float3 left_vector, float3 right_vector); 111 #endif 112 113 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 114 extern float __attribute__((const, overloadable)) 115 fast_distance(float4 left_vector, float4 right_vector); 116 #endif 117 118 /* 119 * fast_length: Approximate length of a vector 120 * 121 * Computes the approximate length of a vector. 122 * 123 * The precision is what would be expected from doing the computation using 16 bit floating 124 * point values. 125 * 126 * See also length(), native_length(). 127 */ 128 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 129 extern float __attribute__((const, overloadable)) 130 fast_length(float v); 131 #endif 132 133 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 134 extern float __attribute__((const, overloadable)) 135 fast_length(float2 v); 136 #endif 137 138 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 139 extern float __attribute__((const, overloadable)) 140 fast_length(float3 v); 141 #endif 142 143 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 144 extern float __attribute__((const, overloadable)) 145 fast_length(float4 v); 146 #endif 147 148 /* 149 * fast_normalize: Approximate normalized vector 150 * 151 * Approximately normalizes a vector. 152 * 153 * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for 154 * positive values. 155 * 156 * The precision is what would be expected from doing the computation using 16 bit floating 157 * point values. 158 * 159 * See also normalize(), native_normalize(). 160 */ 161 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 162 extern float __attribute__((const, overloadable)) 163 fast_normalize(float v); 164 #endif 165 166 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 167 extern float2 __attribute__((const, overloadable)) 168 fast_normalize(float2 v); 169 #endif 170 171 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 172 extern float3 __attribute__((const, overloadable)) 173 fast_normalize(float3 v); 174 #endif 175 176 #if (defined(RS_VERSION) && (RS_VERSION >= 17)) 177 extern float4 __attribute__((const, overloadable)) 178 fast_normalize(float4 v); 179 #endif 180 181 /* 182 * length: Length of a vector 183 * 184 * Computes the length of a vector. 185 * 186 * See also fast_length(), native_length(). 187 */ 188 extern float __attribute__((const, overloadable)) 189 length(float v); 190 191 extern float __attribute__((const, overloadable)) 192 length(float2 v); 193 194 extern float __attribute__((const, overloadable)) 195 length(float3 v); 196 197 extern float __attribute__((const, overloadable)) 198 length(float4 v); 199 200 /* 201 * native_distance: Approximate distance between two points 202 * 203 * Computes the approximate distance between two points. 204 * 205 * See also distance(), fast_distance(). 206 */ 207 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 208 extern float __attribute__((const, overloadable)) 209 native_distance(float left_vector, float right_vector); 210 #endif 211 212 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 213 extern float __attribute__((const, overloadable)) 214 native_distance(float2 left_vector, float2 right_vector); 215 #endif 216 217 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 218 extern float __attribute__((const, overloadable)) 219 native_distance(float3 left_vector, float3 right_vector); 220 #endif 221 222 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 223 extern float __attribute__((const, overloadable)) 224 native_distance(float4 left_vector, float4 right_vector); 225 #endif 226 227 /* 228 * native_length: Approximate length of a vector 229 * 230 * Compute the approximate length of a vector. 231 * 232 * See also length(), fast_length(). 233 */ 234 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 235 extern float __attribute__((const, overloadable)) 236 native_length(float v); 237 #endif 238 239 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 240 extern float __attribute__((const, overloadable)) 241 native_length(float2 v); 242 #endif 243 244 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 245 extern float __attribute__((const, overloadable)) 246 native_length(float3 v); 247 #endif 248 249 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 250 extern float __attribute__((const, overloadable)) 251 native_length(float4 v); 252 #endif 253 254 /* 255 * native_normalize: Approximately normalize a vector 256 * 257 * Approximately normalizes a vector. 258 * 259 * See also normalize(), fast_normalize(). 260 */ 261 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 262 extern float __attribute__((const, overloadable)) 263 native_normalize(float v); 264 #endif 265 266 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 267 extern float2 __attribute__((const, overloadable)) 268 native_normalize(float2 v); 269 #endif 270 271 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 272 extern float3 __attribute__((const, overloadable)) 273 native_normalize(float3 v); 274 #endif 275 276 #if (defined(RS_VERSION) && (RS_VERSION >= 21)) 277 extern float4 __attribute__((const, overloadable)) 278 native_normalize(float4 v); 279 #endif 280 281 /* 282 * normalize: Normalize a vector 283 * 284 * Normalize a vector. 285 * 286 * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for 287 * positive values. 288 * 289 * See also fast_normalize(), native_normalize(). 290 */ 291 extern float __attribute__((const, overloadable)) 292 normalize(float v); 293 294 extern float2 __attribute__((const, overloadable)) 295 normalize(float2 v); 296 297 extern float3 __attribute__((const, overloadable)) 298 normalize(float3 v); 299 300 extern float4 __attribute__((const, overloadable)) 301 normalize(float4 v); 302 303 #endif // RENDERSCRIPT_RS_VECTOR_MATH_RSH 304