summaryrefslogtreecommitdiff
path: root/api/rs_value_types.spec
blob: ef1ce4fc5cc86979617a77e4017cf4894c9eced6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
#
# Copyright (C) 2015 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

header:
summary: Numerical Types
description:
 <h5>Scalars:</h5>

 RenderScript supports the following scalar numerical types:
 <table>
 <tr><td>                 </td>  <td>8 bits        </td>   <td>16 bits         </td>   <td>32 bits       </td>   <td>64 bits</td></tr>
 <tr><td>Integer:         </td>  <td>char, @int8_t  </td>   <td>short, @int16_t  </td>   <td>@int32_t       </td>   <td>long, long long, @int64_t</td></tr>
 <tr><td>Unsigned integer:</td>  <td>uchar, @uint8_t</td>   <td>ushort, @uint16_t</td>   <td>uint, @uint32_t</td>   <td>ulong, @uint64_t</td></tr>
 <tr><td>Floating point:  </td>  <td>              </td>   <td>half            </td>   <td>float         </td>   <td>double</td></tr>
 </table>

 <h5>Vectors:</h5>

 RenderScript supports fixed size vectors of length 2, 3, and 4.
 Vectors are declared using the common type name followed by a 2, 3, or 4.
 E.g. @float4, @int3, @double2, @ulong4.

 To create vector literals, use the vector type followed by the values enclosed
 between parentheses, e.g. <code>(float3)(1.0f, 2.0f, 3.0f)</code>.

 Entries of a vector can be accessed using different naming styles.

 Single entries can be accessed by following the variable name with a dot and:<ul>
 <li>The letters x, y, z, and w,</li>
 <li>The letters r, g, b, and a,</li>
 <li>The letter s or S, followed by a zero based index.</li></ul>

 For example, with <code>int4 myVar;</code> the following are equivalent:<code><br/>
   myVar.x == myVar.r == myVar.s0 == myVar.S0<br/>
   myVar.y == myVar.g == myVar.s1 == myVar.S1<br/>
   myVar.z == myVar.b == myVar.s2 == myVar.S2<br/>
   myVar.w == myVar.a == myVar.s3 == myVar.S3</code>

 Multiple entries of a vector can be accessed at once by using an identifier that is
 the concatenation of multiple letters or indices.  The resulting vector has a size
 equal to the number of entries named.

 With the example above, the middle two entries can be accessed using
 <code>myVar.yz</code>, <code>myVar.gb</code>, <code>myVar.s12</code>, and <code>myVar.S12</code>.

 The entries don't have to be contiguous or in increasing order.  Entries can even be
 repeated, as long as we're not trying to assign to it.  You also can't mix the naming
 styles.

 Here are examples of what can or can't be done:<code><br/>
 float4 v4;<br/>
 float3 v3;<br/>
 float2 v2;<br/>
 v2 = v4.xx; // Valid<br/>
 v3 = v4.zxw; // Valid<br/>
 v3 = v4.bba; // Valid<br/>
 v3 = v4.s032; // Valid<br/>
 v3.s120 = v4.S233; // Valid<br/>
 v4.yz = v3.rg; // Valid<br/>
 v4.yzx = v3.rg; // Invalid: mismatched sizes<br/>
 v4.yzz = v3; // Invalid: z appears twice in an assignment<br/>
 v3 = v3.xas0; // Invalid: can't mix xyzw with rgba nor s0...<br/>
 v3 = v4.s034; // Invalid: the digit can only be 0, 1, 2, or 3<br/>
 </code>

 <h5>Matrices and Quaternions:</h5>

 RenderScript supports fixed size square matrices of floats of size 2x2, 3x3, and 4x4.
 The types are named @rs_matrix2x2, @rs_matrix3x3, and @rs_matrix4x4.  See
 <a href='rs_matrix.html'>Matrix Functions</a> for the list of operations.

 Quaternions are also supported via @rs_quaternion.  See <a href='rs_quaternion.html'>Quaterion Functions</a> for the list
 of operations.
end:

type: half
version: 23
simple: __fp16
summary: 16 bit floating point value
description:
 A 16 bit floating point value.
end:

type: half2
version: 23
simple: half __attribute__((ext_vector_type(2)))
summary: Two 16 bit floats
description:
 Vector version of the half float type. Provides two half fields packed
 into a single 32 bit field with 32 bit alignment.
end:

type: half3
version: 23
simple: half __attribute__((ext_vector_type(3)))
summary: Three 16 bit floats
description:
 Vector version of the half float type. Provides three half fields packed
 into a single 64 bit field with 64 bit alignment.
end:

type: half4
version: 23
simple: half __attribute__((ext_vector_type(4)))
summary: Four 16 bit floats
description:
 Vector version of the half float type. Provides four half fields packed
 into a single 64 bit field with 64 bit alignment.
end:


