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 header: 18 summary: Numerical Types 19 description: 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. 87 end: 88 89 type: half 90 version: 23 91 simple: __fp16 92 summary: 16 bit floating point value 93 description: 94 A 16 bit floating point value. 95 end: 96 97 type: half2 98 version: 23 99 simple: half 100 attrib: ext_vector_type(2) 101 summary: Two 16 bit floats 102 description: 103 Vector version of the half float type. Provides two half fields packed 104 into a single 32 bit field with 32 bit alignment. 105 end: 106 107 type: half3 108 version: 23 109 simple: half 110 attrib: ext_vector_type(3) 111 summary: Three 16 bit floats 112 description: 113 Vector version of the half float type. Provides three half fields packed 114 into a single 64 bit field with 64 bit alignment. 115 end: 116 117 type: half4 118 version: 23 119 simple: half 120 attrib: ext_vector_type(4) 121 summary: Four 16 bit floats 122 description: 123 Vector version of the half float type. Provides four half fields packed 124 into a single 64 bit field with 64 bit alignment. 125 end: 126 127 128 type: int8_t 129 simple: char 130 summary: 8 bit signed integer 131 description: 132 8 bit signed integer type. 133 end: 134 135 type: int16_t 136 simple: short 137 summary: 16 bit signed integer 138 description: 139 A 16 bit signed integer type. 140 end: 141 142 type: int32_t 143 simple: int 144 summary: 32 bit signed integer 145 description: 146 A 32 bit signed integer type. 147 end: 148 149 type: int64_t 150 version: 9 20 151 simple: long long 152 summary: 64 bit signed integer 153 description: 154 A 64 bit signed integer type. 155 end: 156 157 type: int64_t 158 version: 21 159 simple: long 160 end: 161 162 type: uint8_t 163 simple: unsigned char 164 summary: 8 bit unsigned integer 165 description: 166 8 bit unsigned integer type. 167 end: 168 169 type: uint16_t 170 simple: unsigned short 171 summary: 16 bit unsigned integer 172 description: 173 A 16 bit unsigned integer type. 174 end: 175 176 type: uint32_t 177 simple: unsigned int 178 summary: 32 bit unsigned integer 179 description: 180 A 32 bit unsigned integer type. 181 end: 182 183 type: uint64_t 184 version: 9 20 185 simple: unsigned long long 186 summary: 64 bit unsigned integer 187 description: 188 A 64 bit unsigned integer type. 189 end: 190 191 type: uint64_t 192 version: 21 193 simple: unsigned long 194 end: 195 196 type: uchar 197 simple: uint8_t 198 summary: 8 bit unsigned integer 199 description: 200 8 bit unsigned integer type. 201 end: 202 203 type: ushort 204 simple: uint16_t 205 summary: 16 bit unsigned integer 206 description: 207 A 16 bit unsigned integer type. 208 end: 209 210 type: uint 211 simple: uint32_t 212 summary: 32 bit unsigned integer 213 description: 214 A 32 bit unsigned integer type. 215 end: 216 217 type: ulong 218 simple: uint64_t 219 summary: 64 bit unsigned integer 220 description: 221 A 64 bit unsigned integer type. 222 end: 223 224 type: size_t 225 size: 64 226 simple: uint64_t 227 summary: Unsigned size type 228 description: 229 Unsigned size type. The number of bits depend on the compilation flags. 230 end: 231 232 type: size_t 233 size: 32 234 simple: uint32_t 235 end: 236 237 type: ssize_t 238 size: 64 239 simple: int64_t 240 summary: Signed size type 241 description: 242 Signed size type. The number of bits depend on the compilation flags. 243 end: 244 245 type: ssize_t 246 size: 32 247 simple: int32_t 248 end: 249 250 type: float2 251 simple: float 252 attrib: ext_vector_type(2) 253 summary: Two 32 bit floats 254 description: 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. 260 end: 261 262 type: float3 263 simple: float 264 attrib: ext_vector_type(3) 265 summary: Three 32 bit floats 266 description: 267 A vector of three floats. These three floats are packed into a single 128 bit field 268 with a 128 bit alignment. 269 end: 270 271 type: float4 272 simple: float 273 attrib: ext_vector_type(4) 274 summary: Four 32 bit floats 275 description: 276 A vector of four floats type. These four floats are packed into a single 128 bit field 277 with a 128 bit alignment. 278 end: 279 280 281 type: double2 282 simple: double 283 attrib: ext_vector_type(2) 284 summary: Two 64 bit floats 285 description: 286 A vector of two doubles. These two double fields packed into a single 128 bit field 287 with a 128 bit alignment. 288 end: 289 290 type: double3 291 simple: double 292 attrib: ext_vector_type(3) 293 summary: Three 64 bit floats 294 description: 295 A vector of three doubles. These three double fields packed into a single 256 bit field 296 with a 256 bit alignment. 297 end: 298 299 type: double4 300 simple: double 301 attrib: ext_vector_type(4) 302 summary: Four 64 bit floats 303 description: 304 A vector of four doubles. These four double fields packed into a single 256 bit field 305 with a 256 bit alignment. 306 end: 307 308 309 type: uchar2 310 simple: uchar 311 attrib: ext_vector_type(2) 312 summary: Two 8 bit unsigned integers 313 description: 314 A vector of two uchars. These two uchar fields packed into a single 16 bit field 315 with a 16 bit alignment. 316 end: 317 318 type: uchar3 319 simple: uchar 320 attrib: ext_vector_type(3) 321 summary: Three 8 bit unsigned integers 322 description: 323 A vector of three uchars. These three uchar fields packed into a single 32 bit field 324 with a 32 bit alignment. 325 end: 326 327 type: uchar4 328 simple: uchar 329 attrib: ext_vector_type(4) 330 summary: Four 8 bit unsigned integers 331 description: 332 A vector of four uchars. These four uchar fields packed into a single 32 bit field 333 with a 32 bit alignment. 334 end: 335 336 337 type: ushort2 338 simple: ushort 339 attrib: ext_vector_type(2) 340 summary: Two 16 bit unsigned integers 341 description: 342 A vector of two ushorts. These two ushort fields packed into a single 32 bit field 343 with a 32 bit alignment. 344 end: 345 346 type: ushort3 347 simple: ushort 348 attrib: ext_vector_type(3) 349 summary: Three 16 bit unsigned integers 350 description: 351 A vector of three ushorts. These three ushort fields packed into a single 64 bit field 352 with a 64 bit alignment. 353 end: 354 355 type: ushort4 356 simple: ushort 357 attrib: ext_vector_type(4) 358 summary: Four 16 bit unsigned integers 359 description: 360 A vector of four ushorts. These four ushort fields packed into a single 64 bit field 361 with a 64 bit alignment. 362 end: 363 364 365 type: uint2 366 simple: uint 367 attrib: ext_vector_type(2) 368 summary: Two 32 bit unsigned integers 369 description: 370 A vector of two uints. These two uints are packed into a single 64 bit field 371 with a 64 bit alignment. 372 end: 373 374 type: uint3 375 simple: uint 376 attrib: ext_vector_type(3) 377 summary: Three 32 bit unsigned integers 378 description: 379 A vector of three uints. These three uints are packed into a single 128 bit field 380 with a 128 bit alignment. 381 end: 382 383 type: uint4 384 simple: uint 385 attrib: ext_vector_type(4) 386 summary: Four 32 bit unsigned integers 387 description: 388 A vector of four uints. These four uints are packed into a single 128 bit field 389 with a 128 bit alignment. 390 end: 391 392 393 type: ulong2 394 simple: ulong 395 attrib: ext_vector_type(2) 396 summary: Two 64 bit unsigned integers 397 description: 398 A vector of two ulongs. These two ulongs are packed into a single 128 bit field 399 with a 128 bit alignment. 400 end: 401 402 type: ulong3 403 simple: ulong 404 attrib: ext_vector_type(3) 405 summary: Three 64 bit unsigned integers 406 description: 407 A vector of three ulongs. These three ulong fields packed into a single 256 bit field 408 with a 256 bit alignment. 409 end: 410 411 type: ulong4 412 simple: ulong 413 attrib: ext_vector_type(4) 414 summary: Four 64 bit unsigned integers 415 description: 416 A vector of four ulongs. These four ulong fields packed into a single 256 bit field 417 with a 256 bit alignment. 418 end: 419 420 421 type: char2 422 simple: char 423 attrib: ext_vector_type(2) 424 summary: Two 8 bit signed integers 425 description: 426 A vector of two chars. These two chars are packed into a single 16 bit field 427 with a 16 bit alignment. 428 end: 429 430 type: char3 431 simple: char 432 attrib: ext_vector_type(3) 433 summary: Three 8 bit signed integers 434 description: 435 A vector of three chars. These three chars are packed into a single 32 bit field 436 with a 32 bit alignment. 437 end: 438 439 type: char4 440 simple: char 441 attrib: ext_vector_type(4) 442 summary: Four 8 bit signed integers 443 description: 444 A vector of four chars. These four chars are packed into a single 32 bit field 445 with a 32 bit alignment. 446 end: 447 448 449 type: short2 450 simple: short 451 attrib: ext_vector_type(2) 452 summary: Two 16 bit signed integers 453 description: 454 A vector of two shorts. These two shorts are packed into a single 32 bit field 455 with a 32 bit alignment. 456 end: 457 458 type: short3 459 simple: short 460 attrib: ext_vector_type(3) 461 summary: Three 16 bit signed integers 462 description: 463 A vector of three shorts. These three short fields packed into a single 64 bit field 464 with a 64 bit alignment. 465 end: 466 467 type: short4 468 simple: short 469 attrib: ext_vector_type(4) 470 summary: Four 16 bit signed integers 471 description: 472 A vector of four shorts. These four short fields packed into a single 64 bit field 473 with a 64 bit alignment. 474 end: 475 476 477 type: int2 478 simple: int 479 attrib: ext_vector_type(2) 480 summary: Two 32 bit signed integers 481 description: 482 A vector of two ints. These two ints are packed into a single 64 bit field 483 with a 64 bit alignment. 484 end: 485 486 type: int3 487 simple: int 488 attrib: ext_vector_type(3) 489 summary: Three 32 bit signed integers 490 description: 491 A vector of three ints. These three ints are packed into a single 128 bit field 492 with a 128 bit alignment. 493 end: 494 495 type: int4 496 simple: int 497 attrib: ext_vector_type(4) 498 summary: Four 32 bit signed integers 499 description: 500 A vector of four ints. These two fours are packed into a single 128 bit field 501 with a 128 bit alignment. 502 end: 503 504 505 type: long2 506 simple: long 507 attrib: ext_vector_type(2) 508 summary: Two 64 bit signed integers 509 description: 510 A vector of two longs. These two longs are packed into a single 128 bit field 511 with a 128 bit alignment. 512 end: 513 514 type: long3 515 simple: long 516 attrib: ext_vector_type(3) 517 summary: Three 64 bit signed integers 518 description: 519 A vector of three longs. These three longs are packed into a single 256 bit field 520 with a 256 bit alignment. 521 end: 522 523 type: long4 524 simple: long 525 attrib: ext_vector_type(4) 526 summary: Four 64 bit signed integers 527 description: 528 A vector of four longs. These four longs are packed into a single 256 bit field 529 with a 256 bit alignment. 530 end: 531 532 533 type: rs_matrix2x2 534 struct: 535 field: float m[4] 536 summary: 2x2 matrix of 32 bit floats 537 description: 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>. 542 end: 543 544 type: rs_matrix3x3 545 struct: 546 field: float m[9] 547 summary: 3x3 matrix of 32 bit floats 548 description: 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>. 553 end: 554 555 type: rs_matrix4x4 556 struct: 557 field: float m[16] 558 summary: 4x4 matrix of 32 bit floats 559 description: 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>. 564 end: 565 566 567 type: rs_quaternion 568 simple: float4 569 summary: Quaternion 570 description: 571 A square 4x4 matrix of floats that represents a quaternion. 572 573 See <a href='rs_quaternion.html'>Quaternion Functions</a>. 574 end: 575