2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 // Don't edit this file! It is auto-generated by frameworks/rs/api/generate.sh.
20 * rs_vector_math.rsh: Vector Math Functions
22 * These functions interpret the input arguments as representation of vectors in
23 * n-dimensional space.
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.
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.
38 #ifndef RENDERSCRIPT_RS_VECTOR_MATH_RSH
39 #define RENDERSCRIPT_RS_VECTOR_MATH_RSH
42 * cross: Cross product of two vectors
44 * Computes the cross product of two vectors.
46 extern float3 __attribute__((const, overloadable))
47 cross(float3 left_vector, float3 right_vector);
49 extern float4 __attribute__((const, overloadable))
50 cross(float4 left_vector, float4 right_vector);
52 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
53 extern half3 __attribute__((const, overloadable))
54 cross(half3 left_vector, half3 right_vector);
57 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
58 extern half4 __attribute__((const, overloadable))
59 cross(half4 left_vector, half4 right_vector);
63 * distance: Distance between two points
65 * Compute the distance between two points.
67 * See also fast_distance(), native_distance().
69 extern float __attribute__((const, overloadable))
70 distance(float left_vector, float right_vector);
72 extern float __attribute__((const, overloadable))
73 distance(float2 left_vector, float2 right_vector);
75 extern float __attribute__((const, overloadable))
76 distance(float3 left_vector, float3 right_vector);
78 extern float __attribute__((const, overloadable))
79 distance(float4 left_vector, float4 right_vector);
81 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
82 extern half __attribute__((const, overloadable))
83 distance(half left_vector, half right_vector);
86 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
87 extern half __attribute__((const, overloadable))
88 distance(half2 left_vector, half2 right_vector);
91 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
92 extern half __attribute__((const, overloadable))
93 distance(half3 left_vector, half3 right_vector);
96 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
97 extern half __attribute__((const, overloadable))
98 distance(half4 left_vector, half4 right_vector);
102 * dot: Dot product of two vectors
104 * Computes the dot product of two vectors.
106 extern float __attribute__((const, overloadable))
107 dot(float left_vector, float right_vector);
109 extern float __attribute__((const, overloadable))
110 dot(float2 left_vector, float2 right_vector);
112 extern float __attribute__((const, overloadable))
113 dot(float3 left_vector, float3 right_vector);
115 extern float __attribute__((const, overloadable))
116 dot(float4 left_vector, float4 right_vector);
118 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
119 extern half __attribute__((const, overloadable))
120 dot(half left_vector, half right_vector);
123 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
124 extern half __attribute__((const, overloadable))
125 dot(half2 left_vector, half2 right_vector);
128 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
129 extern half __attribute__((const, overloadable))
130 dot(half3 left_vector, half3 right_vector);
133 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
134 extern half __attribute__((const, overloadable))
135 dot(half4 left_vector, half4 right_vector);
139 * fast_distance: Approximate distance between two points
141 * Computes the approximate distance between two points.
143 * The precision is what would be expected from doing the computation using 16 bit floating
146 * See also distance(), native_distance().
148 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
149 extern float __attribute__((const, overloadable))
150 fast_distance(float left_vector, float right_vector);
153 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
154 extern float __attribute__((const, overloadable))
155 fast_distance(float2 left_vector, float2 right_vector);
158 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
159 extern float __attribute__((const, overloadable))
160 fast_distance(float3 left_vector, float3 right_vector);
163 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
164 extern float __attribute__((const, overloadable))
165 fast_distance(float4 left_vector, float4 right_vector);
169 * fast_length: Approximate length of a vector
171 * Computes the approximate length of a vector.
173 * The precision is what would be expected from doing the computation using 16 bit floating
176 * See also length(), native_length().
178 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
179 extern float __attribute__((const, overloadable))
180 fast_length(float v);
183 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
184 extern float __attribute__((const, overloadable))
185 fast_length(float2 v);
188 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
189 extern float __attribute__((const, overloadable))
190 fast_length(float3 v);
193 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
194 extern float __attribute__((const, overloadable))
195 fast_length(float4 v);
199 * fast_normalize: Approximate normalized vector
201 * Approximately normalizes a vector.
203 * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for
206 * The precision is what would be expected from doing the computation using 16 bit floating
209 * See also normalize(), native_normalize().
211 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
212 extern float __attribute__((const, overloadable))
213 fast_normalize(float v);
216 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
217 extern float2 __attribute__((const, overloadable))
218 fast_normalize(float2 v);
221 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
222 extern float3 __attribute__((const, overloadable))
223 fast_normalize(float3 v);
226 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
227 extern float4 __attribute__((const, overloadable))
228 fast_normalize(float4 v);
232 * length: Length of a vector
234 * Computes the length of a vector.
236 * See also fast_length(), native_length().
238 extern float __attribute__((const, overloadable))
241 extern float __attribute__((const, overloadable))
244 extern float __attribute__((const, overloadable))
247 extern float __attribute__((const, overloadable))
250 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
251 extern half __attribute__((const, overloadable))
255 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
256 extern half __attribute__((const, overloadable))
260 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
261 extern half __attribute__((const, overloadable))
265 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
266 extern half __attribute__((const, overloadable))
271 * native_distance: Approximate distance between two points
273 * Computes the approximate distance between two points.
275 * See also distance(), fast_distance().
277 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
278 extern float __attribute__((const, overloadable))
279 native_distance(float left_vector, float right_vector);
282 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
283 extern float __attribute__((const, overloadable))
284 native_distance(float2 left_vector, float2 right_vector);
287 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
288 extern float __attribute__((const, overloadable))
289 native_distance(float3 left_vector, float3 right_vector);
292 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
293 extern float __attribute__((const, overloadable))
294 native_distance(float4 left_vector, float4 right_vector);
297 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
298 extern half __attribute__((const, overloadable))
299 native_distance(half left_vector, half right_vector);
302 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
303 extern half __attribute__((const, overloadable))
304 native_distance(half2 left_vector, half2 right_vector);
307 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
308 extern half __attribute__((const, overloadable))
309 native_distance(half3 left_vector, half3 right_vector);
312 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
313 extern half __attribute__((const, overloadable))
314 native_distance(half4 left_vector, half4 right_vector);
318 * native_length: Approximate length of a vector
320 * Compute the approximate length of a vector.
322 * See also length(), fast_length().
324 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
325 extern float __attribute__((const, overloadable))
326 native_length(float v);
329 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
330 extern float __attribute__((const, overloadable))
331 native_length(float2 v);
334 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
335 extern float __attribute__((const, overloadable))
336 native_length(float3 v);
339 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
340 extern float __attribute__((const, overloadable))
341 native_length(float4 v);
344 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
345 extern half __attribute__((const, overloadable))
346 native_length(half v);
349 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
350 extern half __attribute__((const, overloadable))
351 native_length(half2 v);
354 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
355 extern half __attribute__((const, overloadable))
356 native_length(half3 v);
359 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
360 extern half __attribute__((const, overloadable))
361 native_length(half4 v);
365 * native_normalize: Approximately normalize a vector
367 * Approximately normalizes a vector.
369 * See also normalize(), fast_normalize().
371 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
372 extern float __attribute__((const, overloadable))
373 native_normalize(float v);
376 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
377 extern float2 __attribute__((const, overloadable))
378 native_normalize(float2 v);
381 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
382 extern float3 __attribute__((const, overloadable))
383 native_normalize(float3 v);
386 #if (defined(RS_VERSION) && (RS_VERSION >= 21))
387 extern float4 __attribute__((const, overloadable))
388 native_normalize(float4 v);
391 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
392 extern half __attribute__((const, overloadable))
393 native_normalize(half v);
396 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
397 extern half2 __attribute__((const, overloadable))
398 native_normalize(half2 v);
401 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
402 extern half3 __attribute__((const, overloadable))
403 native_normalize(half3 v);
406 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
407 extern half4 __attribute__((const, overloadable))
408 native_normalize(half4 v);
412 * normalize: Normalize a vector
414 * Normalize a vector.
416 * For vectors of size 1, returns -1.f for negative values, 0.f for null values, and 1.f for
419 * See also fast_normalize(), native_normalize().
421 extern float __attribute__((const, overloadable))
424 extern float2 __attribute__((const, overloadable))
427 extern float3 __attribute__((const, overloadable))
430 extern float4 __attribute__((const, overloadable))
433 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
434 extern half __attribute__((const, overloadable))
438 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
439 extern half2 __attribute__((const, overloadable))
443 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
444 extern half3 __attribute__((const, overloadable))
448 #if (defined(RS_VERSION) && (RS_VERSION >= 24))
449 extern half4 __attribute__((const, overloadable))
453 #endif // RENDERSCRIPT_RS_VECTOR_MATH_RSH