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