type: int8_t
simple: char
summary: 8 bit signed integer
description:
 8 bit signed integer type.
end:

type: int16_t
simple: short
summary: 16 bit signed integer
description:
 A 16 bit signed integer type.
end:

type: int32_t
simple: int
summary: 32 bit signed integer
description:
 A 32 bit signed integer type.
end:

type: int64_t
version: 9 20
simple: long long
summary: 64 bit signed integer
description:
 A 64 bit signed integer type.
end:

type: int64_t
version: 21
simple: long
end:

type: uint8_t
simple: unsigned char
summary: 8 bit unsigned integer
description:
 8 bit unsigned integer type.
end:

type: uint16_t
simple: unsigned short
summary: 16 bit unsigned integer
description:
 A 16 bit unsigned integer type.
end:

type: uint32_t
simple: unsigned int
summary: 32 bit unsigned integer
description:
 A 32 bit unsigned integer type.
end:

type: uint64_t
version: 9 20
simple: unsigned long long
summary: 64 bit unsigned integer
description:
 A 64 bit unsigned integer type.
end:

type: uint64_t
version: 21
simple: unsigned long
end:

type: uchar
simple: uint8_t
summary: 8 bit unsigned integer
description:
 8 bit unsigned integer type.
end:

type: ushort
simple: uint16_t
summary: 16 bit unsigned integer
description:
 A 16 bit unsigned integer type.
end:

type: uint
simple: uint32_t
summary: 32 bit unsigned integer
description:
 A 32 bit unsigned integer type.
end:

type: ulong
simple: uint64_t
summary: 64 bit unsigned integer
description:
 A 64 bit unsigned integer type.
end:

type: size_t
size: 64
simple: uint64_t
summary: Unsigned size type
description:
 Unsigned size type.  The number of bits depend on the compilation flags.
end:

type: size_t
size: 32
simple: uint32_t
end:

type: ssize_t
size: 64
simple: int64_t
summary: Signed size type
description:
 Signed size type.  The number of bits depend on the compilation flags.
end:

type: ssize_t
size: 32
simple: int32_t
end:

type: float2
simple: float
attrib: ext_vector_type(2)
summary: Two 32 bit floats
description:
 A vector of two floats.  These two floats are packed into a single 64 bit field
 with a 64 bit alignment.

 A vector of two floats.  These two floats are packed into a single 64 bit field
 with a 64 bit alignment.
end:

type: float3
simple: float
attrib: ext_vector_type(3)
summary: Three 32 bit floats
description:
 A vector of three floats.  These three floats are packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: float4
simple: float
attrib: ext_vector_type(4)
summary: Four 32 bit floats
description:
 A vector of four floats type.  These four floats are packed into a single 128 bit field
 with a 128 bit alignment.
end:


type: double2
simple: double
attrib: ext_vector_type(2)
summary: Two 64 bit floats
description:
 A vector of two doubles.  These two double fields packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: double3
simple: double
attrib: ext_vector_type(3)
summary: Three 64 bit floats
description:
 A vector of three doubles.  These three double fields packed into a single 256 bit field
 with a 256 bit alignment.
end:

type: double4
simple: double
attrib: ext_vector_type(4)
summary: Four 64 bit floats
description:
 A vector of four doubles.  These four double fields packed into a single 256 bit field
 with a 256 bit alignment.
end:


type: uchar2
simple: uchar
attrib: ext_vector_type(2)
summary: Two 8 bit unsigned integers
description:
 A vector of two uchars.  These two uchar fields packed into a single 16 bit field
 with a 16 bit alignment.
end:

type: uchar3
simple: uchar
attrib: ext_vector_type(3)
summary: Three 8 bit unsigned integers
description:
 A vector of three uchars.  These three uchar fields packed into a single 32 bit field
 with a 32 bit alignment.
end:

type: uchar4
simple: uchar
attrib: ext_vector_type(4)
summary: Four 8 bit unsigned integers
description:
 A vector of four uchars.  These four uchar fields packed into a single 32 bit field
 with a 32 bit alignment.
end:


type: ushort2
simple: ushort
attrib: ext_vector_type(2)
summary: Two 16 bit unsigned integers
description:
 A vector of two ushorts.  These two ushort fields packed into a single 32 bit field
 with a 32 bit alignment.
end:

type: ushort3
simple: ushort
attrib: ext_vector_type(3)
summary: Three 16 bit unsigned integers
description:
 A vector of three ushorts.  These three ushort fields packed into a single 64 bit field
 with a 64 bit alignment.
end:

type: ushort4
simple: ushort
attrib: ext_vector_type(4)
summary: Four 16 bit unsigned integers
description:
 A vector of four ushorts.  These four ushort fields packed into a single 64 bit field
 with a 64 bit alignment.
end:


