1/*
2 * Copyright (C) 2016 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_value_types.rsh: Numerical Types
21 *
22 * Scalars:
23 *
24 * RenderScript supports the following scalar numerical types:
25 *
26 *                    8 bits           16 bits            32 bits          64 bits
27 * Integer:           char, int8_t     short, int16_t     int32_t          long, long long, int64_t
28 * Unsigned integer:  uchar, uint8_t   ushort, uint16_t   uint, uint32_t   ulong, uint64_t
29 * Floating point:                     half               float            double
30 *
31 *
32 * Vectors:
33 *
34 * RenderScript supports fixed size vectors of length 2, 3, and 4.
35 * Vectors are declared using the common type name followed by a 2, 3, or 4.
36 * E.g. float4, int3, double2, ulong4.
37 *
38 * To create vector literals, use the vector type followed by the values enclosed
39 * between curly braces, e.g. (float3){1.0f, 2.0f, 3.0f}.
40 *
41 * Entries of a vector can be accessed using different naming styles.
42 *
43 * Single entries can be accessed by following the variable name with a dot and:
44 * - The letters x, y, z, and w,
45 * - The letters r, g, b, and a,
46 * - The letter s or S, followed by a zero based index.
47 *
48 * For example, with int4 myVar; the following are equivalent:
49 *   myVar.x == myVar.r == myVar.s0 == myVar.S0
50 *   myVar.y == myVar.g == myVar.s1 == myVar.S1
51 *   myVar.z == myVar.b == myVar.s2 == myVar.S2
52 *   myVar.w == myVar.a == myVar.s3 == myVar.S3
53 *
54 * Multiple entries of a vector can be accessed at once by using an identifier that is
55 * the concatenation of multiple letters or indices.  The resulting vector has a size
56 * equal to the number of entries named.
57 *
58 * With the example above, the middle two entries can be accessed using
59 * myVar.yz, myVar.gb, myVar.s12, and myVar.S12.
60 *
61 * The entries don't have to be contiguous or in increasing order.  Entries can even be
62 * repeated, as long as we're not trying to assign to it.  You also can't mix the naming
63 * styles.
64 *
65 * Here are examples of what can or can't be done:
66 * float4 v4;
67 * float3 v3;
68 * float2 v2;
69 * v2 = v4.xx; // Valid
70 * v3 = v4.zxw; // Valid
71 * v3 = v4.bba; // Valid
72 * v3 = v4.s032; // Valid
73 * v3.s120 = v4.S233; // Valid
74 * v4.yz = v3.rg; // Valid
75 * v4.yzx = v3.rg; // Invalid: mismatched sizes
76 * v4.yzz = v3; // Invalid: z appears twice in an assignment
77 * v3 = v3.xas0; // Invalid: can't mix xyzw with rgba nor s0...
78 * v3 = v4.s034; // Invalid: the digit can only be 0, 1, 2, or 3
79 *
80 *
81 * Matrices and Quaternions:
82 *
83 * RenderScript supports fixed size square matrices of floats of size 2x2, 3x3, and 4x4.
84 * The types are named rs_matrix2x2, rs_matrix3x3, and rs_matrix4x4.  See
85 * Matrix Functions for the list of operations.
86 *
87 * Quaternions are also supported via rs_quaternion.  See Quaterion Functions for the list
88 * of operations.
89 */
90
91#ifndef RENDERSCRIPT_RS_VALUE_TYPES_RSH
92#define RENDERSCRIPT_RS_VALUE_TYPES_RSH
93
94/*
95 * half: 16 bit floating point value
96 *
97 * A 16 bit floating point value.
98 */
99#if (defined(RS_VERSION) && (RS_VERSION >= 23))
100typedef __fp16 half;
101#endif
102
103/*
104 * half2: Two 16 bit floats
105 *
106 * Vector version of the half float type. Provides two half fields packed
107 * into a single 32 bit field with 32 bit alignment.
108 */
109#if (defined(RS_VERSION) && (RS_VERSION >= 23))
110typedef half __attribute__((ext_vector_type(2))) half2;
111#endif
112
113/*
114 * half3: Three 16 bit floats
115 *
116 * Vector version of the half float type. Provides three half fields packed
117 * into a single 64 bit field with 64 bit alignment.
118 */
119#if (defined(RS_VERSION) && (RS_VERSION >= 23))
120typedef half __attribute__((ext_vector_type(3))) half3;
121#endif
122
123/*
124 * half4: Four 16 bit floats
125 *
126 * Vector version of the half float type. Provides four half fields packed
127 * into a single 64 bit field with 64 bit alignment.
128 */
129#if (defined(RS_VERSION) && (RS_VERSION >= 23))
130typedef half __attribute__((ext_vector_type(4))) half4;
131#endif
132
133/*
134 * int8_t: 8 bit signed integer
135 *
136 * 8 bit signed integer type.
137 */
138typedef char int8_t;
139
140/*
141 * int16_t: 16 bit signed integer
142 *
143 * A 16 bit signed integer type.
144 */
145typedef short int16_t;
146
147/*
148 * int32_t: 32 bit signed integer
149 *
150 * A 32 bit signed integer type.
151 */
152typedef int int32_t;
153
154/*
155 * int64_t: 64 bit signed integer
156 *
157 * A 64 bit signed integer type.
158 */
159#if !defined(RS_VERSION) || (RS_VERSION <= 20)
160typedef long long int64_t;
161#endif
162
163#if (defined(RS_VERSION) && (RS_VERSION >= 21))
164typedef long int64_t;
165#endif
166
167/*
168 * uint8_t: 8 bit unsigned integer
169 *
170 * 8 bit unsigned integer type.
171 */
172typedef unsigned char uint8_t;
173
174/*
175 * uint16_t: 16 bit unsigned integer
176 *
177 * A 16 bit unsigned integer type.
178 */
179typedef unsigned short uint16_t;
180
181/*
182 * uint32_t: 32 bit unsigned integer
183 *
184 * A 32 bit unsigned integer type.
185 */
186typedef unsigned int uint32_t;
187
188/*
189 * uint64_t: 64 bit unsigned integer
190 *
191 * A 64 bit unsigned integer type.
192 */
193#if !defined(RS_VERSION) || (RS_VERSION <= 20)
194typedef unsigned long long uint64_t;
195#endif
196
197#if (defined(RS_VERSION) && (RS_VERSION >= 21))
198typedef unsigned long uint64_t;
199#endif
200
201/*
202 * uchar: 8 bit unsigned integer
203 *
204 * 8 bit unsigned integer type.
205 */
206typedef uint8_t uchar;
207
208/*
209 * ushort: 16 bit unsigned integer
210 *
211 * A 16 bit unsigned integer type.
212 */
213typedef uint16_t ushort;
214
215/*
216 * uint: 32 bit unsigned integer
217 *
218 * A 32 bit unsigned integer type.
219 */
220typedef uint32_t uint;
221
222/*
223 * ulong: 64 bit unsigned integer
224 *
225 * A 64 bit unsigned integer type.
226 */
227typedef uint64_t ulong;
228
229/*
230 * size_t: Unsigned size type
231 *
232 * Unsigned size type.  The number of bits depend on the compilation flags.
233 */
234#ifdef __LP64__
235typedef uint64_t size_t;
236#endif
237
238#ifndef __LP64__
239typedef uint32_t size_t;
240#endif
241
242/*
243 * ssize_t: Signed size type
244 *
245 * Signed size type.  The number of bits depend on the compilation flags.
246 */
247#ifdef __LP64__
248typedef int64_t ssize_t;
249#endif
250
251#ifndef __LP64__
252typedef int32_t ssize_t;
253#endif
254
255/*
256 * float2: Two 32 bit floats
257 *
258 * A vector of two floats.  These two floats are packed into a single 64 bit field
259 * with a 64 bit alignment.
260 *
261 * A vector of two floats.  These two floats are packed into a single 64 bit field
262 * with a 64 bit alignment.
263 */
264typedef float __attribute__((ext_vector_type(2))) float2;
265
266/*
267 * float3: Three 32 bit floats
268 *
269 * A vector of three floats.  These three floats are packed into a single 128 bit field
270 * with a 128 bit alignment.
271 */
272typedef float __attribute__((ext_vector_type(3))) float3;
273
274/*
275 * float4: Four 32 bit floats
276 *
277 * A vector of four floats type.  These four floats are packed into a single 128 bit field
278 * with a 128 bit alignment.
279 */
280typedef float __attribute__((ext_vector_type(4))) float4;
281
282/*
283 * double2: Two 64 bit floats
284 *
285 * A vector of two doubles.  These two double fields packed into a single 128 bit field
286 * with a 128 bit alignment.
287 */
288typedef double __attribute__((ext_vector_type(2))) double2;
289
290/*
291 * double3: Three 64 bit floats
292 *
293 * A vector of three doubles.  These three double fields packed into a single 256 bit field
294 * with a 256 bit alignment.
295 */
296typedef double __attribute__((ext_vector_type(3))) double3;
297
298/*
299 * double4: Four 64 bit floats
300 *
301 * A vector of four doubles.  These four double fields packed into a single 256 bit field
302 * with a 256 bit alignment.
303 */
304typedef double __attribute__((ext_vector_type(4))) double4;
305
306/*
307 * uchar2: Two 8 bit unsigned integers
308 *
309 * A vector of two uchars.  These two uchar fields packed into a single 16 bit field
310 * with a 16 bit alignment.
311 */
312typedef uchar __attribute__((ext_vector_type(2))) uchar2;
313
314/*
315 * uchar3: Three 8 bit unsigned integers
316 *
317 * A vector of three uchars.  These three uchar fields packed into a single 32 bit field
318 * with a 32 bit alignment.
319 */
320typedef uchar __attribute__((ext_vector_type(3))) uchar3;
321
322/*
323 * uchar4: Four 8 bit unsigned integers
324 *
325 * A vector of four uchars.  These four uchar fields packed into a single 32 bit field
326 * with a 32 bit alignment.
327 */
328typedef uchar __attribute__((ext_vector_type(4))) uchar4;
329
330/*
331 * ushort2: Two 16 bit unsigned integers
332 *
333 * A vector of two ushorts.  These two ushort fields packed into a single 32 bit field
334 * with a 32 bit alignment.
335 */
336typedef ushort __attribute__((ext_vector_type(2))) ushort2;
337
338/*
339 * ushort3: Three 16 bit unsigned integers
340 *
341 * A vector of three ushorts.  These three ushort fields packed into a single 64 bit field
342 * with a 64 bit alignment.
343 */
344typedef ushort __attribute__((ext_vector_type(3))) ushort3;
345
346/*
347 * ushort4: Four 16 bit unsigned integers
348 *
349 * A vector of four ushorts.  These four ushort fields packed into a single 64 bit field
350 * with a 64 bit alignment.
351 */
352typedef ushort __attribute__((ext_vector_type(4))) ushort4;
353
354/*
355 * uint2: Two 32 bit unsigned integers
356 *
357 * A vector of two uints.  These two uints are packed into a single 64 bit field
358 * with a 64 bit alignment.
359 */
360typedef uint __attribute__((ext_vector_type(2))) uint2;
361
362/*
363 * uint3: Three 32 bit unsigned integers
364 *
365 * A vector of three uints.  These three uints are packed into a single 128 bit field
366 * with a 128 bit alignment.
367 */
368typedef uint __attribute__((ext_vector_type(3))) uint3;
369
370/*
371 * uint4: Four 32 bit unsigned integers
372 *
373 * A vector of four uints.  These four uints are packed into a single 128 bit field
374 * with a 128 bit alignment.
375 */
376typedef uint __attribute__((ext_vector_type(4))) uint4;
377
378/*
379 * ulong2: Two 64 bit unsigned integers
380 *
381 * A vector of two ulongs.  These two ulongs are packed into a single 128 bit field
382 * with a 128 bit alignment.
383 */
384typedef ulong __attribute__((ext_vector_type(2))) ulong2;
385
386/*
387 * ulong3: Three 64 bit unsigned integers
388 *
389 * A vector of three ulongs.  These three ulong fields packed into a single 256 bit field
390 * with a 256 bit alignment.
391 */
392typedef ulong __attribute__((ext_vector_type(3))) ulong3;
393
394/*
395 * ulong4: Four 64 bit unsigned integers
396 *
397 * A vector of four ulongs.  These four ulong fields packed into a single 256 bit field
398 * with a 256 bit alignment.
399 */
400typedef ulong __attribute__((ext_vector_type(4))) ulong4;
401
402/*
403 * char2: Two 8 bit signed integers
404 *
405 * A vector of two chars.  These two chars are packed into a single 16 bit field
406 * with a 16 bit alignment.
407 */
408typedef char __attribute__((ext_vector_type(2))) char2;
409
410/*
411 * char3: Three 8 bit signed integers
412 *
413 * A vector of three chars.  These three chars are packed into a single 32 bit field
414 * with a 32 bit alignment.
415 */
416typedef char __attribute__((ext_vector_type(3))) char3;
417
418/*
419 * char4: Four 8 bit signed integers
420 *
421 * A vector of four chars.  These four chars are packed into a single 32 bit field
422 * with a 32 bit alignment.
423 */
424typedef char __attribute__((ext_vector_type(4))) char4;
425
426/*
427 * short2: Two 16 bit signed integers
428 *
429 * A vector of two shorts.  These two shorts are packed into a single 32 bit field
430 * with a 32 bit alignment.
431 */
432typedef short __attribute__((ext_vector_type(2))) short2;
433
434/*
435 * short3: Three 16 bit signed integers
436 *
437 * A vector of three shorts.  These three short fields packed into a single 64 bit field
438 * with a 64 bit alignment.
439 */
440typedef short __attribute__((ext_vector_type(3))) short3;
441
442/*
443 * short4: Four 16 bit signed integers
444 *
445 * A vector of four shorts.  These four short fields packed into a single 64 bit field
446 * with a 64 bit alignment.
447 */
448typedef short __attribute__((ext_vector_type(4))) short4;
449
450/*
451 * int2: Two 32 bit signed integers
452 *
453 * A vector of two ints.  These two ints are packed into a single 64 bit field
454 * with a 64 bit alignment.
455 */
456typedef int __attribute__((ext_vector_type(2))) int2;
457
458/*
459 * int3: Three 32 bit signed integers
460 *
461 * A vector of three ints.  These three ints are packed into a single 128 bit field
462 * with a 128 bit alignment.
463 */
464typedef int __attribute__((ext_vector_type(3))) int3;
465
466/*
467 * int4: Four 32 bit signed integers
468 *
469 * A vector of four ints.  These two fours are packed into a single 128 bit field
470 * with a 128 bit alignment.
471 */
472typedef int __attribute__((ext_vector_type(4))) int4;
473
474/*
475 * long2: Two 64 bit signed integers
476 *
477 * A vector of two longs.  These two longs are packed into a single 128 bit field
478 * with a 128 bit alignment.
479 */
480typedef long __attribute__((ext_vector_type(2))) long2;
481
482/*
483 * long3: Three 64 bit signed integers
484 *
485 * A vector of three longs.  These three longs are packed into a single 256 bit field
486 * with a 256 bit alignment.
487 */
488typedef long __attribute__((ext_vector_type(3))) long3;
489
490/*
491 * long4: Four 64 bit signed integers
492 *
493 * A vector of four longs.  These four longs are packed into a single 256 bit field
494 * with a 256 bit alignment.
495 */
496typedef long __attribute__((ext_vector_type(4))) long4;
497
498/*
499 * rs_matrix2x2: 2x2 matrix of 32 bit floats
500 *
501 * A square 2x2 matrix of floats.  The entries are stored in the array at the
502 * location [row*2 + col].
503 *
504 * See Matrix Functions.
505 */
506typedef struct {
507    float m[4];
508} rs_matrix2x2;
509
510/*
511 * rs_matrix3x3: 3x3 matrix of 32 bit floats
512 *
513 * A square 3x3 matrix of floats.  The entries are stored in the array at the
514 * location [row*3 + col].
515 *
516 * See Matrix Functions.
517 */
518typedef struct {
519    float m[9];
520} rs_matrix3x3;
521
522/*
523 * rs_matrix4x4: 4x4 matrix of 32 bit floats
524 *
525 * A square 4x4 matrix of floats.  The entries are stored in the array at the
526 * location [row*4 + col].
527 *
528 * See Matrix Functions.
529 */
530typedef struct {
531    float m[16];
532} rs_matrix4x4;
533
534/*
535 * rs_quaternion: Quaternion
536 *
537 * A square 4x4 matrix of floats that represents a quaternion.
538 *
539 * See Quaternion Functions.
540 */
541typedef float4 rs_quaternion;
542
543#endif // RENDERSCRIPT_RS_VALUE_TYPES_RSH
544