type: uint2
simple: uint
attrib: ext_vector_type(2)
summary: Two 32 bit unsigned integers
description:
 A vector of two uints.  These two uints are packed into a single 64 bit field
 with a 64 bit alignment.
end:

type: uint3
simple: uint
attrib: ext_vector_type(3)
summary: Three 32 bit unsigned integers
description:
 A vector of three uints.  These three uints are packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: uint4
simple: uint
attrib: ext_vector_type(4)
summary: Four 32 bit unsigned integers
description:
 A vector of four uints.  These four uints are packed into a single 128 bit field
 with a 128 bit alignment.
end:


type: ulong2
simple: ulong
attrib: ext_vector_type(2)
summary: Two 64 bit unsigned integers
description:
 A vector of two ulongs.  These two ulongs are packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: ulong3
simple: ulong
attrib: ext_vector_type(3)
summary: Three 64 bit unsigned integers
description:
 A vector of three ulongs.  These three ulong fields packed into a single 256 bit field
 with a 256 bit alignment.
end:

type: ulong4
simple: ulong
attrib: ext_vector_type(4)
summary: Four 64 bit unsigned integers
description:
 A vector of four ulongs.  These four ulong fields packed into a single 256 bit field
 with a 256 bit alignment.
end:


type: char2
simple: char
attrib: ext_vector_type(2)
summary: Two 8 bit signed integers
description:
 A vector of two chars.  These two chars are packed into a single 16 bit field
 with a 16 bit alignment.
end:

type: char3
simple: char
attrib: ext_vector_type(3)
summary: Three 8 bit signed integers
description:
 A vector of three chars.  These three chars are packed into a single 32 bit field
 with a 32 bit alignment.
end:

type: char4
simple: char
attrib: ext_vector_type(4)
summary: Four 8 bit signed integers
description:
 A vector of four chars.  These four chars are packed into a single 32 bit field
 with a 32 bit alignment.
end:


type: short2
simple: short
attrib: ext_vector_type(2)
summary: Two 16 bit signed integers
description:
 A vector of two shorts.  These two shorts are packed into a single 32 bit field
 with a 32 bit alignment.
end:

type: short3
simple: short
attrib: ext_vector_type(3)
summary: Three 16 bit signed integers
description:
 A vector of three shorts.  These three short fields packed into a single 64 bit field
 with a 64 bit alignment.
end:

type: short4
simple: short
attrib: ext_vector_type(4)
summary: Four 16 bit signed integers
description:
 A vector of four shorts.  These four short fields packed into a single 64 bit field
 with a 64 bit alignment.
end:


type: int2
simple: int
attrib: ext_vector_type(2)
summary: Two 32 bit signed integers
description:
 A vector of two ints.  These two ints are packed into a single 64 bit field
 with a 64 bit alignment.
end:

type: int3
simple: int
attrib: ext_vector_type(3)
summary: Three 32 bit signed integers
description:
 A vector of three ints.  These three ints are packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: int4
simple: int
attrib: ext_vector_type(4)
summary: Four 32 bit signed integers
description:
 A vector of four ints.  These two fours are packed into a single 128 bit field
 with a 128 bit alignment.
end:


type: long2
simple: long
attrib: ext_vector_type(2)
summary: Two 64 bit signed integers
description:
 A vector of two longs.  These two longs are packed into a single 128 bit field
 with a 128 bit alignment.
end:

type: long3
simple: long
attrib: ext_vector_type(3)
summary: Three 64 bit signed integers
description:
 A vector of three longs.  These three longs are packed into a single 256 bit field
 with a 256 bit alignment.
end:

type: long4
simple: long
attrib: ext_vector_type(4)
summary: Four 64 bit signed integers
description:
 A vector of four longs.  These four longs are packed into a single 256 bit field
 with a 256 bit alignment.
end:


type: rs_matrix2x2
struct:
field: float m[4]
summary: 2x2 matrix of 32 bit floats
description:
 A square 2x2 matrix of floats.  The entries are stored in the array at the
 location [row*2 + col].

 See <a href='rs_matrix.html'>Matrix Functions</a>.
end:

type: rs_matrix3x3
struct:
field: float m[9]
summary: 3x3 matrix of 32 bit floats
description:
 A square 3x3 matrix of floats.  The entries are stored in the array at the
 location [row*3 + col].

 See <a href='rs_matrix.html'>Matrix Functions</a>.
end:

type: rs_matrix4x4
struct:
field: float m[16]
summary: 4x4 matrix of 32 bit floats
description:
 A square 4x4 matrix of floats.  The entries are stored in the array at the
 location [row*4 + col].

 See <a href='rs_matrix.html'>Matrix Functions</a>.
end:


type: rs_quaternion
simple: float4
summary: Quaternion
description:
 A square 4x4 matrix of floats that represents a quaternion.

 See <a href='rs_quaternion.html'>Quaternion Functions</a>.
end: