1 /* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (c) 2011 VMware, Inc. 5 * Copyright (c) 2014 Intel Corporation. 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a 8 * copy of this software and associated documentation files (the "Software"), 9 * to deal in the Software without restriction, including without limitation 10 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 * and/or sell copies of the Software, and to permit persons to whom the 12 * Software is furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included 15 * in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 27 /** 28 * Color, depth, stencil packing functions. 29 * Used to pack basic color, depth and stencil formats to specific 30 * hardware formats. 31 * 32 * There are both per-pixel and per-row packing functions: 33 * - The former will be used by swrast to write values to the color, depth, 34 * stencil buffers when drawing points, lines and masked spans. 35 * - The later will be used for image-oriented functions like glDrawPixels, 36 * glAccum, and glTexImage. 37 */ 38 39 #include <stdint.h> 40 41 #include "format_pack.h" 42 #include "format_utils.h" 43 #include "macros.h" 44 #include "util/format_rgb9e5.h" 45 #include "util/format_r11g11b10f.h" 46 #include "util/format_srgb.h" 47 48 #define UNPACK(SRC, OFFSET, BITS) (((SRC) >> (OFFSET)) & MAX_UINT(BITS)) 49 #define PACK(SRC, OFFSET, BITS) (((SRC) & MAX_UINT(BITS)) << (OFFSET)) 50 51 52 53 /* ubyte packing functions */ 54 55 56 static inline void 57 pack_ubyte_a8b8g8r8_unorm(const GLubyte src[4], void *dst) 58 { 59 60 61 uint8_t a = 62 _mesa_unorm_to_unorm(src[3], 8, 8); 63 64 65 uint8_t b = 66 _mesa_unorm_to_unorm(src[2], 8, 8); 67 68 69 uint8_t g = 70 _mesa_unorm_to_unorm(src[1], 8, 8); 71 72 73 uint8_t r = 74 _mesa_unorm_to_unorm(src[0], 8, 8); 75 76 uint32_t d = 0; 77 d |= PACK(a, 0, 8); 78 d |= PACK(b, 8, 8); 79 d |= PACK(g, 16, 8); 80 d |= PACK(r, 24, 8); 81 (*(uint32_t *)dst) = d; 82 } 83 84 static inline void 85 pack_ubyte_x8b8g8r8_unorm(const GLubyte src[4], void *dst) 86 { 87 88 89 90 uint8_t b = 91 _mesa_unorm_to_unorm(src[2], 8, 8); 92 93 94 uint8_t g = 95 _mesa_unorm_to_unorm(src[1], 8, 8); 96 97 98 uint8_t r = 99 _mesa_unorm_to_unorm(src[0], 8, 8); 100 101 uint32_t d = 0; 102 d |= PACK(b, 8, 8); 103 d |= PACK(g, 16, 8); 104 d |= PACK(r, 24, 8); 105 (*(uint32_t *)dst) = d; 106 } 107 108 static inline void 109 pack_ubyte_r8g8b8a8_unorm(const GLubyte src[4], void *dst) 110 { 111 112 113 uint8_t r = 114 _mesa_unorm_to_unorm(src[0], 8, 8); 115 116 117 uint8_t g = 118 _mesa_unorm_to_unorm(src[1], 8, 8); 119 120 121 uint8_t b = 122 _mesa_unorm_to_unorm(src[2], 8, 8); 123 124 125 uint8_t a = 126 _mesa_unorm_to_unorm(src[3], 8, 8); 127 128 uint32_t d = 0; 129 d |= PACK(r, 0, 8); 130 d |= PACK(g, 8, 8); 131 d |= PACK(b, 16, 8); 132 d |= PACK(a, 24, 8); 133 (*(uint32_t *)dst) = d; 134 } 135 136 static inline void 137 pack_ubyte_r8g8b8x8_unorm(const GLubyte src[4], void *dst) 138 { 139 140 141 uint8_t r = 142 _mesa_unorm_to_unorm(src[0], 8, 8); 143 144 145 uint8_t g = 146 _mesa_unorm_to_unorm(src[1], 8, 8); 147 148 149 uint8_t b = 150 _mesa_unorm_to_unorm(src[2], 8, 8); 151 152 153 uint32_t d = 0; 154 d |= PACK(r, 0, 8); 155 d |= PACK(g, 8, 8); 156 d |= PACK(b, 16, 8); 157 (*(uint32_t *)dst) = d; 158 } 159 160 static inline void 161 pack_ubyte_b8g8r8a8_unorm(const GLubyte src[4], void *dst) 162 { 163 164 165 uint8_t b = 166 _mesa_unorm_to_unorm(src[2], 8, 8); 167 168 169 uint8_t g = 170 _mesa_unorm_to_unorm(src[1], 8, 8); 171 172 173 uint8_t r = 174 _mesa_unorm_to_unorm(src[0], 8, 8); 175 176 177 uint8_t a = 178 _mesa_unorm_to_unorm(src[3], 8, 8); 179 180 uint32_t d = 0; 181 d |= PACK(b, 0, 8); 182 d |= PACK(g, 8, 8); 183 d |= PACK(r, 16, 8); 184 d |= PACK(a, 24, 8); 185 (*(uint32_t *)dst) = d; 186 } 187 188 static inline void 189 pack_ubyte_b8g8r8x8_unorm(const GLubyte src[4], void *dst) 190 { 191 192 193 uint8_t b = 194 _mesa_unorm_to_unorm(src[2], 8, 8); 195 196 197 uint8_t g = 198 _mesa_unorm_to_unorm(src[1], 8, 8); 199 200 201 uint8_t r = 202 _mesa_unorm_to_unorm(src[0], 8, 8); 203 204 205 uint32_t d = 0; 206 d |= PACK(b, 0, 8); 207 d |= PACK(g, 8, 8); 208 d |= PACK(r, 16, 8); 209 (*(uint32_t *)dst) = d; 210 } 211 212 static inline void 213 pack_ubyte_a8r8g8b8_unorm(const GLubyte src[4], void *dst) 214 { 215 216 217 uint8_t a = 218 _mesa_unorm_to_unorm(src[3], 8, 8); 219 220 221 uint8_t r = 222 _mesa_unorm_to_unorm(src[0], 8, 8); 223 224 225 uint8_t g = 226 _mesa_unorm_to_unorm(src[1], 8, 8); 227 228 229 uint8_t b = 230 _mesa_unorm_to_unorm(src[2], 8, 8); 231 232 uint32_t d = 0; 233 d |= PACK(a, 0, 8); 234 d |= PACK(r, 8, 8); 235 d |= PACK(g, 16, 8); 236 d |= PACK(b, 24, 8); 237 (*(uint32_t *)dst) = d; 238 } 239 240 static inline void 241 pack_ubyte_x8r8g8b8_unorm(const GLubyte src[4], void *dst) 242 { 243 244 245 246 uint8_t r = 247 _mesa_unorm_to_unorm(src[0], 8, 8); 248 249 250 uint8_t g = 251 _mesa_unorm_to_unorm(src[1], 8, 8); 252 253 254 uint8_t b = 255 _mesa_unorm_to_unorm(src[2], 8, 8); 256 257 uint32_t d = 0; 258 d |= PACK(r, 8, 8); 259 d |= PACK(g, 16, 8); 260 d |= PACK(b, 24, 8); 261 (*(uint32_t *)dst) = d; 262 } 263 264 static inline void 265 pack_ubyte_l16a16_unorm(const GLubyte src[4], void *dst) 266 { 267 268 269 uint16_t l = 270 _mesa_unorm_to_unorm(src[0], 8, 16); 271 272 273 uint16_t a = 274 _mesa_unorm_to_unorm(src[3], 8, 16); 275 276 uint32_t d = 0; 277 d |= PACK(l, 0, 16); 278 d |= PACK(a, 16, 16); 279 (*(uint32_t *)dst) = d; 280 } 281 282 static inline void 283 pack_ubyte_a16l16_unorm(const GLubyte src[4], void *dst) 284 { 285 286 287 uint16_t a = 288 _mesa_unorm_to_unorm(src[3], 8, 16); 289 290 291 uint16_t l = 292 _mesa_unorm_to_unorm(src[0], 8, 16); 293 294 uint32_t d = 0; 295 d |= PACK(a, 0, 16); 296 d |= PACK(l, 16, 16); 297 (*(uint32_t *)dst) = d; 298 } 299 300 static inline void 301 pack_ubyte_b5g6r5_unorm(const GLubyte src[4], void *dst) 302 { 303 304 305 uint8_t b = 306 _mesa_unorm_to_unorm(src[2], 8, 5); 307 308 309 uint8_t g = 310 _mesa_unorm_to_unorm(src[1], 8, 6); 311 312 313 uint8_t r = 314 _mesa_unorm_to_unorm(src[0], 8, 5); 315 316 uint16_t d = 0; 317 d |= PACK(b, 0, 5); 318 d |= PACK(g, 5, 6); 319 d |= PACK(r, 11, 5); 320 (*(uint16_t *)dst) = d; 321 } 322 323 static inline void 324 pack_ubyte_r5g6b5_unorm(const GLubyte src[4], void *dst) 325 { 326 327 328 uint8_t r = 329 _mesa_unorm_to_unorm(src[0], 8, 5); 330 331 332 uint8_t g = 333 _mesa_unorm_to_unorm(src[1], 8, 6); 334 335 336 uint8_t b = 337 _mesa_unorm_to_unorm(src[2], 8, 5); 338 339 uint16_t d = 0; 340 d |= PACK(r, 0, 5); 341 d |= PACK(g, 5, 6); 342 d |= PACK(b, 11, 5); 343 (*(uint16_t *)dst) = d; 344 } 345 346 static inline void 347 pack_ubyte_b4g4r4a4_unorm(const GLubyte src[4], void *dst) 348 { 349 350 351 uint8_t b = 352 _mesa_unorm_to_unorm(src[2], 8, 4); 353 354 355 uint8_t g = 356 _mesa_unorm_to_unorm(src[1], 8, 4); 357 358 359 uint8_t r = 360 _mesa_unorm_to_unorm(src[0], 8, 4); 361 362 363 uint8_t a = 364 _mesa_unorm_to_unorm(src[3], 8, 4); 365 366 uint16_t d = 0; 367 d |= PACK(b, 0, 4); 368 d |= PACK(g, 4, 4); 369 d |= PACK(r, 8, 4); 370 d |= PACK(a, 12, 4); 371 (*(uint16_t *)dst) = d; 372 } 373 374 static inline void 375 pack_ubyte_b4g4r4x4_unorm(const GLubyte src[4], void *dst) 376 { 377 378 379 uint8_t b = 380 _mesa_unorm_to_unorm(src[2], 8, 4); 381 382 383 uint8_t g = 384 _mesa_unorm_to_unorm(src[1], 8, 4); 385 386 387 uint8_t r = 388 _mesa_unorm_to_unorm(src[0], 8, 4); 389 390 391 uint16_t d = 0; 392 d |= PACK(b, 0, 4); 393 d |= PACK(g, 4, 4); 394 d |= PACK(r, 8, 4); 395 (*(uint16_t *)dst) = d; 396 } 397 398 static inline void 399 pack_ubyte_a4r4g4b4_unorm(const GLubyte src[4], void *dst) 400 { 401 402 403 uint8_t a = 404 _mesa_unorm_to_unorm(src[3], 8, 4); 405 406 407 uint8_t r = 408 _mesa_unorm_to_unorm(src[0], 8, 4); 409 410 411 uint8_t g = 412 _mesa_unorm_to_unorm(src[1], 8, 4); 413 414 415 uint8_t b = 416 _mesa_unorm_to_unorm(src[2], 8, 4); 417 418 uint16_t d = 0; 419 d |= PACK(a, 0, 4); 420 d |= PACK(r, 4, 4); 421 d |= PACK(g, 8, 4); 422 d |= PACK(b, 12, 4); 423 (*(uint16_t *)dst) = d; 424 } 425 426 static inline void 427 pack_ubyte_a1b5g5r5_unorm(const GLubyte src[4], void *dst) 428 { 429 430 431 uint8_t a = 432 _mesa_unorm_to_unorm(src[3], 8, 1); 433 434 435 uint8_t b = 436 _mesa_unorm_to_unorm(src[2], 8, 5); 437 438 439 uint8_t g = 440 _mesa_unorm_to_unorm(src[1], 8, 5); 441 442 443 uint8_t r = 444 _mesa_unorm_to_unorm(src[0], 8, 5); 445 446 uint16_t d = 0; 447 d |= PACK(a, 0, 1); 448 d |= PACK(b, 1, 5); 449 d |= PACK(g, 6, 5); 450 d |= PACK(r, 11, 5); 451 (*(uint16_t *)dst) = d; 452 } 453 454 static inline void 455 pack_ubyte_b5g5r5a1_unorm(const GLubyte src[4], void *dst) 456 { 457 458 459 uint8_t b = 460 _mesa_unorm_to_unorm(src[2], 8, 5); 461 462 463 uint8_t g = 464 _mesa_unorm_to_unorm(src[1], 8, 5); 465 466 467 uint8_t r = 468 _mesa_unorm_to_unorm(src[0], 8, 5); 469 470 471 uint8_t a = 472 _mesa_unorm_to_unorm(src[3], 8, 1); 473 474 uint16_t d = 0; 475 d |= PACK(b, 0, 5); 476 d |= PACK(g, 5, 5); 477 d |= PACK(r, 10, 5); 478 d |= PACK(a, 15, 1); 479 (*(uint16_t *)dst) = d; 480 } 481 482 static inline void 483 pack_ubyte_b5g5r5x1_unorm(const GLubyte src[4], void *dst) 484 { 485 486 487 uint8_t b = 488 _mesa_unorm_to_unorm(src[2], 8, 5); 489 490 491 uint8_t g = 492 _mesa_unorm_to_unorm(src[1], 8, 5); 493 494 495 uint8_t r = 496 _mesa_unorm_to_unorm(src[0], 8, 5); 497 498 499 uint16_t d = 0; 500 d |= PACK(b, 0, 5); 501 d |= PACK(g, 5, 5); 502 d |= PACK(r, 10, 5); 503 (*(uint16_t *)dst) = d; 504 } 505 506 static inline void 507 pack_ubyte_a1r5g5b5_unorm(const GLubyte src[4], void *dst) 508 { 509 510 511 uint8_t a = 512 _mesa_unorm_to_unorm(src[3], 8, 1); 513 514 515 uint8_t r = 516 _mesa_unorm_to_unorm(src[0], 8, 5); 517 518 519 uint8_t g = 520 _mesa_unorm_to_unorm(src[1], 8, 5); 521 522 523 uint8_t b = 524 _mesa_unorm_to_unorm(src[2], 8, 5); 525 526 uint16_t d = 0; 527 d |= PACK(a, 0, 1); 528 d |= PACK(r, 1, 5); 529 d |= PACK(g, 6, 5); 530 d |= PACK(b, 11, 5); 531 (*(uint16_t *)dst) = d; 532 } 533 534 static inline void 535 pack_ubyte_l8a8_unorm(const GLubyte src[4], void *dst) 536 { 537 538 539 uint8_t l = 540 _mesa_unorm_to_unorm(src[0], 8, 8); 541 542 543 uint8_t a = 544 _mesa_unorm_to_unorm(src[3], 8, 8); 545 546 uint16_t d = 0; 547 d |= PACK(l, 0, 8); 548 d |= PACK(a, 8, 8); 549 (*(uint16_t *)dst) = d; 550 } 551 552 static inline void 553 pack_ubyte_a8l8_unorm(const GLubyte src[4], void *dst) 554 { 555 556 557 uint8_t a = 558 _mesa_unorm_to_unorm(src[3], 8, 8); 559 560 561 uint8_t l = 562 _mesa_unorm_to_unorm(src[0], 8, 8); 563 564 uint16_t d = 0; 565 d |= PACK(a, 0, 8); 566 d |= PACK(l, 8, 8); 567 (*(uint16_t *)dst) = d; 568 } 569 570 static inline void 571 pack_ubyte_r8g8_unorm(const GLubyte src[4], void *dst) 572 { 573 574 575 uint8_t r = 576 _mesa_unorm_to_unorm(src[0], 8, 8); 577 578 579 uint8_t g = 580 _mesa_unorm_to_unorm(src[1], 8, 8); 581 582 uint16_t d = 0; 583 d |= PACK(r, 0, 8); 584 d |= PACK(g, 8, 8); 585 (*(uint16_t *)dst) = d; 586 } 587 588 static inline void 589 pack_ubyte_g8r8_unorm(const GLubyte src[4], void *dst) 590 { 591 592 593 uint8_t g = 594 _mesa_unorm_to_unorm(src[1], 8, 8); 595 596 597 uint8_t r = 598 _mesa_unorm_to_unorm(src[0], 8, 8); 599 600 uint16_t d = 0; 601 d |= PACK(g, 0, 8); 602 d |= PACK(r, 8, 8); 603 (*(uint16_t *)dst) = d; 604 } 605 606 static inline void 607 pack_ubyte_l4a4_unorm(const GLubyte src[4], void *dst) 608 { 609 610 611 uint8_t l = 612 _mesa_unorm_to_unorm(src[0], 8, 4); 613 614 615 uint8_t a = 616 _mesa_unorm_to_unorm(src[3], 8, 4); 617 618 uint8_t d = 0; 619 d |= PACK(l, 0, 4); 620 d |= PACK(a, 4, 4); 621 (*(uint8_t *)dst) = d; 622 } 623 624 static inline void 625 pack_ubyte_b2g3r3_unorm(const GLubyte src[4], void *dst) 626 { 627 628 629 uint8_t b = 630 _mesa_unorm_to_unorm(src[2], 8, 2); 631 632 633 uint8_t g = 634 _mesa_unorm_to_unorm(src[1], 8, 3); 635 636 637 uint8_t r = 638 _mesa_unorm_to_unorm(src[0], 8, 3); 639 640 uint8_t d = 0; 641 d |= PACK(b, 0, 2); 642 d |= PACK(g, 2, 3); 643 d |= PACK(r, 5, 3); 644 (*(uint8_t *)dst) = d; 645 } 646 647 static inline void 648 pack_ubyte_r16g16_unorm(const GLubyte src[4], void *dst) 649 { 650 651 652 uint16_t r = 653 _mesa_unorm_to_unorm(src[0], 8, 16); 654 655 656 uint16_t g = 657 _mesa_unorm_to_unorm(src[1], 8, 16); 658 659 uint32_t d = 0; 660 d |= PACK(r, 0, 16); 661 d |= PACK(g, 16, 16); 662 (*(uint32_t *)dst) = d; 663 } 664 665 static inline void 666 pack_ubyte_g16r16_unorm(const GLubyte src[4], void *dst) 667 { 668 669 670 uint16_t g = 671 _mesa_unorm_to_unorm(src[1], 8, 16); 672 673 674 uint16_t r = 675 _mesa_unorm_to_unorm(src[0], 8, 16); 676 677 uint32_t d = 0; 678 d |= PACK(g, 0, 16); 679 d |= PACK(r, 16, 16); 680 (*(uint32_t *)dst) = d; 681 } 682 683 static inline void 684 pack_ubyte_b10g10r10a2_unorm(const GLubyte src[4], void *dst) 685 { 686 687 688 uint16_t b = 689 _mesa_unorm_to_unorm(src[2], 8, 10); 690 691 692 uint16_t g = 693 _mesa_unorm_to_unorm(src[1], 8, 10); 694 695 696 uint16_t r = 697 _mesa_unorm_to_unorm(src[0], 8, 10); 698 699 700 uint8_t a = 701 _mesa_unorm_to_unorm(src[3], 8, 2); 702 703 uint32_t d = 0; 704 d |= PACK(b, 0, 10); 705 d |= PACK(g, 10, 10); 706 d |= PACK(r, 20, 10); 707 d |= PACK(a, 30, 2); 708 (*(uint32_t *)dst) = d; 709 } 710 711 static inline void 712 pack_ubyte_b10g10r10x2_unorm(const GLubyte src[4], void *dst) 713 { 714 715 716 uint16_t b = 717 _mesa_unorm_to_unorm(src[2], 8, 10); 718 719 720 uint16_t g = 721 _mesa_unorm_to_unorm(src[1], 8, 10); 722 723 724 uint16_t r = 725 _mesa_unorm_to_unorm(src[0], 8, 10); 726 727 728 uint32_t d = 0; 729 d |= PACK(b, 0, 10); 730 d |= PACK(g, 10, 10); 731 d |= PACK(r, 20, 10); 732 (*(uint32_t *)dst) = d; 733 } 734 735 static inline void 736 pack_ubyte_r10g10b10a2_unorm(const GLubyte src[4], void *dst) 737 { 738 739 740 uint16_t r = 741 _mesa_unorm_to_unorm(src[0], 8, 10); 742 743 744 uint16_t g = 745 _mesa_unorm_to_unorm(src[1], 8, 10); 746 747 748 uint16_t b = 749 _mesa_unorm_to_unorm(src[2], 8, 10); 750 751 752 uint8_t a = 753 _mesa_unorm_to_unorm(src[3], 8, 2); 754 755 uint32_t d = 0; 756 d |= PACK(r, 0, 10); 757 d |= PACK(g, 10, 10); 758 d |= PACK(b, 20, 10); 759 d |= PACK(a, 30, 2); 760 (*(uint32_t *)dst) = d; 761 } 762 763 static inline void 764 pack_ubyte_r10g10b10x2_unorm(const GLubyte src[4], void *dst) 765 { 766 767 768 uint16_t r = 769 _mesa_unorm_to_unorm(src[0], 8, 10); 770 771 772 uint16_t g = 773 _mesa_unorm_to_unorm(src[1], 8, 10); 774 775 776 uint16_t b = 777 _mesa_unorm_to_unorm(src[2], 8, 10); 778 779 780 uint32_t d = 0; 781 d |= PACK(r, 0, 10); 782 d |= PACK(g, 10, 10); 783 d |= PACK(b, 20, 10); 784 (*(uint32_t *)dst) = d; 785 } 786 787 static inline void 788 pack_ubyte_r3g3b2_unorm(const GLubyte src[4], void *dst) 789 { 790 791 792 uint8_t r = 793 _mesa_unorm_to_unorm(src[0], 8, 3); 794 795 796 uint8_t g = 797 _mesa_unorm_to_unorm(src[1], 8, 3); 798 799 800 uint8_t b = 801 _mesa_unorm_to_unorm(src[2], 8, 2); 802 803 uint8_t d = 0; 804 d |= PACK(r, 0, 3); 805 d |= PACK(g, 3, 3); 806 d |= PACK(b, 6, 2); 807 (*(uint8_t *)dst) = d; 808 } 809 810 static inline void 811 pack_ubyte_a4b4g4r4_unorm(const GLubyte src[4], void *dst) 812 { 813 814 815 uint8_t a = 816 _mesa_unorm_to_unorm(src[3], 8, 4); 817 818 819 uint8_t b = 820 _mesa_unorm_to_unorm(src[2], 8, 4); 821 822 823 uint8_t g = 824 _mesa_unorm_to_unorm(src[1], 8, 4); 825 826 827 uint8_t r = 828 _mesa_unorm_to_unorm(src[0], 8, 4); 829 830 uint16_t d = 0; 831 d |= PACK(a, 0, 4); 832 d |= PACK(b, 4, 4); 833 d |= PACK(g, 8, 4); 834 d |= PACK(r, 12, 4); 835 (*(uint16_t *)dst) = d; 836 } 837 838 static inline void 839 pack_ubyte_r4g4b4a4_unorm(const GLubyte src[4], void *dst) 840 { 841 842 843 uint8_t r = 844 _mesa_unorm_to_unorm(src[0], 8, 4); 845 846 847 uint8_t g = 848 _mesa_unorm_to_unorm(src[1], 8, 4); 849 850 851 uint8_t b = 852 _mesa_unorm_to_unorm(src[2], 8, 4); 853 854 855 uint8_t a = 856 _mesa_unorm_to_unorm(src[3], 8, 4); 857 858 uint16_t d = 0; 859 d |= PACK(r, 0, 4); 860 d |= PACK(g, 4, 4); 861 d |= PACK(b, 8, 4); 862 d |= PACK(a, 12, 4); 863 (*(uint16_t *)dst) = d; 864 } 865 866 static inline void 867 pack_ubyte_r5g5b5a1_unorm(const GLubyte src[4], void *dst) 868 { 869 870 871 uint8_t r = 872 _mesa_unorm_to_unorm(src[0], 8, 5); 873 874 875 uint8_t g = 876 _mesa_unorm_to_unorm(src[1], 8, 5); 877 878 879 uint8_t b = 880 _mesa_unorm_to_unorm(src[2], 8, 5); 881 882 883 uint8_t a = 884 _mesa_unorm_to_unorm(src[3], 8, 1); 885 886 uint16_t d = 0; 887 d |= PACK(r, 0, 5); 888 d |= PACK(g, 5, 5); 889 d |= PACK(b, 10, 5); 890 d |= PACK(a, 15, 1); 891 (*(uint16_t *)dst) = d; 892 } 893 894 static inline void 895 pack_ubyte_a2b10g10r10_unorm(const GLubyte src[4], void *dst) 896 { 897 898 899 uint8_t a = 900 _mesa_unorm_to_unorm(src[3], 8, 2); 901 902 903 uint16_t b = 904 _mesa_unorm_to_unorm(src[2], 8, 10); 905 906 907 uint16_t g = 908 _mesa_unorm_to_unorm(src[1], 8, 10); 909 910 911 uint16_t r = 912 _mesa_unorm_to_unorm(src[0], 8, 10); 913 914 uint32_t d = 0; 915 d |= PACK(a, 0, 2); 916 d |= PACK(b, 2, 10); 917 d |= PACK(g, 12, 10); 918 d |= PACK(r, 22, 10); 919 (*(uint32_t *)dst) = d; 920 } 921 922 static inline void 923 pack_ubyte_a2r10g10b10_unorm(const GLubyte src[4], void *dst) 924 { 925 926 927 uint8_t a = 928 _mesa_unorm_to_unorm(src[3], 8, 2); 929 930 931 uint16_t r = 932 _mesa_unorm_to_unorm(src[0], 8, 10); 933 934 935 uint16_t g = 936 _mesa_unorm_to_unorm(src[1], 8, 10); 937 938 939 uint16_t b = 940 _mesa_unorm_to_unorm(src[2], 8, 10); 941 942 uint32_t d = 0; 943 d |= PACK(a, 0, 2); 944 d |= PACK(r, 2, 10); 945 d |= PACK(g, 12, 10); 946 d |= PACK(b, 22, 10); 947 (*(uint32_t *)dst) = d; 948 } 949 950 static inline void 951 pack_ubyte_a_unorm8(const GLubyte src[4], void *dst) 952 { 953 954 955 uint8_t a = 956 _mesa_unorm_to_unorm(src[3], 8, 8); 957 958 uint8_t *d = (uint8_t *)dst; 959 d[0] = a; 960 } 961 962 static inline void 963 pack_ubyte_a_unorm16(const GLubyte src[4], void *dst) 964 { 965 966 967 uint16_t a = 968 _mesa_unorm_to_unorm(src[3], 8, 16); 969 970 uint16_t *d = (uint16_t *)dst; 971 d[0] = a; 972 } 973 974 static inline void 975 pack_ubyte_l_unorm8(const GLubyte src[4], void *dst) 976 { 977 978 979 uint8_t l = 980 _mesa_unorm_to_unorm(src[0], 8, 8); 981 982 uint8_t *d = (uint8_t *)dst; 983 d[0] = l; 984 } 985 986 static inline void 987 pack_ubyte_l_unorm16(const GLubyte src[4], void *dst) 988 { 989 990 991 uint16_t l = 992 _mesa_unorm_to_unorm(src[0], 8, 16); 993 994 uint16_t *d = (uint16_t *)dst; 995 d[0] = l; 996 } 997 998 static inline void 999 pack_ubyte_i_unorm8(const GLubyte src[4], void *dst) 1000 { 1001 1002 1003 uint8_t i = 1004 _mesa_unorm_to_unorm(src[0], 8, 8); 1005 1006 uint8_t *d = (uint8_t *)dst; 1007 d[0] = i; 1008 } 1009 1010 static inline void 1011 pack_ubyte_i_unorm16(const GLubyte src[4], void *dst) 1012 { 1013 1014 1015 uint16_t i = 1016 _mesa_unorm_to_unorm(src[0], 8, 16); 1017 1018 uint16_t *d = (uint16_t *)dst; 1019 d[0] = i; 1020 } 1021 1022 static inline void 1023 pack_ubyte_r_unorm8(const GLubyte src[4], void *dst) 1024 { 1025 1026 1027 uint8_t r = 1028 _mesa_unorm_to_unorm(src[0], 8, 8); 1029 1030 uint8_t *d = (uint8_t *)dst; 1031 d[0] = r; 1032 } 1033 1034 static inline void 1035 pack_ubyte_r_unorm16(const GLubyte src[4], void *dst) 1036 { 1037 1038 1039 uint16_t r = 1040 _mesa_unorm_to_unorm(src[0], 8, 16); 1041 1042 uint16_t *d = (uint16_t *)dst; 1043 d[0] = r; 1044 } 1045 1046 static inline void 1047 pack_ubyte_bgr_unorm8(const GLubyte src[4], void *dst) 1048 { 1049 1050 1051 uint8_t b = 1052 _mesa_unorm_to_unorm(src[2], 8, 8); 1053 1054 1055 uint8_t g = 1056 _mesa_unorm_to_unorm(src[1], 8, 8); 1057 1058 1059 uint8_t r = 1060 _mesa_unorm_to_unorm(src[0], 8, 8); 1061 1062 uint8_t *d = (uint8_t *)dst; 1063 d[0] = b; 1064 d[1] = g; 1065 d[2] = r; 1066 } 1067 1068 static inline void 1069 pack_ubyte_rgb_unorm8(const GLubyte src[4], void *dst) 1070 { 1071 1072 1073 uint8_t r = 1074 _mesa_unorm_to_unorm(src[0], 8, 8); 1075 1076 1077 uint8_t g = 1078 _mesa_unorm_to_unorm(src[1], 8, 8); 1079 1080 1081 uint8_t b = 1082 _mesa_unorm_to_unorm(src[2], 8, 8); 1083 1084 uint8_t *d = (uint8_t *)dst; 1085 d[0] = r; 1086 d[1] = g; 1087 d[2] = b; 1088 } 1089 1090 static inline void 1091 pack_ubyte_rgba_unorm16(const GLubyte src[4], void *dst) 1092 { 1093 1094 1095 uint16_t r = 1096 _mesa_unorm_to_unorm(src[0], 8, 16); 1097 1098 1099 uint16_t g = 1100 _mesa_unorm_to_unorm(src[1], 8, 16); 1101 1102 1103 uint16_t b = 1104 _mesa_unorm_to_unorm(src[2], 8, 16); 1105 1106 1107 uint16_t a = 1108 _mesa_unorm_to_unorm(src[3], 8, 16); 1109 1110 uint16_t *d = (uint16_t *)dst; 1111 d[0] = r; 1112 d[1] = g; 1113 d[2] = b; 1114 d[3] = a; 1115 } 1116 1117 static inline void 1118 pack_ubyte_rgbx_unorm16(const GLubyte src[4], void *dst) 1119 { 1120 1121 1122 uint16_t r = 1123 _mesa_unorm_to_unorm(src[0], 8, 16); 1124 1125 1126 uint16_t g = 1127 _mesa_unorm_to_unorm(src[1], 8, 16); 1128 1129 1130 uint16_t b = 1131 _mesa_unorm_to_unorm(src[2], 8, 16); 1132 1133 1134 uint16_t *d = (uint16_t *)dst; 1135 d[0] = r; 1136 d[1] = g; 1137 d[2] = b; 1138 } 1139 1140 static inline void 1141 pack_ubyte_a8b8g8r8_snorm(const GLubyte src[4], void *dst) 1142 { 1143 1144 1145 int8_t a = 1146 _mesa_unorm_to_snorm(src[3], 8, 8); 1147 1148 1149 int8_t b = 1150 _mesa_unorm_to_snorm(src[2], 8, 8); 1151 1152 1153 int8_t g = 1154 _mesa_unorm_to_snorm(src[1], 8, 8); 1155 1156 1157 int8_t r = 1158 _mesa_unorm_to_snorm(src[0], 8, 8); 1159 1160 uint32_t d = 0; 1161 d |= PACK(a, 0, 8); 1162 d |= PACK(b, 8, 8); 1163 d |= PACK(g, 16, 8); 1164 d |= PACK(r, 24, 8); 1165 (*(uint32_t *)dst) = d; 1166 } 1167 1168 static inline void 1169 pack_ubyte_x8b8g8r8_snorm(const GLubyte src[4], void *dst) 1170 { 1171 1172 1173 1174 int8_t b = 1175 _mesa_unorm_to_snorm(src[2], 8, 8); 1176 1177 1178 int8_t g = 1179 _mesa_unorm_to_snorm(src[1], 8, 8); 1180 1181 1182 int8_t r = 1183 _mesa_unorm_to_snorm(src[0], 8, 8); 1184 1185 uint32_t d = 0; 1186 d |= PACK(b, 8, 8); 1187 d |= PACK(g, 16, 8); 1188 d |= PACK(r, 24, 8); 1189 (*(uint32_t *)dst) = d; 1190 } 1191 1192 static inline void 1193 pack_ubyte_r8g8b8a8_snorm(const GLubyte src[4], void *dst) 1194 { 1195 1196 1197 int8_t r = 1198 _mesa_unorm_to_snorm(src[0], 8, 8); 1199 1200 1201 int8_t g = 1202 _mesa_unorm_to_snorm(src[1], 8, 8); 1203 1204 1205 int8_t b = 1206 _mesa_unorm_to_snorm(src[2], 8, 8); 1207 1208 1209 int8_t a = 1210 _mesa_unorm_to_snorm(src[3], 8, 8); 1211 1212 uint32_t d = 0; 1213 d |= PACK(r, 0, 8); 1214 d |= PACK(g, 8, 8); 1215 d |= PACK(b, 16, 8); 1216 d |= PACK(a, 24, 8); 1217 (*(uint32_t *)dst) = d; 1218 } 1219 1220 static inline void 1221 pack_ubyte_r8g8b8x8_snorm(const GLubyte src[4], void *dst) 1222 { 1223 1224 1225 int8_t r = 1226 _mesa_unorm_to_snorm(src[0], 8, 8); 1227 1228 1229 int8_t g = 1230 _mesa_unorm_to_snorm(src[1], 8, 8); 1231 1232 1233 int8_t b = 1234 _mesa_unorm_to_snorm(src[2], 8, 8); 1235 1236 1237 uint32_t d = 0; 1238 d |= PACK(r, 0, 8); 1239 d |= PACK(g, 8, 8); 1240 d |= PACK(b, 16, 8); 1241 (*(uint32_t *)dst) = d; 1242 } 1243 1244 static inline void 1245 pack_ubyte_r16g16_snorm(const GLubyte src[4], void *dst) 1246 { 1247 1248 1249 int16_t r = 1250 _mesa_unorm_to_snorm(src[0], 8, 16); 1251 1252 1253 int16_t g = 1254 _mesa_unorm_to_snorm(src[1], 8, 16); 1255 1256 uint32_t d = 0; 1257 d |= PACK(r, 0, 16); 1258 d |= PACK(g, 16, 16); 1259 (*(uint32_t *)dst) = d; 1260 } 1261 1262 static inline void 1263 pack_ubyte_g16r16_snorm(const GLubyte src[4], void *dst) 1264 { 1265 1266 1267 int16_t g = 1268 _mesa_unorm_to_snorm(src[1], 8, 16); 1269 1270 1271 int16_t r = 1272 _mesa_unorm_to_snorm(src[0], 8, 16); 1273 1274 uint32_t d = 0; 1275 d |= PACK(g, 0, 16); 1276 d |= PACK(r, 16, 16); 1277 (*(uint32_t *)dst) = d; 1278 } 1279 1280 static inline void 1281 pack_ubyte_r8g8_snorm(const GLubyte src[4], void *dst) 1282 { 1283 1284 1285 int8_t r = 1286 _mesa_unorm_to_snorm(src[0], 8, 8); 1287 1288 1289 int8_t g = 1290 _mesa_unorm_to_snorm(src[1], 8, 8); 1291 1292 uint16_t d = 0; 1293 d |= PACK(r, 0, 8); 1294 d |= PACK(g, 8, 8); 1295 (*(uint16_t *)dst) = d; 1296 } 1297 1298 static inline void 1299 pack_ubyte_g8r8_snorm(const GLubyte src[4], void *dst) 1300 { 1301 1302 1303 int8_t g = 1304 _mesa_unorm_to_snorm(src[1], 8, 8); 1305 1306 1307 int8_t r = 1308 _mesa_unorm_to_snorm(src[0], 8, 8); 1309 1310 uint16_t d = 0; 1311 d |= PACK(g, 0, 8); 1312 d |= PACK(r, 8, 8); 1313 (*(uint16_t *)dst) = d; 1314 } 1315 1316 static inline void 1317 pack_ubyte_l8a8_snorm(const GLubyte src[4], void *dst) 1318 { 1319 1320 1321 int8_t l = 1322 _mesa_unorm_to_snorm(src[0], 8, 8); 1323 1324 1325 int8_t a = 1326 _mesa_unorm_to_snorm(src[3], 8, 8); 1327 1328 uint16_t d = 0; 1329 d |= PACK(l, 0, 8); 1330 d |= PACK(a, 8, 8); 1331 (*(uint16_t *)dst) = d; 1332 } 1333 1334 static inline void 1335 pack_ubyte_a8l8_snorm(const GLubyte src[4], void *dst) 1336 { 1337 1338 1339 int8_t a = 1340 _mesa_unorm_to_snorm(src[3], 8, 8); 1341 1342 1343 int8_t l = 1344 _mesa_unorm_to_snorm(src[0], 8, 8); 1345 1346 uint16_t d = 0; 1347 d |= PACK(a, 0, 8); 1348 d |= PACK(l, 8, 8); 1349 (*(uint16_t *)dst) = d; 1350 } 1351 1352 static inline void 1353 pack_ubyte_a_snorm8(const GLubyte src[4], void *dst) 1354 { 1355 1356 1357 int8_t a = 1358 _mesa_unorm_to_snorm(src[3], 8, 8); 1359 1360 int8_t *d = (int8_t *)dst; 1361 d[0] = a; 1362 } 1363 1364 static inline void 1365 pack_ubyte_a_snorm16(const GLubyte src[4], void *dst) 1366 { 1367 1368 1369 int16_t a = 1370 _mesa_unorm_to_snorm(src[3], 8, 16); 1371 1372 int16_t *d = (int16_t *)dst; 1373 d[0] = a; 1374 } 1375 1376 static inline void 1377 pack_ubyte_l_snorm8(const GLubyte src[4], void *dst) 1378 { 1379 1380 1381 int8_t l = 1382 _mesa_unorm_to_snorm(src[0], 8, 8); 1383 1384 int8_t *d = (int8_t *)dst; 1385 d[0] = l; 1386 } 1387 1388 static inline void 1389 pack_ubyte_l_snorm16(const GLubyte src[4], void *dst) 1390 { 1391 1392 1393 int16_t l = 1394 _mesa_unorm_to_snorm(src[0], 8, 16); 1395 1396 int16_t *d = (int16_t *)dst; 1397 d[0] = l; 1398 } 1399 1400 static inline void 1401 pack_ubyte_i_snorm8(const GLubyte src[4], void *dst) 1402 { 1403 1404 1405 int8_t i = 1406 _mesa_unorm_to_snorm(src[0], 8, 8); 1407 1408 int8_t *d = (int8_t *)dst; 1409 d[0] = i; 1410 } 1411 1412 static inline void 1413 pack_ubyte_i_snorm16(const GLubyte src[4], void *dst) 1414 { 1415 1416 1417 int16_t i = 1418 _mesa_unorm_to_snorm(src[0], 8, 16); 1419 1420 int16_t *d = (int16_t *)dst; 1421 d[0] = i; 1422 } 1423 1424 static inline void 1425 pack_ubyte_r_snorm8(const GLubyte src[4], void *dst) 1426 { 1427 1428 1429 int8_t r = 1430 _mesa_unorm_to_snorm(src[0], 8, 8); 1431 1432 int8_t *d = (int8_t *)dst; 1433 d[0] = r; 1434 } 1435 1436 static inline void 1437 pack_ubyte_r_snorm16(const GLubyte src[4], void *dst) 1438 { 1439 1440 1441 int16_t r = 1442 _mesa_unorm_to_snorm(src[0], 8, 16); 1443 1444 int16_t *d = (int16_t *)dst; 1445 d[0] = r; 1446 } 1447 1448 static inline void 1449 pack_ubyte_la_snorm16(const GLubyte src[4], void *dst) 1450 { 1451 1452 1453 int16_t l = 1454 _mesa_unorm_to_snorm(src[0], 8, 16); 1455 1456 1457 int16_t a = 1458 _mesa_unorm_to_snorm(src[3], 8, 16); 1459 1460 int16_t *d = (int16_t *)dst; 1461 d[0] = l; 1462 d[1] = a; 1463 } 1464 1465 static inline void 1466 pack_ubyte_rgb_snorm16(const GLubyte src[4], void *dst) 1467 { 1468 1469 1470 int16_t r = 1471 _mesa_unorm_to_snorm(src[0], 8, 16); 1472 1473 1474 int16_t g = 1475 _mesa_unorm_to_snorm(src[1], 8, 16); 1476 1477 1478 int16_t b = 1479 _mesa_unorm_to_snorm(src[2], 8, 16); 1480 1481 int16_t *d = (int16_t *)dst; 1482 d[0] = r; 1483 d[1] = g; 1484 d[2] = b; 1485 } 1486 1487 static inline void 1488 pack_ubyte_rgba_snorm16(const GLubyte src[4], void *dst) 1489 { 1490 1491 1492 int16_t r = 1493 _mesa_unorm_to_snorm(src[0], 8, 16); 1494 1495 1496 int16_t g = 1497 _mesa_unorm_to_snorm(src[1], 8, 16); 1498 1499 1500 int16_t b = 1501 _mesa_unorm_to_snorm(src[2], 8, 16); 1502 1503 1504 int16_t a = 1505 _mesa_unorm_to_snorm(src[3], 8, 16); 1506 1507 int16_t *d = (int16_t *)dst; 1508 d[0] = r; 1509 d[1] = g; 1510 d[2] = b; 1511 d[3] = a; 1512 } 1513 1514 static inline void 1515 pack_ubyte_rgbx_snorm16(const GLubyte src[4], void *dst) 1516 { 1517 1518 1519 int16_t r = 1520 _mesa_unorm_to_snorm(src[0], 8, 16); 1521 1522 1523 int16_t g = 1524 _mesa_unorm_to_snorm(src[1], 8, 16); 1525 1526 1527 int16_t b = 1528 _mesa_unorm_to_snorm(src[2], 8, 16); 1529 1530 1531 int16_t *d = (int16_t *)dst; 1532 d[0] = r; 1533 d[1] = g; 1534 d[2] = b; 1535 } 1536 1537 static inline void 1538 pack_ubyte_a8b8g8r8_srgb(const GLubyte src[4], void *dst) 1539 { 1540 1541 1542 uint8_t a = 1543 _mesa_unorm_to_unorm(src[3], 8, 8); 1544 1545 1546 uint8_t b = 1547 1548 util_format_linear_to_srgb_8unorm(src[2]); 1549 1550 1551 uint8_t g = 1552 1553 util_format_linear_to_srgb_8unorm(src[1]); 1554 1555 1556 uint8_t r = 1557 1558 util_format_linear_to_srgb_8unorm(src[0]); 1559 1560 uint32_t d = 0; 1561 d |= PACK(a, 0, 8); 1562 d |= PACK(b, 8, 8); 1563 d |= PACK(g, 16, 8); 1564 d |= PACK(r, 24, 8); 1565 (*(uint32_t *)dst) = d; 1566 } 1567 1568 static inline void 1569 pack_ubyte_b8g8r8a8_srgb(const GLubyte src[4], void *dst) 1570 { 1571 1572 1573 uint8_t b = 1574 1575 util_format_linear_to_srgb_8unorm(src[2]); 1576 1577 1578 uint8_t g = 1579 1580 util_format_linear_to_srgb_8unorm(src[1]); 1581 1582 1583 uint8_t r = 1584 1585 util_format_linear_to_srgb_8unorm(src[0]); 1586 1587 1588 uint8_t a = 1589 _mesa_unorm_to_unorm(src[3], 8, 8); 1590 1591 uint32_t d = 0; 1592 d |= PACK(b, 0, 8); 1593 d |= PACK(g, 8, 8); 1594 d |= PACK(r, 16, 8); 1595 d |= PACK(a, 24, 8); 1596 (*(uint32_t *)dst) = d; 1597 } 1598 1599 static inline void 1600 pack_ubyte_a8r8g8b8_srgb(const GLubyte src[4], void *dst) 1601 { 1602 1603 1604 uint8_t a = 1605 _mesa_unorm_to_unorm(src[3], 8, 8); 1606 1607 1608 uint8_t r = 1609 1610 util_format_linear_to_srgb_8unorm(src[0]); 1611 1612 1613 uint8_t g = 1614 1615 util_format_linear_to_srgb_8unorm(src[1]); 1616 1617 1618 uint8_t b = 1619 1620 util_format_linear_to_srgb_8unorm(src[2]); 1621 1622 uint32_t d = 0; 1623 d |= PACK(a, 0, 8); 1624 d |= PACK(r, 8, 8); 1625 d |= PACK(g, 16, 8); 1626 d |= PACK(b, 24, 8); 1627 (*(uint32_t *)dst) = d; 1628 } 1629 1630 static inline void 1631 pack_ubyte_b8g8r8x8_srgb(const GLubyte src[4], void *dst) 1632 { 1633 1634 1635 uint8_t b = 1636 1637 util_format_linear_to_srgb_8unorm(src[2]); 1638 1639 1640 uint8_t g = 1641 1642 util_format_linear_to_srgb_8unorm(src[1]); 1643 1644 1645 uint8_t r = 1646 1647 util_format_linear_to_srgb_8unorm(src[0]); 1648 1649 1650 uint32_t d = 0; 1651 d |= PACK(b, 0, 8); 1652 d |= PACK(g, 8, 8); 1653 d |= PACK(r, 16, 8); 1654 (*(uint32_t *)dst) = d; 1655 } 1656 1657 static inline void 1658 pack_ubyte_x8r8g8b8_srgb(const GLubyte src[4], void *dst) 1659 { 1660 1661 1662 1663 uint8_t r = 1664 1665 util_format_linear_to_srgb_8unorm(src[0]); 1666 1667 1668 uint8_t g = 1669 1670 util_format_linear_to_srgb_8unorm(src[1]); 1671 1672 1673 uint8_t b = 1674 1675 util_format_linear_to_srgb_8unorm(src[2]); 1676 1677 uint32_t d = 0; 1678 d |= PACK(r, 8, 8); 1679 d |= PACK(g, 16, 8); 1680 d |= PACK(b, 24, 8); 1681 (*(uint32_t *)dst) = d; 1682 } 1683 1684 static inline void 1685 pack_ubyte_r8g8b8a8_srgb(const GLubyte src[4], void *dst) 1686 { 1687 1688 1689 uint8_t r = 1690 1691 util_format_linear_to_srgb_8unorm(src[0]); 1692 1693 1694 uint8_t g = 1695 1696 util_format_linear_to_srgb_8unorm(src[1]); 1697 1698 1699 uint8_t b = 1700 1701 util_format_linear_to_srgb_8unorm(src[2]); 1702 1703 1704 uint8_t a = 1705 _mesa_unorm_to_unorm(src[3], 8, 8); 1706 1707 uint32_t d = 0; 1708 d |= PACK(r, 0, 8); 1709 d |= PACK(g, 8, 8); 1710 d |= PACK(b, 16, 8); 1711 d |= PACK(a, 24, 8); 1712 (*(uint32_t *)dst) = d; 1713 } 1714 1715 static inline void 1716 pack_ubyte_r8g8b8x8_srgb(const GLubyte src[4], void *dst) 1717 { 1718 1719 1720 uint8_t r = 1721 1722 util_format_linear_to_srgb_8unorm(src[0]); 1723 1724 1725 uint8_t g = 1726 1727 util_format_linear_to_srgb_8unorm(src[1]); 1728 1729 1730 uint8_t b = 1731 1732 util_format_linear_to_srgb_8unorm(src[2]); 1733 1734 1735 uint32_t d = 0; 1736 d |= PACK(r, 0, 8); 1737 d |= PACK(g, 8, 8); 1738 d |= PACK(b, 16, 8); 1739 (*(uint32_t *)dst) = d; 1740 } 1741 1742 static inline void 1743 pack_ubyte_x8b8g8r8_srgb(const GLubyte src[4], void *dst) 1744 { 1745 1746 1747 1748 uint8_t b = 1749 1750 util_format_linear_to_srgb_8unorm(src[2]); 1751 1752 1753 uint8_t g = 1754 1755 util_format_linear_to_srgb_8unorm(src[1]); 1756 1757 1758 uint8_t r = 1759 1760 util_format_linear_to_srgb_8unorm(src[0]); 1761 1762 uint32_t d = 0; 1763 d |= PACK(b, 8, 8); 1764 d |= PACK(g, 16, 8); 1765 d |= PACK(r, 24, 8); 1766 (*(uint32_t *)dst) = d; 1767 } 1768 1769 static inline void 1770 pack_ubyte_l8a8_srgb(const GLubyte src[4], void *dst) 1771 { 1772 1773 1774 uint8_t l = 1775 _mesa_unorm_to_unorm(src[0], 8, 8); 1776 1777 1778 uint8_t a = 1779 _mesa_unorm_to_unorm(src[3], 8, 8); 1780 1781 uint16_t d = 0; 1782 d |= PACK(l, 0, 8); 1783 d |= PACK(a, 8, 8); 1784 (*(uint16_t *)dst) = d; 1785 } 1786 1787 static inline void 1788 pack_ubyte_a8l8_srgb(const GLubyte src[4], void *dst) 1789 { 1790 1791 1792 uint8_t a = 1793 _mesa_unorm_to_unorm(src[3], 8, 8); 1794 1795 1796 uint8_t l = 1797 _mesa_unorm_to_unorm(src[0], 8, 8); 1798 1799 uint16_t d = 0; 1800 d |= PACK(a, 0, 8); 1801 d |= PACK(l, 8, 8); 1802 (*(uint16_t *)dst) = d; 1803 } 1804 1805 static inline void 1806 pack_ubyte_l_srgb8(const GLubyte src[4], void *dst) 1807 { 1808 1809 1810 uint8_t l = 1811 _mesa_unorm_to_unorm(src[0], 8, 8); 1812 1813 uint8_t *d = (uint8_t *)dst; 1814 d[0] = l; 1815 } 1816 1817 static inline void 1818 pack_ubyte_bgr_srgb8(const GLubyte src[4], void *dst) 1819 { 1820 1821 1822 uint8_t b = 1823 1824 util_format_linear_to_srgb_8unorm(src[2]); 1825 1826 1827 uint8_t g = 1828 1829 util_format_linear_to_srgb_8unorm(src[1]); 1830 1831 1832 uint8_t r = 1833 1834 util_format_linear_to_srgb_8unorm(src[0]); 1835 1836 uint8_t *d = (uint8_t *)dst; 1837 d[0] = b; 1838 d[1] = g; 1839 d[2] = r; 1840 } 1841 1842 static inline void 1843 pack_ubyte_a_float16(const GLubyte src[4], void *dst) 1844 { 1845 1846 1847 uint16_t a = 1848 _mesa_unorm_to_half(src[3], 8); 1849 1850 uint16_t *d = (uint16_t *)dst; 1851 d[0] = a; 1852 } 1853 1854 static inline void 1855 pack_ubyte_a_float32(const GLubyte src[4], void *dst) 1856 { 1857 1858 1859 float a = 1860 _mesa_unorm_to_float(src[3], 8); 1861 1862 float *d = (float *)dst; 1863 d[0] = a; 1864 } 1865 1866 static inline void 1867 pack_ubyte_l_float16(const GLubyte src[4], void *dst) 1868 { 1869 1870 1871 uint16_t l = 1872 _mesa_unorm_to_half(src[0], 8); 1873 1874 uint16_t *d = (uint16_t *)dst; 1875 d[0] = l; 1876 } 1877 1878 static inline void 1879 pack_ubyte_l_float32(const GLubyte src[4], void *dst) 1880 { 1881 1882 1883 float l = 1884 _mesa_unorm_to_float(src[0], 8); 1885 1886 float *d = (float *)dst; 1887 d[0] = l; 1888 } 1889 1890 static inline void 1891 pack_ubyte_la_float16(const GLubyte src[4], void *dst) 1892 { 1893 1894 1895 uint16_t l = 1896 _mesa_unorm_to_half(src[0], 8); 1897 1898 1899 uint16_t a = 1900 _mesa_unorm_to_half(src[3], 8); 1901 1902 uint16_t *d = (uint16_t *)dst; 1903 d[0] = l; 1904 d[1] = a; 1905 } 1906 1907 static inline void 1908 pack_ubyte_la_float32(const GLubyte src[4], void *dst) 1909 { 1910 1911 1912 float l = 1913 _mesa_unorm_to_float(src[0], 8); 1914 1915 1916 float a = 1917 _mesa_unorm_to_float(src[3], 8); 1918 1919 float *d = (float *)dst; 1920 d[0] = l; 1921 d[1] = a; 1922 } 1923 1924 static inline void 1925 pack_ubyte_i_float16(const GLubyte src[4], void *dst) 1926 { 1927 1928 1929 uint16_t i = 1930 _mesa_unorm_to_half(src[0], 8); 1931 1932 uint16_t *d = (uint16_t *)dst; 1933 d[0] = i; 1934 } 1935 1936 static inline void 1937 pack_ubyte_i_float32(const GLubyte src[4], void *dst) 1938 { 1939 1940 1941 float i = 1942 _mesa_unorm_to_float(src[0], 8); 1943 1944 float *d = (float *)dst; 1945 d[0] = i; 1946 } 1947 1948 static inline void 1949 pack_ubyte_r_float16(const GLubyte src[4], void *dst) 1950 { 1951 1952 1953 uint16_t r = 1954 _mesa_unorm_to_half(src[0], 8); 1955 1956 uint16_t *d = (uint16_t *)dst; 1957 d[0] = r; 1958 } 1959 1960 static inline void 1961 pack_ubyte_r_float32(const GLubyte src[4], void *dst) 1962 { 1963 1964 1965 float r = 1966 _mesa_unorm_to_float(src[0], 8); 1967 1968 float *d = (float *)dst; 1969 d[0] = r; 1970 } 1971 1972 static inline void 1973 pack_ubyte_rg_float16(const GLubyte src[4], void *dst) 1974 { 1975 1976 1977 uint16_t r = 1978 _mesa_unorm_to_half(src[0], 8); 1979 1980 1981 uint16_t g = 1982 _mesa_unorm_to_half(src[1], 8); 1983 1984 uint16_t *d = (uint16_t *)dst; 1985 d[0] = r; 1986 d[1] = g; 1987 } 1988 1989 static inline void 1990 pack_ubyte_rg_float32(const GLubyte src[4], void *dst) 1991 { 1992 1993 1994 float r = 1995 _mesa_unorm_to_float(src[0], 8); 1996 1997 1998 float g = 1999 _mesa_unorm_to_float(src[1], 8); 2000 2001 float *d = (float *)dst; 2002 d[0] = r; 2003 d[1] = g; 2004 } 2005 2006 static inline void 2007 pack_ubyte_rgb_float16(const GLubyte src[4], void *dst) 2008 { 2009 2010 2011 uint16_t r = 2012 _mesa_unorm_to_half(src[0], 8); 2013 2014 2015 uint16_t g = 2016 _mesa_unorm_to_half(src[1], 8); 2017 2018 2019 uint16_t b = 2020 _mesa_unorm_to_half(src[2], 8); 2021 2022 uint16_t *d = (uint16_t *)dst; 2023 d[0] = r; 2024 d[1] = g; 2025 d[2] = b; 2026 } 2027 2028 static inline void 2029 pack_ubyte_rgb_float32(const GLubyte src[4], void *dst) 2030 { 2031 2032 2033 float r = 2034 _mesa_unorm_to_float(src[0], 8); 2035 2036 2037 float g = 2038 _mesa_unorm_to_float(src[1], 8); 2039 2040 2041 float b = 2042 _mesa_unorm_to_float(src[2], 8); 2043 2044 float *d = (float *)dst; 2045 d[0] = r; 2046 d[1] = g; 2047 d[2] = b; 2048 } 2049 2050 static inline void 2051 pack_ubyte_rgba_float16(const GLubyte src[4], void *dst) 2052 { 2053 2054 2055 uint16_t r = 2056 _mesa_unorm_to_half(src[0], 8); 2057 2058 2059 uint16_t g = 2060 _mesa_unorm_to_half(src[1], 8); 2061 2062 2063 uint16_t b = 2064 _mesa_unorm_to_half(src[2], 8); 2065 2066 2067 uint16_t a = 2068 _mesa_unorm_to_half(src[3], 8); 2069 2070 uint16_t *d = (uint16_t *)dst; 2071 d[0] = r; 2072 d[1] = g; 2073 d[2] = b; 2074 d[3] = a; 2075 } 2076 2077 static inline void 2078 pack_ubyte_rgba_float32(const GLubyte src[4], void *dst) 2079 { 2080 2081 2082 float r = 2083 _mesa_unorm_to_float(src[0], 8); 2084 2085 2086 float g = 2087 _mesa_unorm_to_float(src[1], 8); 2088 2089 2090 float b = 2091 _mesa_unorm_to_float(src[2], 8); 2092 2093 2094 float a = 2095 _mesa_unorm_to_float(src[3], 8); 2096 2097 float *d = (float *)dst; 2098 d[0] = r; 2099 d[1] = g; 2100 d[2] = b; 2101 d[3] = a; 2102 } 2103 2104 static inline void 2105 pack_ubyte_rgbx_float16(const GLubyte src[4], void *dst) 2106 { 2107 2108 2109 uint16_t r = 2110 _mesa_unorm_to_half(src[0], 8); 2111 2112 2113 uint16_t g = 2114 _mesa_unorm_to_half(src[1], 8); 2115 2116 2117 uint16_t b = 2118 _mesa_unorm_to_half(src[2], 8); 2119 2120 2121 uint16_t *d = (uint16_t *)dst; 2122 d[0] = r; 2123 d[1] = g; 2124 d[2] = b; 2125 } 2126 2127 static inline void 2128 pack_ubyte_rgbx_float32(const GLubyte src[4], void *dst) 2129 { 2130 2131 2132 float r = 2133 _mesa_unorm_to_float(src[0], 8); 2134 2135 2136 float g = 2137 _mesa_unorm_to_float(src[1], 8); 2138 2139 2140 float b = 2141 _mesa_unorm_to_float(src[2], 8); 2142 2143 2144 float *d = (float *)dst; 2145 d[0] = r; 2146 d[1] = g; 2147 d[2] = b; 2148 } 2149 2150 static inline void 2151 pack_ubyte_a8b8g8r8_uint(const GLubyte src[4], void *dst) 2152 { 2153 2154 2155 uint8_t a = 2156 _mesa_unsigned_to_unsigned(src[3], 8); 2157 2158 2159 uint8_t b = 2160 _mesa_unsigned_to_unsigned(src[2], 8); 2161 2162 2163 uint8_t g = 2164 _mesa_unsigned_to_unsigned(src[1], 8); 2165 2166 2167 uint8_t r = 2168 _mesa_unsigned_to_unsigned(src[0], 8); 2169 2170 uint32_t d = 0; 2171 d |= PACK(a, 0, 8); 2172 d |= PACK(b, 8, 8); 2173 d |= PACK(g, 16, 8); 2174 d |= PACK(r, 24, 8); 2175 (*(uint32_t *)dst) = d; 2176 } 2177 2178 static inline void 2179 pack_ubyte_a8r8g8b8_uint(const GLubyte src[4], void *dst) 2180 { 2181 2182 2183 uint8_t a = 2184 _mesa_unsigned_to_unsigned(src[3], 8); 2185 2186 2187 uint8_t r = 2188 _mesa_unsigned_to_unsigned(src[0], 8); 2189 2190 2191 uint8_t g = 2192 _mesa_unsigned_to_unsigned(src[1], 8); 2193 2194 2195 uint8_t b = 2196 _mesa_unsigned_to_unsigned(src[2], 8); 2197 2198 uint32_t d = 0; 2199 d |= PACK(a, 0, 8); 2200 d |= PACK(r, 8, 8); 2201 d |= PACK(g, 16, 8); 2202 d |= PACK(b, 24, 8); 2203 (*(uint32_t *)dst) = d; 2204 } 2205 2206 static inline void 2207 pack_ubyte_r8g8b8a8_uint(const GLubyte src[4], void *dst) 2208 { 2209 2210 2211 uint8_t r = 2212 _mesa_unsigned_to_unsigned(src[0], 8); 2213 2214 2215 uint8_t g = 2216 _mesa_unsigned_to_unsigned(src[1], 8); 2217 2218 2219 uint8_t b = 2220 _mesa_unsigned_to_unsigned(src[2], 8); 2221 2222 2223 uint8_t a = 2224 _mesa_unsigned_to_unsigned(src[3], 8); 2225 2226 uint32_t d = 0; 2227 d |= PACK(r, 0, 8); 2228 d |= PACK(g, 8, 8); 2229 d |= PACK(b, 16, 8); 2230 d |= PACK(a, 24, 8); 2231 (*(uint32_t *)dst) = d; 2232 } 2233 2234 static inline void 2235 pack_ubyte_b8g8r8a8_uint(const GLubyte src[4], void *dst) 2236 { 2237 2238 2239 uint8_t b = 2240 _mesa_unsigned_to_unsigned(src[2], 8); 2241 2242 2243 uint8_t g = 2244 _mesa_unsigned_to_unsigned(src[1], 8); 2245 2246 2247 uint8_t r = 2248 _mesa_unsigned_to_unsigned(src[0], 8); 2249 2250 2251 uint8_t a = 2252 _mesa_unsigned_to_unsigned(src[3], 8); 2253 2254 uint32_t d = 0; 2255 d |= PACK(b, 0, 8); 2256 d |= PACK(g, 8, 8); 2257 d |= PACK(r, 16, 8); 2258 d |= PACK(a, 24, 8); 2259 (*(uint32_t *)dst) = d; 2260 } 2261 2262 static inline void 2263 pack_ubyte_b10g10r10a2_uint(const GLubyte src[4], void *dst) 2264 { 2265 2266 2267 uint16_t b = 2268 _mesa_unsigned_to_unsigned(src[2], 10); 2269 2270 2271 uint16_t g = 2272 _mesa_unsigned_to_unsigned(src[1], 10); 2273 2274 2275 uint16_t r = 2276 _mesa_unsigned_to_unsigned(src[0], 10); 2277 2278 2279 uint8_t a = 2280 _mesa_unsigned_to_unsigned(src[3], 2); 2281 2282 uint32_t d = 0; 2283 d |= PACK(b, 0, 10); 2284 d |= PACK(g, 10, 10); 2285 d |= PACK(r, 20, 10); 2286 d |= PACK(a, 30, 2); 2287 (*(uint32_t *)dst) = d; 2288 } 2289 2290 static inline void 2291 pack_ubyte_r10g10b10a2_uint(const GLubyte src[4], void *dst) 2292 { 2293 2294 2295 uint16_t r = 2296 _mesa_unsigned_to_unsigned(src[0], 10); 2297 2298 2299 uint16_t g = 2300 _mesa_unsigned_to_unsigned(src[1], 10); 2301 2302 2303 uint16_t b = 2304 _mesa_unsigned_to_unsigned(src[2], 10); 2305 2306 2307 uint8_t a = 2308 _mesa_unsigned_to_unsigned(src[3], 2); 2309 2310 uint32_t d = 0; 2311 d |= PACK(r, 0, 10); 2312 d |= PACK(g, 10, 10); 2313 d |= PACK(b, 20, 10); 2314 d |= PACK(a, 30, 2); 2315 (*(uint32_t *)dst) = d; 2316 } 2317 2318 static inline void 2319 pack_ubyte_a2b10g10r10_uint(const GLubyte src[4], void *dst) 2320 { 2321 2322 2323 uint8_t a = 2324 _mesa_unsigned_to_unsigned(src[3], 2); 2325 2326 2327 uint16_t b = 2328 _mesa_unsigned_to_unsigned(src[2], 10); 2329 2330 2331 uint16_t g = 2332 _mesa_unsigned_to_unsigned(src[1], 10); 2333 2334 2335 uint16_t r = 2336 _mesa_unsigned_to_unsigned(src[0], 10); 2337 2338 uint32_t d = 0; 2339 d |= PACK(a, 0, 2); 2340 d |= PACK(b, 2, 10); 2341 d |= PACK(g, 12, 10); 2342 d |= PACK(r, 22, 10); 2343 (*(uint32_t *)dst) = d; 2344 } 2345 2346 static inline void 2347 pack_ubyte_a2r10g10b10_uint(const GLubyte src[4], void *dst) 2348 { 2349 2350 2351 uint8_t a = 2352 _mesa_unsigned_to_unsigned(src[3], 2); 2353 2354 2355 uint16_t r = 2356 _mesa_unsigned_to_unsigned(src[0], 10); 2357 2358 2359 uint16_t g = 2360 _mesa_unsigned_to_unsigned(src[1], 10); 2361 2362 2363 uint16_t b = 2364 _mesa_unsigned_to_unsigned(src[2], 10); 2365 2366 uint32_t d = 0; 2367 d |= PACK(a, 0, 2); 2368 d |= PACK(r, 2, 10); 2369 d |= PACK(g, 12, 10); 2370 d |= PACK(b, 22, 10); 2371 (*(uint32_t *)dst) = d; 2372 } 2373 2374 static inline void 2375 pack_ubyte_b5g6r5_uint(const GLubyte src[4], void *dst) 2376 { 2377 2378 2379 uint8_t b = 2380 _mesa_unsigned_to_unsigned(src[2], 5); 2381 2382 2383 uint8_t g = 2384 _mesa_unsigned_to_unsigned(src[1], 6); 2385 2386 2387 uint8_t r = 2388 _mesa_unsigned_to_unsigned(src[0], 5); 2389 2390 uint16_t d = 0; 2391 d |= PACK(b, 0, 5); 2392 d |= PACK(g, 5, 6); 2393 d |= PACK(r, 11, 5); 2394 (*(uint16_t *)dst) = d; 2395 } 2396 2397 static inline void 2398 pack_ubyte_r5g6b5_uint(const GLubyte src[4], void *dst) 2399 { 2400 2401 2402 uint8_t r = 2403 _mesa_unsigned_to_unsigned(src[0], 5); 2404 2405 2406 uint8_t g = 2407 _mesa_unsigned_to_unsigned(src[1], 6); 2408 2409 2410 uint8_t b = 2411 _mesa_unsigned_to_unsigned(src[2], 5); 2412 2413 uint16_t d = 0; 2414 d |= PACK(r, 0, 5); 2415 d |= PACK(g, 5, 6); 2416 d |= PACK(b, 11, 5); 2417 (*(uint16_t *)dst) = d; 2418 } 2419 2420 static inline void 2421 pack_ubyte_b2g3r3_uint(const GLubyte src[4], void *dst) 2422 { 2423 2424 2425 uint8_t b = 2426 _mesa_unsigned_to_unsigned(src[2], 2); 2427 2428 2429 uint8_t g = 2430 _mesa_unsigned_to_unsigned(src[1], 3); 2431 2432 2433 uint8_t r = 2434 _mesa_unsigned_to_unsigned(src[0], 3); 2435 2436 uint8_t d = 0; 2437 d |= PACK(b, 0, 2); 2438 d |= PACK(g, 2, 3); 2439 d |= PACK(r, 5, 3); 2440 (*(uint8_t *)dst) = d; 2441 } 2442 2443 static inline void 2444 pack_ubyte_r3g3b2_uint(const GLubyte src[4], void *dst) 2445 { 2446 2447 2448 uint8_t r = 2449 _mesa_unsigned_to_unsigned(src[0], 3); 2450 2451 2452 uint8_t g = 2453 _mesa_unsigned_to_unsigned(src[1], 3); 2454 2455 2456 uint8_t b = 2457 _mesa_unsigned_to_unsigned(src[2], 2); 2458 2459 uint8_t d = 0; 2460 d |= PACK(r, 0, 3); 2461 d |= PACK(g, 3, 3); 2462 d |= PACK(b, 6, 2); 2463 (*(uint8_t *)dst) = d; 2464 } 2465 2466 static inline void 2467 pack_ubyte_a4b4g4r4_uint(const GLubyte src[4], void *dst) 2468 { 2469 2470 2471 uint8_t a = 2472 _mesa_unsigned_to_unsigned(src[3], 4); 2473 2474 2475 uint8_t b = 2476 _mesa_unsigned_to_unsigned(src[2], 4); 2477 2478 2479 uint8_t g = 2480 _mesa_unsigned_to_unsigned(src[1], 4); 2481 2482 2483 uint8_t r = 2484 _mesa_unsigned_to_unsigned(src[0], 4); 2485 2486 uint16_t d = 0; 2487 d |= PACK(a, 0, 4); 2488 d |= PACK(b, 4, 4); 2489 d |= PACK(g, 8, 4); 2490 d |= PACK(r, 12, 4); 2491 (*(uint16_t *)dst) = d; 2492 } 2493 2494 static inline void 2495 pack_ubyte_r4g4b4a4_uint(const GLubyte src[4], void *dst) 2496 { 2497 2498 2499 uint8_t r = 2500 _mesa_unsigned_to_unsigned(src[0], 4); 2501 2502 2503 uint8_t g = 2504 _mesa_unsigned_to_unsigned(src[1], 4); 2505 2506 2507 uint8_t b = 2508 _mesa_unsigned_to_unsigned(src[2], 4); 2509 2510 2511 uint8_t a = 2512 _mesa_unsigned_to_unsigned(src[3], 4); 2513 2514 uint16_t d = 0; 2515 d |= PACK(r, 0, 4); 2516 d |= PACK(g, 4, 4); 2517 d |= PACK(b, 8, 4); 2518 d |= PACK(a, 12, 4); 2519 (*(uint16_t *)dst) = d; 2520 } 2521 2522 static inline void 2523 pack_ubyte_b4g4r4a4_uint(const GLubyte src[4], void *dst) 2524 { 2525 2526 2527 uint8_t b = 2528 _mesa_unsigned_to_unsigned(src[2], 4); 2529 2530 2531 uint8_t g = 2532 _mesa_unsigned_to_unsigned(src[1], 4); 2533 2534 2535 uint8_t r = 2536 _mesa_unsigned_to_unsigned(src[0], 4); 2537 2538 2539 uint8_t a = 2540 _mesa_unsigned_to_unsigned(src[3], 4); 2541 2542 uint16_t d = 0; 2543 d |= PACK(b, 0, 4); 2544 d |= PACK(g, 4, 4); 2545 d |= PACK(r, 8, 4); 2546 d |= PACK(a, 12, 4); 2547 (*(uint16_t *)dst) = d; 2548 } 2549 2550 static inline void 2551 pack_ubyte_a4r4g4b4_uint(const GLubyte src[4], void *dst) 2552 { 2553 2554 2555 uint8_t a = 2556 _mesa_unsigned_to_unsigned(src[3], 4); 2557 2558 2559 uint8_t r = 2560 _mesa_unsigned_to_unsigned(src[0], 4); 2561 2562 2563 uint8_t g = 2564 _mesa_unsigned_to_unsigned(src[1], 4); 2565 2566 2567 uint8_t b = 2568 _mesa_unsigned_to_unsigned(src[2], 4); 2569 2570 uint16_t d = 0; 2571 d |= PACK(a, 0, 4); 2572 d |= PACK(r, 4, 4); 2573 d |= PACK(g, 8, 4); 2574 d |= PACK(b, 12, 4); 2575 (*(uint16_t *)dst) = d; 2576 } 2577 2578 static inline void 2579 pack_ubyte_a1b5g5r5_uint(const GLubyte src[4], void *dst) 2580 { 2581 2582 2583 uint8_t a = 2584 _mesa_unsigned_to_unsigned(src[3], 1); 2585 2586 2587 uint8_t b = 2588 _mesa_unsigned_to_unsigned(src[2], 5); 2589 2590 2591 uint8_t g = 2592 _mesa_unsigned_to_unsigned(src[1], 5); 2593 2594 2595 uint8_t r = 2596 _mesa_unsigned_to_unsigned(src[0], 5); 2597 2598 uint16_t d = 0; 2599 d |= PACK(a, 0, 1); 2600 d |= PACK(b, 1, 5); 2601 d |= PACK(g, 6, 5); 2602 d |= PACK(r, 11, 5); 2603 (*(uint16_t *)dst) = d; 2604 } 2605 2606 static inline void 2607 pack_ubyte_b5g5r5a1_uint(const GLubyte src[4], void *dst) 2608 { 2609 2610 2611 uint8_t b = 2612 _mesa_unsigned_to_unsigned(src[2], 5); 2613 2614 2615 uint8_t g = 2616 _mesa_unsigned_to_unsigned(src[1], 5); 2617 2618 2619 uint8_t r = 2620 _mesa_unsigned_to_unsigned(src[0], 5); 2621 2622 2623 uint8_t a = 2624 _mesa_unsigned_to_unsigned(src[3], 1); 2625 2626 uint16_t d = 0; 2627 d |= PACK(b, 0, 5); 2628 d |= PACK(g, 5, 5); 2629 d |= PACK(r, 10, 5); 2630 d |= PACK(a, 15, 1); 2631 (*(uint16_t *)dst) = d; 2632 } 2633 2634 static inline void 2635 pack_ubyte_a1r5g5b5_uint(const GLubyte src[4], void *dst) 2636 { 2637 2638 2639 uint8_t a = 2640 _mesa_unsigned_to_unsigned(src[3], 1); 2641 2642 2643 uint8_t r = 2644 _mesa_unsigned_to_unsigned(src[0], 5); 2645 2646 2647 uint8_t g = 2648 _mesa_unsigned_to_unsigned(src[1], 5); 2649 2650 2651 uint8_t b = 2652 _mesa_unsigned_to_unsigned(src[2], 5); 2653 2654 uint16_t d = 0; 2655 d |= PACK(a, 0, 1); 2656 d |= PACK(r, 1, 5); 2657 d |= PACK(g, 6, 5); 2658 d |= PACK(b, 11, 5); 2659 (*(uint16_t *)dst) = d; 2660 } 2661 2662 static inline void 2663 pack_ubyte_r5g5b5a1_uint(const GLubyte src[4], void *dst) 2664 { 2665 2666 2667 uint8_t r = 2668 _mesa_unsigned_to_unsigned(src[0], 5); 2669 2670 2671 uint8_t g = 2672 _mesa_unsigned_to_unsigned(src[1], 5); 2673 2674 2675 uint8_t b = 2676 _mesa_unsigned_to_unsigned(src[2], 5); 2677 2678 2679 uint8_t a = 2680 _mesa_unsigned_to_unsigned(src[3], 1); 2681 2682 uint16_t d = 0; 2683 d |= PACK(r, 0, 5); 2684 d |= PACK(g, 5, 5); 2685 d |= PACK(b, 10, 5); 2686 d |= PACK(a, 15, 1); 2687 (*(uint16_t *)dst) = d; 2688 } 2689 2690 static inline void 2691 pack_ubyte_a_uint8(const GLubyte src[4], void *dst) 2692 { 2693 2694 2695 uint8_t a = 2696 _mesa_unsigned_to_unsigned(src[3], 8); 2697 2698 uint8_t *d = (uint8_t *)dst; 2699 d[0] = a; 2700 } 2701 2702 static inline void 2703 pack_ubyte_a_uint16(const GLubyte src[4], void *dst) 2704 { 2705 2706 2707 uint16_t a = 2708 _mesa_unsigned_to_unsigned(src[3], 16); 2709 2710 uint16_t *d = (uint16_t *)dst; 2711 d[0] = a; 2712 } 2713 2714 static inline void 2715 pack_ubyte_a_uint32(const GLubyte src[4], void *dst) 2716 { 2717 2718 2719 uint32_t a = 2720 _mesa_unsigned_to_unsigned(src[3], 32); 2721 2722 uint32_t *d = (uint32_t *)dst; 2723 d[0] = a; 2724 } 2725 2726 static inline void 2727 pack_ubyte_a_sint8(const GLubyte src[4], void *dst) 2728 { 2729 2730 2731 int8_t a = 2732 _mesa_unsigned_to_signed(src[3], 8); 2733 2734 int8_t *d = (int8_t *)dst; 2735 d[0] = a; 2736 } 2737 2738 static inline void 2739 pack_ubyte_a_sint16(const GLubyte src[4], void *dst) 2740 { 2741 2742 2743 int16_t a = 2744 _mesa_unsigned_to_signed(src[3], 16); 2745 2746 int16_t *d = (int16_t *)dst; 2747 d[0] = a; 2748 } 2749 2750 static inline void 2751 pack_ubyte_a_sint32(const GLubyte src[4], void *dst) 2752 { 2753 2754 2755 int32_t a = 2756 _mesa_unsigned_to_signed(src[3], 32); 2757 2758 int32_t *d = (int32_t *)dst; 2759 d[0] = a; 2760 } 2761 2762 static inline void 2763 pack_ubyte_i_uint8(const GLubyte src[4], void *dst) 2764 { 2765 2766 2767 uint8_t i = 2768 _mesa_unsigned_to_unsigned(src[0], 8); 2769 2770 uint8_t *d = (uint8_t *)dst; 2771 d[0] = i; 2772 } 2773 2774 static inline void 2775 pack_ubyte_i_uint16(const GLubyte src[4], void *dst) 2776 { 2777 2778 2779 uint16_t i = 2780 _mesa_unsigned_to_unsigned(src[0], 16); 2781 2782 uint16_t *d = (uint16_t *)dst; 2783 d[0] = i; 2784 } 2785 2786 static inline void 2787 pack_ubyte_i_uint32(const GLubyte src[4], void *dst) 2788 { 2789 2790 2791 uint32_t i = 2792 _mesa_unsigned_to_unsigned(src[0], 32); 2793 2794 uint32_t *d = (uint32_t *)dst; 2795 d[0] = i; 2796 } 2797 2798 static inline void 2799 pack_ubyte_i_sint8(const GLubyte src[4], void *dst) 2800 { 2801 2802 2803 int8_t i = 2804 _mesa_unsigned_to_signed(src[0], 8); 2805 2806 int8_t *d = (int8_t *)dst; 2807 d[0] = i; 2808 } 2809 2810 static inline void 2811 pack_ubyte_i_sint16(const GLubyte src[4], void *dst) 2812 { 2813 2814 2815 int16_t i = 2816 _mesa_unsigned_to_signed(src[0], 16); 2817 2818 int16_t *d = (int16_t *)dst; 2819 d[0] = i; 2820 } 2821 2822 static inline void 2823 pack_ubyte_i_sint32(const GLubyte src[4], void *dst) 2824 { 2825 2826 2827 int32_t i = 2828 _mesa_unsigned_to_signed(src[0], 32); 2829 2830 int32_t *d = (int32_t *)dst; 2831 d[0] = i; 2832 } 2833 2834 static inline void 2835 pack_ubyte_l_uint8(const GLubyte src[4], void *dst) 2836 { 2837 2838 2839 uint8_t l = 2840 _mesa_unsigned_to_unsigned(src[0], 8); 2841 2842 uint8_t *d = (uint8_t *)dst; 2843 d[0] = l; 2844 } 2845 2846 static inline void 2847 pack_ubyte_l_uint16(const GLubyte src[4], void *dst) 2848 { 2849 2850 2851 uint16_t l = 2852 _mesa_unsigned_to_unsigned(src[0], 16); 2853 2854 uint16_t *d = (uint16_t *)dst; 2855 d[0] = l; 2856 } 2857 2858 static inline void 2859 pack_ubyte_l_uint32(const GLubyte src[4], void *dst) 2860 { 2861 2862 2863 uint32_t l = 2864 _mesa_unsigned_to_unsigned(src[0], 32); 2865 2866 uint32_t *d = (uint32_t *)dst; 2867 d[0] = l; 2868 } 2869 2870 static inline void 2871 pack_ubyte_l_sint8(const GLubyte src[4], void *dst) 2872 { 2873 2874 2875 int8_t l = 2876 _mesa_unsigned_to_signed(src[0], 8); 2877 2878 int8_t *d = (int8_t *)dst; 2879 d[0] = l; 2880 } 2881 2882 static inline void 2883 pack_ubyte_l_sint16(const GLubyte src[4], void *dst) 2884 { 2885 2886 2887 int16_t l = 2888 _mesa_unsigned_to_signed(src[0], 16); 2889 2890 int16_t *d = (int16_t *)dst; 2891 d[0] = l; 2892 } 2893 2894 static inline void 2895 pack_ubyte_l_sint32(const GLubyte src[4], void *dst) 2896 { 2897 2898 2899 int32_t l = 2900 _mesa_unsigned_to_signed(src[0], 32); 2901 2902 int32_t *d = (int32_t *)dst; 2903 d[0] = l; 2904 } 2905 2906 static inline void 2907 pack_ubyte_la_uint8(const GLubyte src[4], void *dst) 2908 { 2909 2910 2911 uint8_t l = 2912 _mesa_unsigned_to_unsigned(src[0], 8); 2913 2914 2915 uint8_t a = 2916 _mesa_unsigned_to_unsigned(src[3], 8); 2917 2918 uint8_t *d = (uint8_t *)dst; 2919 d[0] = l; 2920 d[1] = a; 2921 } 2922 2923 static inline void 2924 pack_ubyte_la_uint16(const GLubyte src[4], void *dst) 2925 { 2926 2927 2928 uint16_t l = 2929 _mesa_unsigned_to_unsigned(src[0], 16); 2930 2931 2932 uint16_t a = 2933 _mesa_unsigned_to_unsigned(src[3], 16); 2934 2935 uint16_t *d = (uint16_t *)dst; 2936 d[0] = l; 2937 d[1] = a; 2938 } 2939 2940 static inline void 2941 pack_ubyte_la_uint32(const GLubyte src[4], void *dst) 2942 { 2943 2944 2945 uint32_t l = 2946 _mesa_unsigned_to_unsigned(src[0], 32); 2947 2948 2949 uint32_t a = 2950 _mesa_unsigned_to_unsigned(src[3], 32); 2951 2952 uint32_t *d = (uint32_t *)dst; 2953 d[0] = l; 2954 d[1] = a; 2955 } 2956 2957 static inline void 2958 pack_ubyte_la_sint8(const GLubyte src[4], void *dst) 2959 { 2960 2961 2962 int8_t l = 2963 _mesa_unsigned_to_signed(src[0], 8); 2964 2965 2966 int8_t a = 2967 _mesa_unsigned_to_signed(src[3], 8); 2968 2969 int8_t *d = (int8_t *)dst; 2970 d[0] = l; 2971 d[1] = a; 2972 } 2973 2974 static inline void 2975 pack_ubyte_la_sint16(const GLubyte src[4], void *dst) 2976 { 2977 2978 2979 int16_t l = 2980 _mesa_unsigned_to_signed(src[0], 16); 2981 2982 2983 int16_t a = 2984 _mesa_unsigned_to_signed(src[3], 16); 2985 2986 int16_t *d = (int16_t *)dst; 2987 d[0] = l; 2988 d[1] = a; 2989 } 2990 2991 static inline void 2992 pack_ubyte_la_sint32(const GLubyte src[4], void *dst) 2993 { 2994 2995 2996 int32_t l = 2997 _mesa_unsigned_to_signed(src[0], 32); 2998 2999 3000 int32_t a = 3001 _mesa_unsigned_to_signed(src[3], 32); 3002 3003 int32_t *d = (int32_t *)dst; 3004 d[0] = l; 3005 d[1] = a; 3006 } 3007 3008 static inline void 3009 pack_ubyte_r_uint8(const GLubyte src[4], void *dst) 3010 { 3011 3012 3013 uint8_t r = 3014 _mesa_unsigned_to_unsigned(src[0], 8); 3015 3016 uint8_t *d = (uint8_t *)dst; 3017 d[0] = r; 3018 } 3019 3020 static inline void 3021 pack_ubyte_r_uint16(const GLubyte src[4], void *dst) 3022 { 3023 3024 3025 uint16_t r = 3026 _mesa_unsigned_to_unsigned(src[0], 16); 3027 3028 uint16_t *d = (uint16_t *)dst; 3029 d[0] = r; 3030 } 3031 3032 static inline void 3033 pack_ubyte_r_uint32(const GLubyte src[4], void *dst) 3034 { 3035 3036 3037 uint32_t r = 3038 _mesa_unsigned_to_unsigned(src[0], 32); 3039 3040 uint32_t *d = (uint32_t *)dst; 3041 d[0] = r; 3042 } 3043 3044 static inline void 3045 pack_ubyte_r_sint8(const GLubyte src[4], void *dst) 3046 { 3047 3048 3049 int8_t r = 3050 _mesa_unsigned_to_signed(src[0], 8); 3051 3052 int8_t *d = (int8_t *)dst; 3053 d[0] = r; 3054 } 3055 3056 static inline void 3057 pack_ubyte_r_sint16(const GLubyte src[4], void *dst) 3058 { 3059 3060 3061 int16_t r = 3062 _mesa_unsigned_to_signed(src[0], 16); 3063 3064 int16_t *d = (int16_t *)dst; 3065 d[0] = r; 3066 } 3067 3068 static inline void 3069 pack_ubyte_r_sint32(const GLubyte src[4], void *dst) 3070 { 3071 3072 3073 int32_t r = 3074 _mesa_unsigned_to_signed(src[0], 32); 3075 3076 int32_t *d = (int32_t *)dst; 3077 d[0] = r; 3078 } 3079 3080 static inline void 3081 pack_ubyte_rg_uint8(const GLubyte src[4], void *dst) 3082 { 3083 3084 3085 uint8_t r = 3086 _mesa_unsigned_to_unsigned(src[0], 8); 3087 3088 3089 uint8_t g = 3090 _mesa_unsigned_to_unsigned(src[1], 8); 3091 3092 uint8_t *d = (uint8_t *)dst; 3093 d[0] = r; 3094 d[1] = g; 3095 } 3096 3097 static inline void 3098 pack_ubyte_rg_uint16(const GLubyte src[4], void *dst) 3099 { 3100 3101 3102 uint16_t r = 3103 _mesa_unsigned_to_unsigned(src[0], 16); 3104 3105 3106 uint16_t g = 3107 _mesa_unsigned_to_unsigned(src[1], 16); 3108 3109 uint16_t *d = (uint16_t *)dst; 3110 d[0] = r; 3111 d[1] = g; 3112 } 3113 3114 static inline void 3115 pack_ubyte_rg_uint32(const GLubyte src[4], void *dst) 3116 { 3117 3118 3119 uint32_t r = 3120 _mesa_unsigned_to_unsigned(src[0], 32); 3121 3122 3123 uint32_t g = 3124 _mesa_unsigned_to_unsigned(src[1], 32); 3125 3126 uint32_t *d = (uint32_t *)dst; 3127 d[0] = r; 3128 d[1] = g; 3129 } 3130 3131 static inline void 3132 pack_ubyte_rg_sint8(const GLubyte src[4], void *dst) 3133 { 3134 3135 3136 int8_t r = 3137 _mesa_unsigned_to_signed(src[0], 8); 3138 3139 3140 int8_t g = 3141 _mesa_unsigned_to_signed(src[1], 8); 3142 3143 int8_t *d = (int8_t *)dst; 3144 d[0] = r; 3145 d[1] = g; 3146 } 3147 3148 static inline void 3149 pack_ubyte_rg_sint16(const GLubyte src[4], void *dst) 3150 { 3151 3152 3153 int16_t r = 3154 _mesa_unsigned_to_signed(src[0], 16); 3155 3156 3157 int16_t g = 3158 _mesa_unsigned_to_signed(src[1], 16); 3159 3160 int16_t *d = (int16_t *)dst; 3161 d[0] = r; 3162 d[1] = g; 3163 } 3164 3165 static inline void 3166 pack_ubyte_rg_sint32(const GLubyte src[4], void *dst) 3167 { 3168 3169 3170 int32_t r = 3171 _mesa_unsigned_to_signed(src[0], 32); 3172 3173 3174 int32_t g = 3175 _mesa_unsigned_to_signed(src[1], 32); 3176 3177 int32_t *d = (int32_t *)dst; 3178 d[0] = r; 3179 d[1] = g; 3180 } 3181 3182 static inline void 3183 pack_ubyte_rgb_uint8(const GLubyte src[4], void *dst) 3184 { 3185 3186 3187 uint8_t r = 3188 _mesa_unsigned_to_unsigned(src[0], 8); 3189 3190 3191 uint8_t g = 3192 _mesa_unsigned_to_unsigned(src[1], 8); 3193 3194 3195 uint8_t b = 3196 _mesa_unsigned_to_unsigned(src[2], 8); 3197 3198 uint8_t *d = (uint8_t *)dst; 3199 d[0] = r; 3200 d[1] = g; 3201 d[2] = b; 3202 } 3203 3204 static inline void 3205 pack_ubyte_rgb_uint16(const GLubyte src[4], void *dst) 3206 { 3207 3208 3209 uint16_t r = 3210 _mesa_unsigned_to_unsigned(src[0], 16); 3211 3212 3213 uint16_t g = 3214 _mesa_unsigned_to_unsigned(src[1], 16); 3215 3216 3217 uint16_t b = 3218 _mesa_unsigned_to_unsigned(src[2], 16); 3219 3220 uint16_t *d = (uint16_t *)dst; 3221 d[0] = r; 3222 d[1] = g; 3223 d[2] = b; 3224 } 3225 3226 static inline void 3227 pack_ubyte_rgb_uint32(const GLubyte src[4], void *dst) 3228 { 3229 3230 3231 uint32_t r = 3232 _mesa_unsigned_to_unsigned(src[0], 32); 3233 3234 3235 uint32_t g = 3236 _mesa_unsigned_to_unsigned(src[1], 32); 3237 3238 3239 uint32_t b = 3240 _mesa_unsigned_to_unsigned(src[2], 32); 3241 3242 uint32_t *d = (uint32_t *)dst; 3243 d[0] = r; 3244 d[1] = g; 3245 d[2] = b; 3246 } 3247 3248 static inline void 3249 pack_ubyte_rgb_sint8(const GLubyte src[4], void *dst) 3250 { 3251 3252 3253 int8_t r = 3254 _mesa_unsigned_to_signed(src[0], 8); 3255 3256 3257 int8_t g = 3258 _mesa_unsigned_to_signed(src[1], 8); 3259 3260 3261 int8_t b = 3262 _mesa_unsigned_to_signed(src[2], 8); 3263 3264 int8_t *d = (int8_t *)dst; 3265 d[0] = r; 3266 d[1] = g; 3267 d[2] = b; 3268 } 3269 3270 static inline void 3271 pack_ubyte_rgb_sint16(const GLubyte src[4], void *dst) 3272 { 3273 3274 3275 int16_t r = 3276 _mesa_unsigned_to_signed(src[0], 16); 3277 3278 3279 int16_t g = 3280 _mesa_unsigned_to_signed(src[1], 16); 3281 3282 3283 int16_t b = 3284 _mesa_unsigned_to_signed(src[2], 16); 3285 3286 int16_t *d = (int16_t *)dst; 3287 d[0] = r; 3288 d[1] = g; 3289 d[2] = b; 3290 } 3291 3292 static inline void 3293 pack_ubyte_rgb_sint32(const GLubyte src[4], void *dst) 3294 { 3295 3296 3297 int32_t r = 3298 _mesa_unsigned_to_signed(src[0], 32); 3299 3300 3301 int32_t g = 3302 _mesa_unsigned_to_signed(src[1], 32); 3303 3304 3305 int32_t b = 3306 _mesa_unsigned_to_signed(src[2], 32); 3307 3308 int32_t *d = (int32_t *)dst; 3309 d[0] = r; 3310 d[1] = g; 3311 d[2] = b; 3312 } 3313 3314 static inline void 3315 pack_ubyte_rgba_uint8(const GLubyte src[4], void *dst) 3316 { 3317 3318 3319 uint8_t r = 3320 _mesa_unsigned_to_unsigned(src[0], 8); 3321 3322 3323 uint8_t g = 3324 _mesa_unsigned_to_unsigned(src[1], 8); 3325 3326 3327 uint8_t b = 3328 _mesa_unsigned_to_unsigned(src[2], 8); 3329 3330 3331 uint8_t a = 3332 _mesa_unsigned_to_unsigned(src[3], 8); 3333 3334 uint8_t *d = (uint8_t *)dst; 3335 d[0] = r; 3336 d[1] = g; 3337 d[2] = b; 3338 d[3] = a; 3339 } 3340 3341 static inline void 3342 pack_ubyte_rgba_uint16(const GLubyte src[4], void *dst) 3343 { 3344 3345 3346 uint16_t r = 3347 _mesa_unsigned_to_unsigned(src[0], 16); 3348 3349 3350 uint16_t g = 3351 _mesa_unsigned_to_unsigned(src[1], 16); 3352 3353 3354 uint16_t b = 3355 _mesa_unsigned_to_unsigned(src[2], 16); 3356 3357 3358 uint16_t a = 3359 _mesa_unsigned_to_unsigned(src[3], 16); 3360 3361 uint16_t *d = (uint16_t *)dst; 3362 d[0] = r; 3363 d[1] = g; 3364 d[2] = b; 3365 d[3] = a; 3366 } 3367 3368 static inline void 3369 pack_ubyte_rgba_uint32(const GLubyte src[4], void *dst) 3370 { 3371 3372 3373 uint32_t r = 3374 _mesa_unsigned_to_unsigned(src[0], 32); 3375 3376 3377 uint32_t g = 3378 _mesa_unsigned_to_unsigned(src[1], 32); 3379 3380 3381 uint32_t b = 3382 _mesa_unsigned_to_unsigned(src[2], 32); 3383 3384 3385 uint32_t a = 3386 _mesa_unsigned_to_unsigned(src[3], 32); 3387 3388 uint32_t *d = (uint32_t *)dst; 3389 d[0] = r; 3390 d[1] = g; 3391 d[2] = b; 3392 d[3] = a; 3393 } 3394 3395 static inline void 3396 pack_ubyte_rgba_sint8(const GLubyte src[4], void *dst) 3397 { 3398 3399 3400 int8_t r = 3401 _mesa_unsigned_to_signed(src[0], 8); 3402 3403 3404 int8_t g = 3405 _mesa_unsigned_to_signed(src[1], 8); 3406 3407 3408 int8_t b = 3409 _mesa_unsigned_to_signed(src[2], 8); 3410 3411 3412 int8_t a = 3413 _mesa_unsigned_to_signed(src[3], 8); 3414 3415 int8_t *d = (int8_t *)dst; 3416 d[0] = r; 3417 d[1] = g; 3418 d[2] = b; 3419 d[3] = a; 3420 } 3421 3422 static inline void 3423 pack_ubyte_rgba_sint16(const GLubyte src[4], void *dst) 3424 { 3425 3426 3427 int16_t r = 3428 _mesa_unsigned_to_signed(src[0], 16); 3429 3430 3431 int16_t g = 3432 _mesa_unsigned_to_signed(src[1], 16); 3433 3434 3435 int16_t b = 3436 _mesa_unsigned_to_signed(src[2], 16); 3437 3438 3439 int16_t a = 3440 _mesa_unsigned_to_signed(src[3], 16); 3441 3442 int16_t *d = (int16_t *)dst; 3443 d[0] = r; 3444 d[1] = g; 3445 d[2] = b; 3446 d[3] = a; 3447 } 3448 3449 static inline void 3450 pack_ubyte_rgba_sint32(const GLubyte src[4], void *dst) 3451 { 3452 3453 3454 int32_t r = 3455 _mesa_unsigned_to_signed(src[0], 32); 3456 3457 3458 int32_t g = 3459 _mesa_unsigned_to_signed(src[1], 32); 3460 3461 3462 int32_t b = 3463 _mesa_unsigned_to_signed(src[2], 32); 3464 3465 3466 int32_t a = 3467 _mesa_unsigned_to_signed(src[3], 32); 3468 3469 int32_t *d = (int32_t *)dst; 3470 d[0] = r; 3471 d[1] = g; 3472 d[2] = b; 3473 d[3] = a; 3474 } 3475 3476 static inline void 3477 pack_ubyte_rgbx_uint8(const GLubyte src[4], void *dst) 3478 { 3479 3480 3481 uint8_t r = 3482 _mesa_unsigned_to_unsigned(src[0], 8); 3483 3484 3485 uint8_t g = 3486 _mesa_unsigned_to_unsigned(src[1], 8); 3487 3488 3489 uint8_t b = 3490 _mesa_unsigned_to_unsigned(src[2], 8); 3491 3492 3493 uint8_t *d = (uint8_t *)dst; 3494 d[0] = r; 3495 d[1] = g; 3496 d[2] = b; 3497 } 3498 3499 static inline void 3500 pack_ubyte_rgbx_uint16(const GLubyte src[4], void *dst) 3501 { 3502 3503 3504 uint16_t r = 3505 _mesa_unsigned_to_unsigned(src[0], 16); 3506 3507 3508 uint16_t g = 3509 _mesa_unsigned_to_unsigned(src[1], 16); 3510 3511 3512 uint16_t b = 3513 _mesa_unsigned_to_unsigned(src[2], 16); 3514 3515 3516 uint16_t *d = (uint16_t *)dst; 3517 d[0] = r; 3518 d[1] = g; 3519 d[2] = b; 3520 } 3521 3522 static inline void 3523 pack_ubyte_rgbx_uint32(const GLubyte src[4], void *dst) 3524 { 3525 3526 3527 uint32_t r = 3528 _mesa_unsigned_to_unsigned(src[0], 32); 3529 3530 3531 uint32_t g = 3532 _mesa_unsigned_to_unsigned(src[1], 32); 3533 3534 3535 uint32_t b = 3536 _mesa_unsigned_to_unsigned(src[2], 32); 3537 3538 3539 uint32_t *d = (uint32_t *)dst; 3540 d[0] = r; 3541 d[1] = g; 3542 d[2] = b; 3543 } 3544 3545 static inline void 3546 pack_ubyte_rgbx_sint8(const GLubyte src[4], void *dst) 3547 { 3548 3549 3550 int8_t r = 3551 _mesa_unsigned_to_signed(src[0], 8); 3552 3553 3554 int8_t g = 3555 _mesa_unsigned_to_signed(src[1], 8); 3556 3557 3558 int8_t b = 3559 _mesa_unsigned_to_signed(src[2], 8); 3560 3561 3562 int8_t *d = (int8_t *)dst; 3563 d[0] = r; 3564 d[1] = g; 3565 d[2] = b; 3566 } 3567 3568 static inline void 3569 pack_ubyte_rgbx_sint16(const GLubyte src[4], void *dst) 3570 { 3571 3572 3573 int16_t r = 3574 _mesa_unsigned_to_signed(src[0], 16); 3575 3576 3577 int16_t g = 3578 _mesa_unsigned_to_signed(src[1], 16); 3579 3580 3581 int16_t b = 3582 _mesa_unsigned_to_signed(src[2], 16); 3583 3584 3585 int16_t *d = (int16_t *)dst; 3586 d[0] = r; 3587 d[1] = g; 3588 d[2] = b; 3589 } 3590 3591 static inline void 3592 pack_ubyte_rgbx_sint32(const GLubyte src[4], void *dst) 3593 { 3594 3595 3596 int32_t r = 3597 _mesa_unsigned_to_signed(src[0], 32); 3598 3599 3600 int32_t g = 3601 _mesa_unsigned_to_signed(src[1], 32); 3602 3603 3604 int32_t b = 3605 _mesa_unsigned_to_signed(src[2], 32); 3606 3607 3608 int32_t *d = (int32_t *)dst; 3609 d[0] = r; 3610 d[1] = g; 3611 d[2] = b; 3612 } 3613 3614 static inline void 3615 pack_ubyte_r9g9b9e5_float(const GLubyte src[4], void *dst) 3616 { 3617 GLuint *d = (GLuint *) dst; 3618 GLfloat rgb[3]; 3619 rgb[0] = _mesa_unorm_to_float(src[RCOMP], 8); 3620 rgb[1] = _mesa_unorm_to_float(src[GCOMP], 8); 3621 rgb[2] = _mesa_unorm_to_float(src[BCOMP], 8); 3622 *d = float3_to_rgb9e5(rgb); 3623 } 3624 3625 static inline void 3626 pack_ubyte_r11g11b10_float(const GLubyte src[4], void *dst) 3627 { 3628 GLuint *d = (GLuint *) dst; 3629 GLfloat rgb[3]; 3630 rgb[0] = _mesa_unorm_to_float(src[RCOMP], 8); 3631 rgb[1] = _mesa_unorm_to_float(src[GCOMP], 8); 3632 rgb[2] = _mesa_unorm_to_float(src[BCOMP], 8); 3633 *d = float3_to_r11g11b10f(rgb); 3634 } 3635 3636 /* uint packing functions */ 3637 3638 3639 static inline void 3640 pack_uint_a8b8g8r8_uint(const GLuint src[4], void *dst) 3641 { 3642 3643 3644 uint8_t a = 3645 _mesa_unsigned_to_unsigned(src[3], 8); 3646 3647 3648 uint8_t b = 3649 _mesa_unsigned_to_unsigned(src[2], 8); 3650 3651 3652 uint8_t g = 3653 _mesa_unsigned_to_unsigned(src[1], 8); 3654 3655 3656 uint8_t r = 3657 _mesa_unsigned_to_unsigned(src[0], 8); 3658 3659 uint32_t d = 0; 3660 d |= PACK(a, 0, 8); 3661 d |= PACK(b, 8, 8); 3662 d |= PACK(g, 16, 8); 3663 d |= PACK(r, 24, 8); 3664 (*(uint32_t *)dst) = d; 3665 } 3666 3667 static inline void 3668 pack_uint_a8r8g8b8_uint(const GLuint src[4], void *dst) 3669 { 3670 3671 3672 uint8_t a = 3673 _mesa_unsigned_to_unsigned(src[3], 8); 3674 3675 3676 uint8_t r = 3677 _mesa_unsigned_to_unsigned(src[0], 8); 3678 3679 3680 uint8_t g = 3681 _mesa_unsigned_to_unsigned(src[1], 8); 3682 3683 3684 uint8_t b = 3685 _mesa_unsigned_to_unsigned(src[2], 8); 3686 3687 uint32_t d = 0; 3688 d |= PACK(a, 0, 8); 3689 d |= PACK(r, 8, 8); 3690 d |= PACK(g, 16, 8); 3691 d |= PACK(b, 24, 8); 3692 (*(uint32_t *)dst) = d; 3693 } 3694 3695 static inline void 3696 pack_uint_r8g8b8a8_uint(const GLuint src[4], void *dst) 3697 { 3698 3699 3700 uint8_t r = 3701 _mesa_unsigned_to_unsigned(src[0], 8); 3702 3703 3704 uint8_t g = 3705 _mesa_unsigned_to_unsigned(src[1], 8); 3706 3707 3708 uint8_t b = 3709 _mesa_unsigned_to_unsigned(src[2], 8); 3710 3711 3712 uint8_t a = 3713 _mesa_unsigned_to_unsigned(src[3], 8); 3714 3715 uint32_t d = 0; 3716 d |= PACK(r, 0, 8); 3717 d |= PACK(g, 8, 8); 3718 d |= PACK(b, 16, 8); 3719 d |= PACK(a, 24, 8); 3720 (*(uint32_t *)dst) = d; 3721 } 3722 3723 static inline void 3724 pack_uint_b8g8r8a8_uint(const GLuint src[4], void *dst) 3725 { 3726 3727 3728 uint8_t b = 3729 _mesa_unsigned_to_unsigned(src[2], 8); 3730 3731 3732 uint8_t g = 3733 _mesa_unsigned_to_unsigned(src[1], 8); 3734 3735 3736 uint8_t r = 3737 _mesa_unsigned_to_unsigned(src[0], 8); 3738 3739 3740 uint8_t a = 3741 _mesa_unsigned_to_unsigned(src[3], 8); 3742 3743 uint32_t d = 0; 3744 d |= PACK(b, 0, 8); 3745 d |= PACK(g, 8, 8); 3746 d |= PACK(r, 16, 8); 3747 d |= PACK(a, 24, 8); 3748 (*(uint32_t *)dst) = d; 3749 } 3750 3751 static inline void 3752 pack_uint_b10g10r10a2_uint(const GLuint src[4], void *dst) 3753 { 3754 3755 3756 uint16_t b = 3757 _mesa_unsigned_to_unsigned(src[2], 10); 3758 3759 3760 uint16_t g = 3761 _mesa_unsigned_to_unsigned(src[1], 10); 3762 3763 3764 uint16_t r = 3765 _mesa_unsigned_to_unsigned(src[0], 10); 3766 3767 3768 uint8_t a = 3769 _mesa_unsigned_to_unsigned(src[3], 2); 3770 3771 uint32_t d = 0; 3772 d |= PACK(b, 0, 10); 3773 d |= PACK(g, 10, 10); 3774 d |= PACK(r, 20, 10); 3775 d |= PACK(a, 30, 2); 3776 (*(uint32_t *)dst) = d; 3777 } 3778 3779 static inline void 3780 pack_uint_r10g10b10a2_uint(const GLuint src[4], void *dst) 3781 { 3782 3783 3784 uint16_t r = 3785 _mesa_unsigned_to_unsigned(src[0], 10); 3786 3787 3788 uint16_t g = 3789 _mesa_unsigned_to_unsigned(src[1], 10); 3790 3791 3792 uint16_t b = 3793 _mesa_unsigned_to_unsigned(src[2], 10); 3794 3795 3796 uint8_t a = 3797 _mesa_unsigned_to_unsigned(src[3], 2); 3798 3799 uint32_t d = 0; 3800 d |= PACK(r, 0, 10); 3801 d |= PACK(g, 10, 10); 3802 d |= PACK(b, 20, 10); 3803 d |= PACK(a, 30, 2); 3804 (*(uint32_t *)dst) = d; 3805 } 3806 3807 static inline void 3808 pack_uint_a2b10g10r10_uint(const GLuint src[4], void *dst) 3809 { 3810 3811 3812 uint8_t a = 3813 _mesa_unsigned_to_unsigned(src[3], 2); 3814 3815 3816 uint16_t b = 3817 _mesa_unsigned_to_unsigned(src[2], 10); 3818 3819 3820 uint16_t g = 3821 _mesa_unsigned_to_unsigned(src[1], 10); 3822 3823 3824 uint16_t r = 3825 _mesa_unsigned_to_unsigned(src[0], 10); 3826 3827 uint32_t d = 0; 3828 d |= PACK(a, 0, 2); 3829 d |= PACK(b, 2, 10); 3830 d |= PACK(g, 12, 10); 3831 d |= PACK(r, 22, 10); 3832 (*(uint32_t *)dst) = d; 3833 } 3834 3835 static inline void 3836 pack_uint_a2r10g10b10_uint(const GLuint src[4], void *dst) 3837 { 3838 3839 3840 uint8_t a = 3841 _mesa_unsigned_to_unsigned(src[3], 2); 3842 3843 3844 uint16_t r = 3845 _mesa_unsigned_to_unsigned(src[0], 10); 3846 3847 3848 uint16_t g = 3849 _mesa_unsigned_to_unsigned(src[1], 10); 3850 3851 3852 uint16_t b = 3853 _mesa_unsigned_to_unsigned(src[2], 10); 3854 3855 uint32_t d = 0; 3856 d |= PACK(a, 0, 2); 3857 d |= PACK(r, 2, 10); 3858 d |= PACK(g, 12, 10); 3859 d |= PACK(b, 22, 10); 3860 (*(uint32_t *)dst) = d; 3861 } 3862 3863 static inline void 3864 pack_uint_b5g6r5_uint(const GLuint src[4], void *dst) 3865 { 3866 3867 3868 uint8_t b = 3869 _mesa_unsigned_to_unsigned(src[2], 5); 3870 3871 3872 uint8_t g = 3873 _mesa_unsigned_to_unsigned(src[1], 6); 3874 3875 3876 uint8_t r = 3877 _mesa_unsigned_to_unsigned(src[0], 5); 3878 3879 uint16_t d = 0; 3880 d |= PACK(b, 0, 5); 3881 d |= PACK(g, 5, 6); 3882 d |= PACK(r, 11, 5); 3883 (*(uint16_t *)dst) = d; 3884 } 3885 3886 static inline void 3887 pack_uint_r5g6b5_uint(const GLuint src[4], void *dst) 3888 { 3889 3890 3891 uint8_t r = 3892 _mesa_unsigned_to_unsigned(src[0], 5); 3893 3894 3895 uint8_t g = 3896 _mesa_unsigned_to_unsigned(src[1], 6); 3897 3898 3899 uint8_t b = 3900 _mesa_unsigned_to_unsigned(src[2], 5); 3901 3902 uint16_t d = 0; 3903 d |= PACK(r, 0, 5); 3904 d |= PACK(g, 5, 6); 3905 d |= PACK(b, 11, 5); 3906 (*(uint16_t *)dst) = d; 3907 } 3908 3909 static inline void 3910 pack_uint_b2g3r3_uint(const GLuint src[4], void *dst) 3911 { 3912 3913 3914 uint8_t b = 3915 _mesa_unsigned_to_unsigned(src[2], 2); 3916 3917 3918 uint8_t g = 3919 _mesa_unsigned_to_unsigned(src[1], 3); 3920 3921 3922 uint8_t r = 3923 _mesa_unsigned_to_unsigned(src[0], 3); 3924 3925 uint8_t d = 0; 3926 d |= PACK(b, 0, 2); 3927 d |= PACK(g, 2, 3); 3928 d |= PACK(r, 5, 3); 3929 (*(uint8_t *)dst) = d; 3930 } 3931 3932 static inline void 3933 pack_uint_r3g3b2_uint(const GLuint src[4], void *dst) 3934 { 3935 3936 3937 uint8_t r = 3938 _mesa_unsigned_to_unsigned(src[0], 3); 3939 3940 3941 uint8_t g = 3942 _mesa_unsigned_to_unsigned(src[1], 3); 3943 3944 3945 uint8_t b = 3946 _mesa_unsigned_to_unsigned(src[2], 2); 3947 3948 uint8_t d = 0; 3949 d |= PACK(r, 0, 3); 3950 d |= PACK(g, 3, 3); 3951 d |= PACK(b, 6, 2); 3952 (*(uint8_t *)dst) = d; 3953 } 3954 3955 static inline void 3956 pack_uint_a4b4g4r4_uint(const GLuint src[4], void *dst) 3957 { 3958 3959 3960 uint8_t a = 3961 _mesa_unsigned_to_unsigned(src[3], 4); 3962 3963 3964 uint8_t b = 3965 _mesa_unsigned_to_unsigned(src[2], 4); 3966 3967 3968 uint8_t g = 3969 _mesa_unsigned_to_unsigned(src[1], 4); 3970 3971 3972 uint8_t r = 3973 _mesa_unsigned_to_unsigned(src[0], 4); 3974 3975 uint16_t d = 0; 3976 d |= PACK(a, 0, 4); 3977 d |= PACK(b, 4, 4); 3978 d |= PACK(g, 8, 4); 3979 d |= PACK(r, 12, 4); 3980 (*(uint16_t *)dst) = d; 3981 } 3982 3983 static inline void 3984 pack_uint_r4g4b4a4_uint(const GLuint src[4], void *dst) 3985 { 3986 3987 3988 uint8_t r = 3989 _mesa_unsigned_to_unsigned(src[0], 4); 3990 3991 3992 uint8_t g = 3993 _mesa_unsigned_to_unsigned(src[1], 4); 3994 3995 3996 uint8_t b = 3997 _mesa_unsigned_to_unsigned(src[2], 4); 3998 3999 4000 uint8_t a = 4001 _mesa_unsigned_to_unsigned(src[3], 4); 4002 4003 uint16_t d = 0; 4004 d |= PACK(r, 0, 4); 4005 d |= PACK(g, 4, 4); 4006 d |= PACK(b, 8, 4); 4007 d |= PACK(a, 12, 4); 4008 (*(uint16_t *)dst) = d; 4009 } 4010 4011 static inline void 4012 pack_uint_b4g4r4a4_uint(const GLuint src[4], void *dst) 4013 { 4014 4015 4016 uint8_t b = 4017 _mesa_unsigned_to_unsigned(src[2], 4); 4018 4019 4020 uint8_t g = 4021 _mesa_unsigned_to_unsigned(src[1], 4); 4022 4023 4024 uint8_t r = 4025 _mesa_unsigned_to_unsigned(src[0], 4); 4026 4027 4028 uint8_t a = 4029 _mesa_unsigned_to_unsigned(src[3], 4); 4030 4031 uint16_t d = 0; 4032 d |= PACK(b, 0, 4); 4033 d |= PACK(g, 4, 4); 4034 d |= PACK(r, 8, 4); 4035 d |= PACK(a, 12, 4); 4036 (*(uint16_t *)dst) = d; 4037 } 4038 4039 static inline void 4040 pack_uint_a4r4g4b4_uint(const GLuint src[4], void *dst) 4041 { 4042 4043 4044 uint8_t a = 4045 _mesa_unsigned_to_unsigned(src[3], 4); 4046 4047 4048 uint8_t r = 4049 _mesa_unsigned_to_unsigned(src[0], 4); 4050 4051 4052 uint8_t g = 4053 _mesa_unsigned_to_unsigned(src[1], 4); 4054 4055 4056 uint8_t b = 4057 _mesa_unsigned_to_unsigned(src[2], 4); 4058 4059 uint16_t d = 0; 4060 d |= PACK(a, 0, 4); 4061 d |= PACK(r, 4, 4); 4062 d |= PACK(g, 8, 4); 4063 d |= PACK(b, 12, 4); 4064 (*(uint16_t *)dst) = d; 4065 } 4066 4067 static inline void 4068 pack_uint_a1b5g5r5_uint(const GLuint src[4], void *dst) 4069 { 4070 4071 4072 uint8_t a = 4073 _mesa_unsigned_to_unsigned(src[3], 1); 4074 4075 4076 uint8_t b = 4077 _mesa_unsigned_to_unsigned(src[2], 5); 4078 4079 4080 uint8_t g = 4081 _mesa_unsigned_to_unsigned(src[1], 5); 4082 4083 4084 uint8_t r = 4085 _mesa_unsigned_to_unsigned(src[0], 5); 4086 4087 uint16_t d = 0; 4088 d |= PACK(a, 0, 1); 4089 d |= PACK(b, 1, 5); 4090 d |= PACK(g, 6, 5); 4091 d |= PACK(r, 11, 5); 4092 (*(uint16_t *)dst) = d; 4093 } 4094 4095 static inline void 4096 pack_uint_b5g5r5a1_uint(const GLuint src[4], void *dst) 4097 { 4098 4099 4100 uint8_t b = 4101 _mesa_unsigned_to_unsigned(src[2], 5); 4102 4103 4104 uint8_t g = 4105 _mesa_unsigned_to_unsigned(src[1], 5); 4106 4107 4108 uint8_t r = 4109 _mesa_unsigned_to_unsigned(src[0], 5); 4110 4111 4112 uint8_t a = 4113 _mesa_unsigned_to_unsigned(src[3], 1); 4114 4115 uint16_t d = 0; 4116 d |= PACK(b, 0, 5); 4117 d |= PACK(g, 5, 5); 4118 d |= PACK(r, 10, 5); 4119 d |= PACK(a, 15, 1); 4120 (*(uint16_t *)dst) = d; 4121 } 4122 4123 static inline void 4124 pack_uint_a1r5g5b5_uint(const GLuint src[4], void *dst) 4125 { 4126 4127 4128 uint8_t a = 4129 _mesa_unsigned_to_unsigned(src[3], 1); 4130 4131 4132 uint8_t r = 4133 _mesa_unsigned_to_unsigned(src[0], 5); 4134 4135 4136 uint8_t g = 4137 _mesa_unsigned_to_unsigned(src[1], 5); 4138 4139 4140 uint8_t b = 4141 _mesa_unsigned_to_unsigned(src[2], 5); 4142 4143 uint16_t d = 0; 4144 d |= PACK(a, 0, 1); 4145 d |= PACK(r, 1, 5); 4146 d |= PACK(g, 6, 5); 4147 d |= PACK(b, 11, 5); 4148 (*(uint16_t *)dst) = d; 4149 } 4150 4151 static inline void 4152 pack_uint_r5g5b5a1_uint(const GLuint src[4], void *dst) 4153 { 4154 4155 4156 uint8_t r = 4157 _mesa_unsigned_to_unsigned(src[0], 5); 4158 4159 4160 uint8_t g = 4161 _mesa_unsigned_to_unsigned(src[1], 5); 4162 4163 4164 uint8_t b = 4165 _mesa_unsigned_to_unsigned(src[2], 5); 4166 4167 4168 uint8_t a = 4169 _mesa_unsigned_to_unsigned(src[3], 1); 4170 4171 uint16_t d = 0; 4172 d |= PACK(r, 0, 5); 4173 d |= PACK(g, 5, 5); 4174 d |= PACK(b, 10, 5); 4175 d |= PACK(a, 15, 1); 4176 (*(uint16_t *)dst) = d; 4177 } 4178 4179 static inline void 4180 pack_uint_a_uint8(const GLuint src[4], void *dst) 4181 { 4182 4183 4184 uint8_t a = 4185 _mesa_unsigned_to_unsigned(src[3], 8); 4186 4187 uint8_t *d = (uint8_t *)dst; 4188 d[0] = a; 4189 } 4190 4191 static inline void 4192 pack_uint_a_uint16(const GLuint src[4], void *dst) 4193 { 4194 4195 4196 uint16_t a = 4197 _mesa_unsigned_to_unsigned(src[3], 16); 4198 4199 uint16_t *d = (uint16_t *)dst; 4200 d[0] = a; 4201 } 4202 4203 static inline void 4204 pack_uint_a_uint32(const GLuint src[4], void *dst) 4205 { 4206 4207 4208 uint32_t a = 4209 _mesa_unsigned_to_unsigned(src[3], 32); 4210 4211 uint32_t *d = (uint32_t *)dst; 4212 d[0] = a; 4213 } 4214 4215 static inline void 4216 pack_uint_a_sint8(const GLuint src[4], void *dst) 4217 { 4218 4219 4220 int8_t a = 4221 _mesa_signed_to_signed(src[3], 8); 4222 4223 int8_t *d = (int8_t *)dst; 4224 d[0] = a; 4225 } 4226 4227 static inline void 4228 pack_uint_a_sint16(const GLuint src[4], void *dst) 4229 { 4230 4231 4232 int16_t a = 4233 _mesa_signed_to_signed(src[3], 16); 4234 4235 int16_t *d = (int16_t *)dst; 4236 d[0] = a; 4237 } 4238 4239 static inline void 4240 pack_uint_a_sint32(const GLuint src[4], void *dst) 4241 { 4242 4243 4244 int32_t a = 4245 _mesa_signed_to_signed(src[3], 32); 4246 4247 int32_t *d = (int32_t *)dst; 4248 d[0] = a; 4249 } 4250 4251 static inline void 4252 pack_uint_i_uint8(const GLuint src[4], void *dst) 4253 { 4254 4255 4256 uint8_t i = 4257 _mesa_unsigned_to_unsigned(src[0], 8); 4258 4259 uint8_t *d = (uint8_t *)dst; 4260 d[0] = i; 4261 } 4262 4263 static inline void 4264 pack_uint_i_uint16(const GLuint src[4], void *dst) 4265 { 4266 4267 4268 uint16_t i = 4269 _mesa_unsigned_to_unsigned(src[0], 16); 4270 4271 uint16_t *d = (uint16_t *)dst; 4272 d[0] = i; 4273 } 4274 4275 static inline void 4276 pack_uint_i_uint32(const GLuint src[4], void *dst) 4277 { 4278 4279 4280 uint32_t i = 4281 _mesa_unsigned_to_unsigned(src[0], 32); 4282 4283 uint32_t *d = (uint32_t *)dst; 4284 d[0] = i; 4285 } 4286 4287 static inline void 4288 pack_uint_i_sint8(const GLuint src[4], void *dst) 4289 { 4290 4291 4292 int8_t i = 4293 _mesa_signed_to_signed(src[0], 8); 4294 4295 int8_t *d = (int8_t *)dst; 4296 d[0] = i; 4297 } 4298 4299 static inline void 4300 pack_uint_i_sint16(const GLuint src[4], void *dst) 4301 { 4302 4303 4304 int16_t i = 4305 _mesa_signed_to_signed(src[0], 16); 4306 4307 int16_t *d = (int16_t *)dst; 4308 d[0] = i; 4309 } 4310 4311 static inline void 4312 pack_uint_i_sint32(const GLuint src[4], void *dst) 4313 { 4314 4315 4316 int32_t i = 4317 _mesa_signed_to_signed(src[0], 32); 4318 4319 int32_t *d = (int32_t *)dst; 4320 d[0] = i; 4321 } 4322 4323 static inline void 4324 pack_uint_l_uint8(const GLuint src[4], void *dst) 4325 { 4326 4327 4328 uint8_t l = 4329 _mesa_unsigned_to_unsigned(src[0], 8); 4330 4331 uint8_t *d = (uint8_t *)dst; 4332 d[0] = l; 4333 } 4334 4335 static inline void 4336 pack_uint_l_uint16(const GLuint src[4], void *dst) 4337 { 4338 4339 4340 uint16_t l = 4341 _mesa_unsigned_to_unsigned(src[0], 16); 4342 4343 uint16_t *d = (uint16_t *)dst; 4344 d[0] = l; 4345 } 4346 4347 static inline void 4348 pack_uint_l_uint32(const GLuint src[4], void *dst) 4349 { 4350 4351 4352 uint32_t l = 4353 _mesa_unsigned_to_unsigned(src[0], 32); 4354 4355 uint32_t *d = (uint32_t *)dst; 4356 d[0] = l; 4357 } 4358 4359 static inline void 4360 pack_uint_l_sint8(const GLuint src[4], void *dst) 4361 { 4362 4363 4364 int8_t l = 4365 _mesa_signed_to_signed(src[0], 8); 4366 4367 int8_t *d = (int8_t *)dst; 4368 d[0] = l; 4369 } 4370 4371 static inline void 4372 pack_uint_l_sint16(const GLuint src[4], void *dst) 4373 { 4374 4375 4376 int16_t l = 4377 _mesa_signed_to_signed(src[0], 16); 4378 4379 int16_t *d = (int16_t *)dst; 4380 d[0] = l; 4381 } 4382 4383 static inline void 4384 pack_uint_l_sint32(const GLuint src[4], void *dst) 4385 { 4386 4387 4388 int32_t l = 4389 _mesa_signed_to_signed(src[0], 32); 4390 4391 int32_t *d = (int32_t *)dst; 4392 d[0] = l; 4393 } 4394 4395 static inline void 4396 pack_uint_la_uint8(const GLuint src[4], void *dst) 4397 { 4398 4399 4400 uint8_t l = 4401 _mesa_unsigned_to_unsigned(src[0], 8); 4402 4403 4404 uint8_t a = 4405 _mesa_unsigned_to_unsigned(src[3], 8); 4406 4407 uint8_t *d = (uint8_t *)dst; 4408 d[0] = l; 4409 d[1] = a; 4410 } 4411 4412 static inline void 4413 pack_uint_la_uint16(const GLuint src[4], void *dst) 4414 { 4415 4416 4417 uint16_t l = 4418 _mesa_unsigned_to_unsigned(src[0], 16); 4419 4420 4421 uint16_t a = 4422 _mesa_unsigned_to_unsigned(src[3], 16); 4423 4424 uint16_t *d = (uint16_t *)dst; 4425 d[0] = l; 4426 d[1] = a; 4427 } 4428 4429 static inline void 4430 pack_uint_la_uint32(const GLuint src[4], void *dst) 4431 { 4432 4433 4434 uint32_t l = 4435 _mesa_unsigned_to_unsigned(src[0], 32); 4436 4437 4438 uint32_t a = 4439 _mesa_unsigned_to_unsigned(src[3], 32); 4440 4441 uint32_t *d = (uint32_t *)dst; 4442 d[0] = l; 4443 d[1] = a; 4444 } 4445 4446 static inline void 4447 pack_uint_la_sint8(const GLuint src[4], void *dst) 4448 { 4449 4450 4451 int8_t l = 4452 _mesa_signed_to_signed(src[0], 8); 4453 4454 4455 int8_t a = 4456 _mesa_signed_to_signed(src[3], 8); 4457 4458 int8_t *d = (int8_t *)dst; 4459 d[0] = l; 4460 d[1] = a; 4461 } 4462 4463 static inline void 4464 pack_uint_la_sint16(const GLuint src[4], void *dst) 4465 { 4466 4467 4468 int16_t l = 4469 _mesa_signed_to_signed(src[0], 16); 4470 4471 4472 int16_t a = 4473 _mesa_signed_to_signed(src[3], 16); 4474 4475 int16_t *d = (int16_t *)dst; 4476 d[0] = l; 4477 d[1] = a; 4478 } 4479 4480 static inline void 4481 pack_uint_la_sint32(const GLuint src[4], void *dst) 4482 { 4483 4484 4485 int32_t l = 4486 _mesa_signed_to_signed(src[0], 32); 4487 4488 4489 int32_t a = 4490 _mesa_signed_to_signed(src[3], 32); 4491 4492 int32_t *d = (int32_t *)dst; 4493 d[0] = l; 4494 d[1] = a; 4495 } 4496 4497 static inline void 4498 pack_uint_r_uint8(const GLuint src[4], void *dst) 4499 { 4500 4501 4502 uint8_t r = 4503 _mesa_unsigned_to_unsigned(src[0], 8); 4504 4505 uint8_t *d = (uint8_t *)dst; 4506 d[0] = r; 4507 } 4508 4509 static inline void 4510 pack_uint_r_uint16(const GLuint src[4], void *dst) 4511 { 4512 4513 4514 uint16_t r = 4515 _mesa_unsigned_to_unsigned(src[0], 16); 4516 4517 uint16_t *d = (uint16_t *)dst; 4518 d[0] = r; 4519 } 4520 4521 static inline void 4522 pack_uint_r_uint32(const GLuint src[4], void *dst) 4523 { 4524 4525 4526 uint32_t r = 4527 _mesa_unsigned_to_unsigned(src[0], 32); 4528 4529 uint32_t *d = (uint32_t *)dst; 4530 d[0] = r; 4531 } 4532 4533 static inline void 4534 pack_uint_r_sint8(const GLuint src[4], void *dst) 4535 { 4536 4537 4538 int8_t r = 4539 _mesa_signed_to_signed(src[0], 8); 4540 4541 int8_t *d = (int8_t *)dst; 4542 d[0] = r; 4543 } 4544 4545 static inline void 4546 pack_uint_r_sint16(const GLuint src[4], void *dst) 4547 { 4548 4549 4550 int16_t r = 4551 _mesa_signed_to_signed(src[0], 16); 4552 4553 int16_t *d = (int16_t *)dst; 4554 d[0] = r; 4555 } 4556 4557 static inline void 4558 pack_uint_r_sint32(const GLuint src[4], void *dst) 4559 { 4560 4561 4562 int32_t r = 4563 _mesa_signed_to_signed(src[0], 32); 4564 4565 int32_t *d = (int32_t *)dst; 4566 d[0] = r; 4567 } 4568 4569 static inline void 4570 pack_uint_rg_uint8(const GLuint src[4], void *dst) 4571 { 4572 4573 4574 uint8_t r = 4575 _mesa_unsigned_to_unsigned(src[0], 8); 4576 4577 4578 uint8_t g = 4579 _mesa_unsigned_to_unsigned(src[1], 8); 4580 4581 uint8_t *d = (uint8_t *)dst; 4582 d[0] = r; 4583 d[1] = g; 4584 } 4585 4586 static inline void 4587 pack_uint_rg_uint16(const GLuint src[4], void *dst) 4588 { 4589 4590 4591 uint16_t r = 4592 _mesa_unsigned_to_unsigned(src[0], 16); 4593 4594 4595 uint16_t g = 4596 _mesa_unsigned_to_unsigned(src[1], 16); 4597 4598 uint16_t *d = (uint16_t *)dst; 4599 d[0] = r; 4600 d[1] = g; 4601 } 4602 4603 static inline void 4604 pack_uint_rg_uint32(const GLuint src[4], void *dst) 4605 { 4606 4607 4608 uint32_t r = 4609 _mesa_unsigned_to_unsigned(src[0], 32); 4610 4611 4612 uint32_t g = 4613 _mesa_unsigned_to_unsigned(src[1], 32); 4614 4615 uint32_t *d = (uint32_t *)dst; 4616 d[0] = r; 4617 d[1] = g; 4618 } 4619 4620 static inline void 4621 pack_uint_rg_sint8(const GLuint src[4], void *dst) 4622 { 4623 4624 4625 int8_t r = 4626 _mesa_signed_to_signed(src[0], 8); 4627 4628 4629 int8_t g = 4630 _mesa_signed_to_signed(src[1], 8); 4631 4632 int8_t *d = (int8_t *)dst; 4633 d[0] = r; 4634 d[1] = g; 4635 } 4636 4637 static inline void 4638 pack_uint_rg_sint16(const GLuint src[4], void *dst) 4639 { 4640 4641 4642 int16_t r = 4643 _mesa_signed_to_signed(src[0], 16); 4644 4645 4646 int16_t g = 4647 _mesa_signed_to_signed(src[1], 16); 4648 4649 int16_t *d = (int16_t *)dst; 4650 d[0] = r; 4651 d[1] = g; 4652 } 4653 4654 static inline void 4655 pack_uint_rg_sint32(const GLuint src[4], void *dst) 4656 { 4657 4658 4659 int32_t r = 4660 _mesa_signed_to_signed(src[0], 32); 4661 4662 4663 int32_t g = 4664 _mesa_signed_to_signed(src[1], 32); 4665 4666 int32_t *d = (int32_t *)dst; 4667 d[0] = r; 4668 d[1] = g; 4669 } 4670 4671 static inline void 4672 pack_uint_rgb_uint8(const GLuint src[4], void *dst) 4673 { 4674 4675 4676 uint8_t r = 4677 _mesa_unsigned_to_unsigned(src[0], 8); 4678 4679 4680 uint8_t g = 4681 _mesa_unsigned_to_unsigned(src[1], 8); 4682 4683 4684 uint8_t b = 4685 _mesa_unsigned_to_unsigned(src[2], 8); 4686 4687 uint8_t *d = (uint8_t *)dst; 4688 d[0] = r; 4689 d[1] = g; 4690 d[2] = b; 4691 } 4692 4693 static inline void 4694 pack_uint_rgb_uint16(const GLuint src[4], void *dst) 4695 { 4696 4697 4698 uint16_t r = 4699 _mesa_unsigned_to_unsigned(src[0], 16); 4700 4701 4702 uint16_t g = 4703 _mesa_unsigned_to_unsigned(src[1], 16); 4704 4705 4706 uint16_t b = 4707 _mesa_unsigned_to_unsigned(src[2], 16); 4708 4709 uint16_t *d = (uint16_t *)dst; 4710 d[0] = r; 4711 d[1] = g; 4712 d[2] = b; 4713 } 4714 4715 static inline void 4716 pack_uint_rgb_uint32(const GLuint src[4], void *dst) 4717 { 4718 4719 4720 uint32_t r = 4721 _mesa_unsigned_to_unsigned(src[0], 32); 4722 4723 4724 uint32_t g = 4725 _mesa_unsigned_to_unsigned(src[1], 32); 4726 4727 4728 uint32_t b = 4729 _mesa_unsigned_to_unsigned(src[2], 32); 4730 4731 uint32_t *d = (uint32_t *)dst; 4732 d[0] = r; 4733 d[1] = g; 4734 d[2] = b; 4735 } 4736 4737 static inline void 4738 pack_uint_rgb_sint8(const GLuint src[4], void *dst) 4739 { 4740 4741 4742 int8_t r = 4743 _mesa_signed_to_signed(src[0], 8); 4744 4745 4746 int8_t g = 4747 _mesa_signed_to_signed(src[1], 8); 4748 4749 4750 int8_t b = 4751 _mesa_signed_to_signed(src[2], 8); 4752 4753 int8_t *d = (int8_t *)dst; 4754 d[0] = r; 4755 d[1] = g; 4756 d[2] = b; 4757 } 4758 4759 static inline void 4760 pack_uint_rgb_sint16(const GLuint src[4], void *dst) 4761 { 4762 4763 4764 int16_t r = 4765 _mesa_signed_to_signed(src[0], 16); 4766 4767 4768 int16_t g = 4769 _mesa_signed_to_signed(src[1], 16); 4770 4771 4772 int16_t b = 4773 _mesa_signed_to_signed(src[2], 16); 4774 4775 int16_t *d = (int16_t *)dst; 4776 d[0] = r; 4777 d[1] = g; 4778 d[2] = b; 4779 } 4780 4781 static inline void 4782 pack_uint_rgb_sint32(const GLuint src[4], void *dst) 4783 { 4784 4785 4786 int32_t r = 4787 _mesa_signed_to_signed(src[0], 32); 4788 4789 4790 int32_t g = 4791 _mesa_signed_to_signed(src[1], 32); 4792 4793 4794 int32_t b = 4795 _mesa_signed_to_signed(src[2], 32); 4796 4797 int32_t *d = (int32_t *)dst; 4798 d[0] = r; 4799 d[1] = g; 4800 d[2] = b; 4801 } 4802 4803 static inline void 4804 pack_uint_rgba_uint8(const GLuint src[4], void *dst) 4805 { 4806 4807 4808 uint8_t r = 4809 _mesa_unsigned_to_unsigned(src[0], 8); 4810 4811 4812 uint8_t g = 4813 _mesa_unsigned_to_unsigned(src[1], 8); 4814 4815 4816 uint8_t b = 4817 _mesa_unsigned_to_unsigned(src[2], 8); 4818 4819 4820 uint8_t a = 4821 _mesa_unsigned_to_unsigned(src[3], 8); 4822 4823 uint8_t *d = (uint8_t *)dst; 4824 d[0] = r; 4825 d[1] = g; 4826 d[2] = b; 4827 d[3] = a; 4828 } 4829 4830 static inline void 4831 pack_uint_rgba_uint16(const GLuint src[4], void *dst) 4832 { 4833 4834 4835 uint16_t r = 4836 _mesa_unsigned_to_unsigned(src[0], 16); 4837 4838 4839 uint16_t g = 4840 _mesa_unsigned_to_unsigned(src[1], 16); 4841 4842 4843 uint16_t b = 4844 _mesa_unsigned_to_unsigned(src[2], 16); 4845 4846 4847 uint16_t a = 4848 _mesa_unsigned_to_unsigned(src[3], 16); 4849 4850 uint16_t *d = (uint16_t *)dst; 4851 d[0] = r; 4852 d[1] = g; 4853 d[2] = b; 4854 d[3] = a; 4855 } 4856 4857 static inline void 4858 pack_uint_rgba_uint32(const GLuint src[4], void *dst) 4859 { 4860 4861 4862 uint32_t r = 4863 _mesa_unsigned_to_unsigned(src[0], 32); 4864 4865 4866 uint32_t g = 4867 _mesa_unsigned_to_unsigned(src[1], 32); 4868 4869 4870 uint32_t b = 4871 _mesa_unsigned_to_unsigned(src[2], 32); 4872 4873 4874 uint32_t a = 4875 _mesa_unsigned_to_unsigned(src[3], 32); 4876 4877 uint32_t *d = (uint32_t *)dst; 4878 d[0] = r; 4879 d[1] = g; 4880 d[2] = b; 4881 d[3] = a; 4882 } 4883 4884 static inline void 4885 pack_uint_rgba_sint8(const GLuint src[4], void *dst) 4886 { 4887 4888 4889 int8_t r = 4890 _mesa_signed_to_signed(src[0], 8); 4891 4892 4893 int8_t g = 4894 _mesa_signed_to_signed(src[1], 8); 4895 4896 4897 int8_t b = 4898 _mesa_signed_to_signed(src[2], 8); 4899 4900 4901 int8_t a = 4902 _mesa_signed_to_signed(src[3], 8); 4903 4904 int8_t *d = (int8_t *)dst; 4905 d[0] = r; 4906 d[1] = g; 4907 d[2] = b; 4908 d[3] = a; 4909 } 4910 4911 static inline void 4912 pack_uint_rgba_sint16(const GLuint src[4], void *dst) 4913 { 4914 4915 4916 int16_t r = 4917 _mesa_signed_to_signed(src[0], 16); 4918 4919 4920 int16_t g = 4921 _mesa_signed_to_signed(src[1], 16); 4922 4923 4924 int16_t b = 4925 _mesa_signed_to_signed(src[2], 16); 4926 4927 4928 int16_t a = 4929 _mesa_signed_to_signed(src[3], 16); 4930 4931 int16_t *d = (int16_t *)dst; 4932 d[0] = r; 4933 d[1] = g; 4934 d[2] = b; 4935 d[3] = a; 4936 } 4937 4938 static inline void 4939 pack_uint_rgba_sint32(const GLuint src[4], void *dst) 4940 { 4941 4942 4943 int32_t r = 4944 _mesa_signed_to_signed(src[0], 32); 4945 4946 4947 int32_t g = 4948 _mesa_signed_to_signed(src[1], 32); 4949 4950 4951 int32_t b = 4952 _mesa_signed_to_signed(src[2], 32); 4953 4954 4955 int32_t a = 4956 _mesa_signed_to_signed(src[3], 32); 4957 4958 int32_t *d = (int32_t *)dst; 4959 d[0] = r; 4960 d[1] = g; 4961 d[2] = b; 4962 d[3] = a; 4963 } 4964 4965 static inline void 4966 pack_uint_rgbx_uint8(const GLuint src[4], void *dst) 4967 { 4968 4969 4970 uint8_t r = 4971 _mesa_unsigned_to_unsigned(src[0], 8); 4972 4973 4974 uint8_t g = 4975 _mesa_unsigned_to_unsigned(src[1], 8); 4976 4977 4978 uint8_t b = 4979 _mesa_unsigned_to_unsigned(src[2], 8); 4980 4981 4982 uint8_t *d = (uint8_t *)dst; 4983 d[0] = r; 4984 d[1] = g; 4985 d[2] = b; 4986 } 4987 4988 static inline void 4989 pack_uint_rgbx_uint16(const GLuint src[4], void *dst) 4990 { 4991 4992 4993 uint16_t r = 4994 _mesa_unsigned_to_unsigned(src[0], 16); 4995 4996 4997 uint16_t g = 4998 _mesa_unsigned_to_unsigned(src[1], 16); 4999 5000 5001 uint16_t b = 5002 _mesa_unsigned_to_unsigned(src[2], 16); 5003 5004 5005 uint16_t *d = (uint16_t *)dst; 5006 d[0] = r; 5007 d[1] = g; 5008 d[2] = b; 5009 } 5010 5011 static inline void 5012 pack_uint_rgbx_uint32(const GLuint src[4], void *dst) 5013 { 5014 5015 5016 uint32_t r = 5017 _mesa_unsigned_to_unsigned(src[0], 32); 5018 5019 5020 uint32_t g = 5021 _mesa_unsigned_to_unsigned(src[1], 32); 5022 5023 5024 uint32_t b = 5025 _mesa_unsigned_to_unsigned(src[2], 32); 5026 5027 5028 uint32_t *d = (uint32_t *)dst; 5029 d[0] = r; 5030 d[1] = g; 5031 d[2] = b; 5032 } 5033 5034 static inline void 5035 pack_uint_rgbx_sint8(const GLuint src[4], void *dst) 5036 { 5037 5038 5039 int8_t r = 5040 _mesa_signed_to_signed(src[0], 8); 5041 5042 5043 int8_t g = 5044 _mesa_signed_to_signed(src[1], 8); 5045 5046 5047 int8_t b = 5048 _mesa_signed_to_signed(src[2], 8); 5049 5050 5051 int8_t *d = (int8_t *)dst; 5052 d[0] = r; 5053 d[1] = g; 5054 d[2] = b; 5055 } 5056 5057 static inline void 5058 pack_uint_rgbx_sint16(const GLuint src[4], void *dst) 5059 { 5060 5061 5062 int16_t r = 5063 _mesa_signed_to_signed(src[0], 16); 5064 5065 5066 int16_t g = 5067 _mesa_signed_to_signed(src[1], 16); 5068 5069 5070 int16_t b = 5071 _mesa_signed_to_signed(src[2], 16); 5072 5073 5074 int16_t *d = (int16_t *)dst; 5075 d[0] = r; 5076 d[1] = g; 5077 d[2] = b; 5078 } 5079 5080 static inline void 5081 pack_uint_rgbx_sint32(const GLuint src[4], void *dst) 5082 { 5083 5084 5085 int32_t r = 5086 _mesa_signed_to_signed(src[0], 32); 5087 5088 5089 int32_t g = 5090 _mesa_signed_to_signed(src[1], 32); 5091 5092 5093 int32_t b = 5094 _mesa_signed_to_signed(src[2], 32); 5095 5096 5097 int32_t *d = (int32_t *)dst; 5098 d[0] = r; 5099 d[1] = g; 5100 d[2] = b; 5101 } 5102 5103 /* float packing functions */ 5104 5105 5106 static inline void 5107 pack_float_a8b8g8r8_unorm(const GLfloat src[4], void *dst) 5108 { 5109 5110 5111 uint8_t a = 5112 _mesa_float_to_unorm(src[3], 8); 5113 5114 5115 uint8_t b = 5116 _mesa_float_to_unorm(src[2], 8); 5117 5118 5119 uint8_t g = 5120 _mesa_float_to_unorm(src[1], 8); 5121 5122 5123 uint8_t r = 5124 _mesa_float_to_unorm(src[0], 8); 5125 5126 uint32_t d = 0; 5127 d |= PACK(a, 0, 8); 5128 d |= PACK(b, 8, 8); 5129 d |= PACK(g, 16, 8); 5130 d |= PACK(r, 24, 8); 5131 (*(uint32_t *)dst) = d; 5132 } 5133 5134 static inline void 5135 pack_float_x8b8g8r8_unorm(const GLfloat src[4], void *dst) 5136 { 5137 5138 5139 5140 uint8_t b = 5141 _mesa_float_to_unorm(src[2], 8); 5142 5143 5144 uint8_t g = 5145 _mesa_float_to_unorm(src[1], 8); 5146 5147 5148 uint8_t r = 5149 _mesa_float_to_unorm(src[0], 8); 5150 5151 uint32_t d = 0; 5152 d |= PACK(b, 8, 8); 5153 d |= PACK(g, 16, 8); 5154 d |= PACK(r, 24, 8); 5155 (*(uint32_t *)dst) = d; 5156 } 5157 5158 static inline void 5159 pack_float_r8g8b8a8_unorm(const GLfloat src[4], void *dst) 5160 { 5161 5162 5163 uint8_t r = 5164 _mesa_float_to_unorm(src[0], 8); 5165 5166 5167 uint8_t g = 5168 _mesa_float_to_unorm(src[1], 8); 5169 5170 5171 uint8_t b = 5172 _mesa_float_to_unorm(src[2], 8); 5173 5174 5175 uint8_t a = 5176 _mesa_float_to_unorm(src[3], 8); 5177 5178 uint32_t d = 0; 5179 d |= PACK(r, 0, 8); 5180 d |= PACK(g, 8, 8); 5181 d |= PACK(b, 16, 8); 5182 d |= PACK(a, 24, 8); 5183 (*(uint32_t *)dst) = d; 5184 } 5185 5186 static inline void 5187 pack_float_r8g8b8x8_unorm(const GLfloat src[4], void *dst) 5188 { 5189 5190 5191 uint8_t r = 5192 _mesa_float_to_unorm(src[0], 8); 5193 5194 5195 uint8_t g = 5196 _mesa_float_to_unorm(src[1], 8); 5197 5198 5199 uint8_t b = 5200 _mesa_float_to_unorm(src[2], 8); 5201 5202 5203 uint32_t d = 0; 5204 d |= PACK(r, 0, 8); 5205 d |= PACK(g, 8, 8); 5206 d |= PACK(b, 16, 8); 5207 (*(uint32_t *)dst) = d; 5208 } 5209 5210 static inline void 5211 pack_float_b8g8r8a8_unorm(const GLfloat src[4], void *dst) 5212 { 5213 5214 5215 uint8_t b = 5216 _mesa_float_to_unorm(src[2], 8); 5217 5218 5219 uint8_t g = 5220 _mesa_float_to_unorm(src[1], 8); 5221 5222 5223 uint8_t r = 5224 _mesa_float_to_unorm(src[0], 8); 5225 5226 5227 uint8_t a = 5228 _mesa_float_to_unorm(src[3], 8); 5229 5230 uint32_t d = 0; 5231 d |= PACK(b, 0, 8); 5232 d |= PACK(g, 8, 8); 5233 d |= PACK(r, 16, 8); 5234 d |= PACK(a, 24, 8); 5235 (*(uint32_t *)dst) = d; 5236 } 5237 5238 static inline void 5239 pack_float_b8g8r8x8_unorm(const GLfloat src[4], void *dst) 5240 { 5241 5242 5243 uint8_t b = 5244 _mesa_float_to_unorm(src[2], 8); 5245 5246 5247 uint8_t g = 5248 _mesa_float_to_unorm(src[1], 8); 5249 5250 5251 uint8_t r = 5252 _mesa_float_to_unorm(src[0], 8); 5253 5254 5255 uint32_t d = 0; 5256 d |= PACK(b, 0, 8); 5257 d |= PACK(g, 8, 8); 5258 d |= PACK(r, 16, 8); 5259 (*(uint32_t *)dst) = d; 5260 } 5261 5262 static inline void 5263 pack_float_a8r8g8b8_unorm(const GLfloat src[4], void *dst) 5264 { 5265 5266 5267 uint8_t a = 5268 _mesa_float_to_unorm(src[3], 8); 5269 5270 5271 uint8_t r = 5272 _mesa_float_to_unorm(src[0], 8); 5273 5274 5275 uint8_t g = 5276 _mesa_float_to_unorm(src[1], 8); 5277 5278 5279 uint8_t b = 5280 _mesa_float_to_unorm(src[2], 8); 5281 5282 uint32_t d = 0; 5283 d |= PACK(a, 0, 8); 5284 d |= PACK(r, 8, 8); 5285 d |= PACK(g, 16, 8); 5286 d |= PACK(b, 24, 8); 5287 (*(uint32_t *)dst) = d; 5288 } 5289 5290 static inline void 5291 pack_float_x8r8g8b8_unorm(const GLfloat src[4], void *dst) 5292 { 5293 5294 5295 5296 uint8_t r = 5297 _mesa_float_to_unorm(src[0], 8); 5298 5299 5300 uint8_t g = 5301 _mesa_float_to_unorm(src[1], 8); 5302 5303 5304 uint8_t b = 5305 _mesa_float_to_unorm(src[2], 8); 5306 5307 uint32_t d = 0; 5308 d |= PACK(r, 8, 8); 5309 d |= PACK(g, 16, 8); 5310 d |= PACK(b, 24, 8); 5311 (*(uint32_t *)dst) = d; 5312 } 5313 5314 static inline void 5315 pack_float_l16a16_unorm(const GLfloat src[4], void *dst) 5316 { 5317 5318 5319 uint16_t l = 5320 _mesa_float_to_unorm(src[0], 16); 5321 5322 5323 uint16_t a = 5324 _mesa_float_to_unorm(src[3], 16); 5325 5326 uint32_t d = 0; 5327 d |= PACK(l, 0, 16); 5328 d |= PACK(a, 16, 16); 5329 (*(uint32_t *)dst) = d; 5330 } 5331 5332 static inline void 5333 pack_float_a16l16_unorm(const GLfloat src[4], void *dst) 5334 { 5335 5336 5337 uint16_t a = 5338 _mesa_float_to_unorm(src[3], 16); 5339 5340 5341 uint16_t l = 5342 _mesa_float_to_unorm(src[0], 16); 5343 5344 uint32_t d = 0; 5345 d |= PACK(a, 0, 16); 5346 d |= PACK(l, 16, 16); 5347 (*(uint32_t *)dst) = d; 5348 } 5349 5350 static inline void 5351 pack_float_b5g6r5_unorm(const GLfloat src[4], void *dst) 5352 { 5353 5354 5355 uint8_t b = 5356 _mesa_float_to_unorm(src[2], 5); 5357 5358 5359 uint8_t g = 5360 _mesa_float_to_unorm(src[1], 6); 5361 5362 5363 uint8_t r = 5364 _mesa_float_to_unorm(src[0], 5); 5365 5366 uint16_t d = 0; 5367 d |= PACK(b, 0, 5); 5368 d |= PACK(g, 5, 6); 5369 d |= PACK(r, 11, 5); 5370 (*(uint16_t *)dst) = d; 5371 } 5372 5373 static inline void 5374 pack_float_r5g6b5_unorm(const GLfloat src[4], void *dst) 5375 { 5376 5377 5378 uint8_t r = 5379 _mesa_float_to_unorm(src[0], 5); 5380 5381 5382 uint8_t g = 5383 _mesa_float_to_unorm(src[1], 6); 5384 5385 5386 uint8_t b = 5387 _mesa_float_to_unorm(src[2], 5); 5388 5389 uint16_t d = 0; 5390 d |= PACK(r, 0, 5); 5391 d |= PACK(g, 5, 6); 5392 d |= PACK(b, 11, 5); 5393 (*(uint16_t *)dst) = d; 5394 } 5395 5396 static inline void 5397 pack_float_b4g4r4a4_unorm(const GLfloat src[4], void *dst) 5398 { 5399 5400 5401 uint8_t b = 5402 _mesa_float_to_unorm(src[2], 4); 5403 5404 5405 uint8_t g = 5406 _mesa_float_to_unorm(src[1], 4); 5407 5408 5409 uint8_t r = 5410 _mesa_float_to_unorm(src[0], 4); 5411 5412 5413 uint8_t a = 5414 _mesa_float_to_unorm(src[3], 4); 5415 5416 uint16_t d = 0; 5417 d |= PACK(b, 0, 4); 5418 d |= PACK(g, 4, 4); 5419 d |= PACK(r, 8, 4); 5420 d |= PACK(a, 12, 4); 5421 (*(uint16_t *)dst) = d; 5422 } 5423 5424 static inline void 5425 pack_float_b4g4r4x4_unorm(const GLfloat src[4], void *dst) 5426 { 5427 5428 5429 uint8_t b = 5430 _mesa_float_to_unorm(src[2], 4); 5431 5432 5433 uint8_t g = 5434 _mesa_float_to_unorm(src[1], 4); 5435 5436 5437 uint8_t r = 5438 _mesa_float_to_unorm(src[0], 4); 5439 5440 5441 uint16_t d = 0; 5442 d |= PACK(b, 0, 4); 5443 d |= PACK(g, 4, 4); 5444 d |= PACK(r, 8, 4); 5445 (*(uint16_t *)dst) = d; 5446 } 5447 5448 static inline void 5449 pack_float_a4r4g4b4_unorm(const GLfloat src[4], void *dst) 5450 { 5451 5452 5453 uint8_t a = 5454 _mesa_float_to_unorm(src[3], 4); 5455 5456 5457 uint8_t r = 5458 _mesa_float_to_unorm(src[0], 4); 5459 5460 5461 uint8_t g = 5462 _mesa_float_to_unorm(src[1], 4); 5463 5464 5465 uint8_t b = 5466 _mesa_float_to_unorm(src[2], 4); 5467 5468 uint16_t d = 0; 5469 d |= PACK(a, 0, 4); 5470 d |= PACK(r, 4, 4); 5471 d |= PACK(g, 8, 4); 5472 d |= PACK(b, 12, 4); 5473 (*(uint16_t *)dst) = d; 5474 } 5475 5476 static inline void 5477 pack_float_a1b5g5r5_unorm(const GLfloat src[4], void *dst) 5478 { 5479 5480 5481 uint8_t a = 5482 _mesa_float_to_unorm(src[3], 1); 5483 5484 5485 uint8_t b = 5486 _mesa_float_to_unorm(src[2], 5); 5487 5488 5489 uint8_t g = 5490 _mesa_float_to_unorm(src[1], 5); 5491 5492 5493 uint8_t r = 5494 _mesa_float_to_unorm(src[0], 5); 5495 5496 uint16_t d = 0; 5497 d |= PACK(a, 0, 1); 5498 d |= PACK(b, 1, 5); 5499 d |= PACK(g, 6, 5); 5500 d |= PACK(r, 11, 5); 5501 (*(uint16_t *)dst) = d; 5502 } 5503 5504 static inline void 5505 pack_float_b5g5r5a1_unorm(const GLfloat src[4], void *dst) 5506 { 5507 5508 5509 uint8_t b = 5510 _mesa_float_to_unorm(src[2], 5); 5511 5512 5513 uint8_t g = 5514 _mesa_float_to_unorm(src[1], 5); 5515 5516 5517 uint8_t r = 5518 _mesa_float_to_unorm(src[0], 5); 5519 5520 5521 uint8_t a = 5522 _mesa_float_to_unorm(src[3], 1); 5523 5524 uint16_t d = 0; 5525 d |= PACK(b, 0, 5); 5526 d |= PACK(g, 5, 5); 5527 d |= PACK(r, 10, 5); 5528 d |= PACK(a, 15, 1); 5529 (*(uint16_t *)dst) = d; 5530 } 5531 5532 static inline void 5533 pack_float_b5g5r5x1_unorm(const GLfloat src[4], void *dst) 5534 { 5535 5536 5537 uint8_t b = 5538 _mesa_float_to_unorm(src[2], 5); 5539 5540 5541 uint8_t g = 5542 _mesa_float_to_unorm(src[1], 5); 5543 5544 5545 uint8_t r = 5546 _mesa_float_to_unorm(src[0], 5); 5547 5548 5549 uint16_t d = 0; 5550 d |= PACK(b, 0, 5); 5551 d |= PACK(g, 5, 5); 5552 d |= PACK(r, 10, 5); 5553 (*(uint16_t *)dst) = d; 5554 } 5555 5556 static inline void 5557 pack_float_a1r5g5b5_unorm(const GLfloat src[4], void *dst) 5558 { 5559 5560 5561 uint8_t a = 5562 _mesa_float_to_unorm(src[3], 1); 5563 5564 5565 uint8_t r = 5566 _mesa_float_to_unorm(src[0], 5); 5567 5568 5569 uint8_t g = 5570 _mesa_float_to_unorm(src[1], 5); 5571 5572 5573 uint8_t b = 5574 _mesa_float_to_unorm(src[2], 5); 5575 5576 uint16_t d = 0; 5577 d |= PACK(a, 0, 1); 5578 d |= PACK(r, 1, 5); 5579 d |= PACK(g, 6, 5); 5580 d |= PACK(b, 11, 5); 5581 (*(uint16_t *)dst) = d; 5582 } 5583 5584 static inline void 5585 pack_float_l8a8_unorm(const GLfloat src[4], void *dst) 5586 { 5587 5588 5589 uint8_t l = 5590 _mesa_float_to_unorm(src[0], 8); 5591 5592 5593 uint8_t a = 5594 _mesa_float_to_unorm(src[3], 8); 5595 5596 uint16_t d = 0; 5597 d |= PACK(l, 0, 8); 5598 d |= PACK(a, 8, 8); 5599 (*(uint16_t *)dst) = d; 5600 } 5601 5602 static inline void 5603 pack_float_a8l8_unorm(const GLfloat src[4], void *dst) 5604 { 5605 5606 5607 uint8_t a = 5608 _mesa_float_to_unorm(src[3], 8); 5609 5610 5611 uint8_t l = 5612 _mesa_float_to_unorm(src[0], 8); 5613 5614 uint16_t d = 0; 5615 d |= PACK(a, 0, 8); 5616 d |= PACK(l, 8, 8); 5617 (*(uint16_t *)dst) = d; 5618 } 5619 5620 static inline void 5621 pack_float_r8g8_unorm(const GLfloat src[4], void *dst) 5622 { 5623 5624 5625 uint8_t r = 5626 _mesa_float_to_unorm(src[0], 8); 5627 5628 5629 uint8_t g = 5630 _mesa_float_to_unorm(src[1], 8); 5631 5632 uint16_t d = 0; 5633 d |= PACK(r, 0, 8); 5634 d |= PACK(g, 8, 8); 5635 (*(uint16_t *)dst) = d; 5636 } 5637 5638 static inline void 5639 pack_float_g8r8_unorm(const GLfloat src[4], void *dst) 5640 { 5641 5642 5643 uint8_t g = 5644 _mesa_float_to_unorm(src[1], 8); 5645 5646 5647 uint8_t r = 5648 _mesa_float_to_unorm(src[0], 8); 5649 5650 uint16_t d = 0; 5651 d |= PACK(g, 0, 8); 5652 d |= PACK(r, 8, 8); 5653 (*(uint16_t *)dst) = d; 5654 } 5655 5656 static inline void 5657 pack_float_l4a4_unorm(const GLfloat src[4], void *dst) 5658 { 5659 5660 5661 uint8_t l = 5662 _mesa_float_to_unorm(src[0], 4); 5663 5664 5665 uint8_t a = 5666 _mesa_float_to_unorm(src[3], 4); 5667 5668 uint8_t d = 0; 5669 d |= PACK(l, 0, 4); 5670 d |= PACK(a, 4, 4); 5671 (*(uint8_t *)dst) = d; 5672 } 5673 5674 static inline void 5675 pack_float_b2g3r3_unorm(const GLfloat src[4], void *dst) 5676 { 5677 5678 5679 uint8_t b = 5680 _mesa_float_to_unorm(src[2], 2); 5681 5682 5683 uint8_t g = 5684 _mesa_float_to_unorm(src[1], 3); 5685 5686 5687 uint8_t r = 5688 _mesa_float_to_unorm(src[0], 3); 5689 5690 uint8_t d = 0; 5691 d |= PACK(b, 0, 2); 5692 d |= PACK(g, 2, 3); 5693 d |= PACK(r, 5, 3); 5694 (*(uint8_t *)dst) = d; 5695 } 5696 5697 static inline void 5698 pack_float_r16g16_unorm(const GLfloat src[4], void *dst) 5699 { 5700 5701 5702 uint16_t r = 5703 _mesa_float_to_unorm(src[0], 16); 5704 5705 5706 uint16_t g = 5707 _mesa_float_to_unorm(src[1], 16); 5708 5709 uint32_t d = 0; 5710 d |= PACK(r, 0, 16); 5711 d |= PACK(g, 16, 16); 5712 (*(uint32_t *)dst) = d; 5713 } 5714 5715 static inline void 5716 pack_float_g16r16_unorm(const GLfloat src[4], void *dst) 5717 { 5718 5719 5720 uint16_t g = 5721 _mesa_float_to_unorm(src[1], 16); 5722 5723 5724 uint16_t r = 5725 _mesa_float_to_unorm(src[0], 16); 5726 5727 uint32_t d = 0; 5728 d |= PACK(g, 0, 16); 5729 d |= PACK(r, 16, 16); 5730 (*(uint32_t *)dst) = d; 5731 } 5732 5733 static inline void 5734 pack_float_b10g10r10a2_unorm(const GLfloat src[4], void *dst) 5735 { 5736 5737 5738 uint16_t b = 5739 _mesa_float_to_unorm(src[2], 10); 5740 5741 5742 uint16_t g = 5743 _mesa_float_to_unorm(src[1], 10); 5744 5745 5746 uint16_t r = 5747 _mesa_float_to_unorm(src[0], 10); 5748 5749 5750 uint8_t a = 5751 _mesa_float_to_unorm(src[3], 2); 5752 5753 uint32_t d = 0; 5754 d |= PACK(b, 0, 10); 5755 d |= PACK(g, 10, 10); 5756 d |= PACK(r, 20, 10); 5757 d |= PACK(a, 30, 2); 5758 (*(uint32_t *)dst) = d; 5759 } 5760 5761 static inline void 5762 pack_float_b10g10r10x2_unorm(const GLfloat src[4], void *dst) 5763 { 5764 5765 5766 uint16_t b = 5767 _mesa_float_to_unorm(src[2], 10); 5768 5769 5770 uint16_t g = 5771 _mesa_float_to_unorm(src[1], 10); 5772 5773 5774 uint16_t r = 5775 _mesa_float_to_unorm(src[0], 10); 5776 5777 5778 uint32_t d = 0; 5779 d |= PACK(b, 0, 10); 5780 d |= PACK(g, 10, 10); 5781 d |= PACK(r, 20, 10); 5782 (*(uint32_t *)dst) = d; 5783 } 5784 5785 static inline void 5786 pack_float_r10g10b10a2_unorm(const GLfloat src[4], void *dst) 5787 { 5788 5789 5790 uint16_t r = 5791 _mesa_float_to_unorm(src[0], 10); 5792 5793 5794 uint16_t g = 5795 _mesa_float_to_unorm(src[1], 10); 5796 5797 5798 uint16_t b = 5799 _mesa_float_to_unorm(src[2], 10); 5800 5801 5802 uint8_t a = 5803 _mesa_float_to_unorm(src[3], 2); 5804 5805 uint32_t d = 0; 5806 d |= PACK(r, 0, 10); 5807 d |= PACK(g, 10, 10); 5808 d |= PACK(b, 20, 10); 5809 d |= PACK(a, 30, 2); 5810 (*(uint32_t *)dst) = d; 5811 } 5812 5813 static inline void 5814 pack_float_r10g10b10x2_unorm(const GLfloat src[4], void *dst) 5815 { 5816 5817 5818 uint16_t r = 5819 _mesa_float_to_unorm(src[0], 10); 5820 5821 5822 uint16_t g = 5823 _mesa_float_to_unorm(src[1], 10); 5824 5825 5826 uint16_t b = 5827 _mesa_float_to_unorm(src[2], 10); 5828 5829 5830 uint32_t d = 0; 5831 d |= PACK(r, 0, 10); 5832 d |= PACK(g, 10, 10); 5833 d |= PACK(b, 20, 10); 5834 (*(uint32_t *)dst) = d; 5835 } 5836 5837 static inline void 5838 pack_float_r3g3b2_unorm(const GLfloat src[4], void *dst) 5839 { 5840 5841 5842 uint8_t r = 5843 _mesa_float_to_unorm(src[0], 3); 5844 5845 5846 uint8_t g = 5847 _mesa_float_to_unorm(src[1], 3); 5848 5849 5850 uint8_t b = 5851 _mesa_float_to_unorm(src[2], 2); 5852 5853 uint8_t d = 0; 5854 d |= PACK(r, 0, 3); 5855 d |= PACK(g, 3, 3); 5856 d |= PACK(b, 6, 2); 5857 (*(uint8_t *)dst) = d; 5858 } 5859 5860 static inline void 5861 pack_float_a4b4g4r4_unorm(const GLfloat src[4], void *dst) 5862 { 5863 5864 5865 uint8_t a = 5866 _mesa_float_to_unorm(src[3], 4); 5867 5868 5869 uint8_t b = 5870 _mesa_float_to_unorm(src[2], 4); 5871 5872 5873 uint8_t g = 5874 _mesa_float_to_unorm(src[1], 4); 5875 5876 5877 uint8_t r = 5878 _mesa_float_to_unorm(src[0], 4); 5879 5880 uint16_t d = 0; 5881 d |= PACK(a, 0, 4); 5882 d |= PACK(b, 4, 4); 5883 d |= PACK(g, 8, 4); 5884 d |= PACK(r, 12, 4); 5885 (*(uint16_t *)dst) = d; 5886 } 5887 5888 static inline void 5889 pack_float_r4g4b4a4_unorm(const GLfloat src[4], void *dst) 5890 { 5891 5892 5893 uint8_t r = 5894 _mesa_float_to_unorm(src[0], 4); 5895 5896 5897 uint8_t g = 5898 _mesa_float_to_unorm(src[1], 4); 5899 5900 5901 uint8_t b = 5902 _mesa_float_to_unorm(src[2], 4); 5903 5904 5905 uint8_t a = 5906 _mesa_float_to_unorm(src[3], 4); 5907 5908 uint16_t d = 0; 5909 d |= PACK(r, 0, 4); 5910 d |= PACK(g, 4, 4); 5911 d |= PACK(b, 8, 4); 5912 d |= PACK(a, 12, 4); 5913 (*(uint16_t *)dst) = d; 5914 } 5915 5916 static inline void 5917 pack_float_r5g5b5a1_unorm(const GLfloat src[4], void *dst) 5918 { 5919 5920 5921 uint8_t r = 5922 _mesa_float_to_unorm(src[0], 5); 5923 5924 5925 uint8_t g = 5926 _mesa_float_to_unorm(src[1], 5); 5927 5928 5929 uint8_t b = 5930 _mesa_float_to_unorm(src[2], 5); 5931 5932 5933 uint8_t a = 5934 _mesa_float_to_unorm(src[3], 1); 5935 5936 uint16_t d = 0; 5937 d |= PACK(r, 0, 5); 5938 d |= PACK(g, 5, 5); 5939 d |= PACK(b, 10, 5); 5940 d |= PACK(a, 15, 1); 5941 (*(uint16_t *)dst) = d; 5942 } 5943 5944 static inline void 5945 pack_float_a2b10g10r10_unorm(const GLfloat src[4], void *dst) 5946 { 5947 5948 5949 uint8_t a = 5950 _mesa_float_to_unorm(src[3], 2); 5951 5952 5953 uint16_t b = 5954 _mesa_float_to_unorm(src[2], 10); 5955 5956 5957 uint16_t g = 5958 _mesa_float_to_unorm(src[1], 10); 5959 5960 5961 uint16_t r = 5962 _mesa_float_to_unorm(src[0], 10); 5963 5964 uint32_t d = 0; 5965 d |= PACK(a, 0, 2); 5966 d |= PACK(b, 2, 10); 5967 d |= PACK(g, 12, 10); 5968 d |= PACK(r, 22, 10); 5969 (*(uint32_t *)dst) = d; 5970 } 5971 5972 static inline void 5973 pack_float_a2r10g10b10_unorm(const GLfloat src[4], void *dst) 5974 { 5975 5976 5977 uint8_t a = 5978 _mesa_float_to_unorm(src[3], 2); 5979 5980 5981 uint16_t r = 5982 _mesa_float_to_unorm(src[0], 10); 5983 5984 5985 uint16_t g = 5986 _mesa_float_to_unorm(src[1], 10); 5987 5988 5989 uint16_t b = 5990 _mesa_float_to_unorm(src[2], 10); 5991 5992 uint32_t d = 0; 5993 d |= PACK(a, 0, 2); 5994 d |= PACK(r, 2, 10); 5995 d |= PACK(g, 12, 10); 5996 d |= PACK(b, 22, 10); 5997 (*(uint32_t *)dst) = d; 5998 } 5999 6000 static inline void 6001 pack_float_a_unorm8(const GLfloat src[4], void *dst) 6002 { 6003 6004 6005 uint8_t a = 6006 _mesa_float_to_unorm(src[3], 8); 6007 6008 uint8_t *d = (uint8_t *)dst; 6009 d[0] = a; 6010 } 6011 6012 static inline void 6013 pack_float_a_unorm16(const GLfloat src[4], void *dst) 6014 { 6015 6016 6017 uint16_t a = 6018 _mesa_float_to_unorm(src[3], 16); 6019 6020 uint16_t *d = (uint16_t *)dst; 6021 d[0] = a; 6022 } 6023 6024 static inline void 6025 pack_float_l_unorm8(const GLfloat src[4], void *dst) 6026 { 6027 6028 6029 uint8_t l = 6030 _mesa_float_to_unorm(src[0], 8); 6031 6032 uint8_t *d = (uint8_t *)dst; 6033 d[0] = l; 6034 } 6035 6036 static inline void 6037 pack_float_l_unorm16(const GLfloat src[4], void *dst) 6038 { 6039 6040 6041 uint16_t l = 6042 _mesa_float_to_unorm(src[0], 16); 6043 6044 uint16_t *d = (uint16_t *)dst; 6045 d[0] = l; 6046 } 6047 6048 static inline void 6049 pack_float_i_unorm8(const GLfloat src[4], void *dst) 6050 { 6051 6052 6053 uint8_t i = 6054 _mesa_float_to_unorm(src[0], 8); 6055 6056 uint8_t *d = (uint8_t *)dst; 6057 d[0] = i; 6058 } 6059 6060 static inline void 6061 pack_float_i_unorm16(const GLfloat src[4], void *dst) 6062 { 6063 6064 6065 uint16_t i = 6066 _mesa_float_to_unorm(src[0], 16); 6067 6068 uint16_t *d = (uint16_t *)dst; 6069 d[0] = i; 6070 } 6071 6072 static inline void 6073 pack_float_r_unorm8(const GLfloat src[4], void *dst) 6074 { 6075 6076 6077 uint8_t r = 6078 _mesa_float_to_unorm(src[0], 8); 6079 6080 uint8_t *d = (uint8_t *)dst; 6081 d[0] = r; 6082 } 6083 6084 static inline void 6085 pack_float_r_unorm16(const GLfloat src[4], void *dst) 6086 { 6087 6088 6089 uint16_t r = 6090 _mesa_float_to_unorm(src[0], 16); 6091 6092 uint16_t *d = (uint16_t *)dst; 6093 d[0] = r; 6094 } 6095 6096 static inline void 6097 pack_float_bgr_unorm8(const GLfloat src[4], void *dst) 6098 { 6099 6100 6101 uint8_t b = 6102 _mesa_float_to_unorm(src[2], 8); 6103 6104 6105 uint8_t g = 6106 _mesa_float_to_unorm(src[1], 8); 6107 6108 6109 uint8_t r = 6110 _mesa_float_to_unorm(src[0], 8); 6111 6112 uint8_t *d = (uint8_t *)dst; 6113 d[0] = b; 6114 d[1] = g; 6115 d[2] = r; 6116 } 6117 6118 static inline void 6119 pack_float_rgb_unorm8(const GLfloat src[4], void *dst) 6120 { 6121 6122 6123 uint8_t r = 6124 _mesa_float_to_unorm(src[0], 8); 6125 6126 6127 uint8_t g = 6128 _mesa_float_to_unorm(src[1], 8); 6129 6130 6131 uint8_t b = 6132 _mesa_float_to_unorm(src[2], 8); 6133 6134 uint8_t *d = (uint8_t *)dst; 6135 d[0] = r; 6136 d[1] = g; 6137 d[2] = b; 6138 } 6139 6140 static inline void 6141 pack_float_rgba_unorm16(const GLfloat src[4], void *dst) 6142 { 6143 6144 6145 uint16_t r = 6146 _mesa_float_to_unorm(src[0], 16); 6147 6148 6149 uint16_t g = 6150 _mesa_float_to_unorm(src[1], 16); 6151 6152 6153 uint16_t b = 6154 _mesa_float_to_unorm(src[2], 16); 6155 6156 6157 uint16_t a = 6158 _mesa_float_to_unorm(src[3], 16); 6159 6160 uint16_t *d = (uint16_t *)dst; 6161 d[0] = r; 6162 d[1] = g; 6163 d[2] = b; 6164 d[3] = a; 6165 } 6166 6167 static inline void 6168 pack_float_rgbx_unorm16(const GLfloat src[4], void *dst) 6169 { 6170 6171 6172 uint16_t r = 6173 _mesa_float_to_unorm(src[0], 16); 6174 6175 6176 uint16_t g = 6177 _mesa_float_to_unorm(src[1], 16); 6178 6179 6180 uint16_t b = 6181 _mesa_float_to_unorm(src[2], 16); 6182 6183 6184 uint16_t *d = (uint16_t *)dst; 6185 d[0] = r; 6186 d[1] = g; 6187 d[2] = b; 6188 } 6189 6190 static inline void 6191 pack_float_a8b8g8r8_snorm(const GLfloat src[4], void *dst) 6192 { 6193 6194 6195 int8_t a = 6196 _mesa_float_to_snorm(src[3], 8); 6197 6198 6199 int8_t b = 6200 _mesa_float_to_snorm(src[2], 8); 6201 6202 6203 int8_t g = 6204 _mesa_float_to_snorm(src[1], 8); 6205 6206 6207 int8_t r = 6208 _mesa_float_to_snorm(src[0], 8); 6209 6210 uint32_t d = 0; 6211 d |= PACK(a, 0, 8); 6212 d |= PACK(b, 8, 8); 6213 d |= PACK(g, 16, 8); 6214 d |= PACK(r, 24, 8); 6215 (*(uint32_t *)dst) = d; 6216 } 6217 6218 static inline void 6219 pack_float_x8b8g8r8_snorm(const GLfloat src[4], void *dst) 6220 { 6221 6222 6223 6224 int8_t b = 6225 _mesa_float_to_snorm(src[2], 8); 6226 6227 6228 int8_t g = 6229 _mesa_float_to_snorm(src[1], 8); 6230 6231 6232 int8_t r = 6233 _mesa_float_to_snorm(src[0], 8); 6234 6235 uint32_t d = 0; 6236 d |= PACK(b, 8, 8); 6237 d |= PACK(g, 16, 8); 6238 d |= PACK(r, 24, 8); 6239 (*(uint32_t *)dst) = d; 6240 } 6241 6242 static inline void 6243 pack_float_r8g8b8a8_snorm(const GLfloat src[4], void *dst) 6244 { 6245 6246 6247 int8_t r = 6248 _mesa_float_to_snorm(src[0], 8); 6249 6250 6251 int8_t g = 6252 _mesa_float_to_snorm(src[1], 8); 6253 6254 6255 int8_t b = 6256 _mesa_float_to_snorm(src[2], 8); 6257 6258 6259 int8_t a = 6260 _mesa_float_to_snorm(src[3], 8); 6261 6262 uint32_t d = 0; 6263 d |= PACK(r, 0, 8); 6264 d |= PACK(g, 8, 8); 6265 d |= PACK(b, 16, 8); 6266 d |= PACK(a, 24, 8); 6267 (*(uint32_t *)dst) = d; 6268 } 6269 6270 static inline void 6271 pack_float_r8g8b8x8_snorm(const GLfloat src[4], void *dst) 6272 { 6273 6274 6275 int8_t r = 6276 _mesa_float_to_snorm(src[0], 8); 6277 6278 6279 int8_t g = 6280 _mesa_float_to_snorm(src[1], 8); 6281 6282 6283 int8_t b = 6284 _mesa_float_to_snorm(src[2], 8); 6285 6286 6287 uint32_t d = 0; 6288 d |= PACK(r, 0, 8); 6289 d |= PACK(g, 8, 8); 6290 d |= PACK(b, 16, 8); 6291 (*(uint32_t *)dst) = d; 6292 } 6293 6294 static inline void 6295 pack_float_r16g16_snorm(const GLfloat src[4], void *dst) 6296 { 6297 6298 6299 int16_t r = 6300 _mesa_float_to_snorm(src[0], 16); 6301 6302 6303 int16_t g = 6304 _mesa_float_to_snorm(src[1], 16); 6305 6306 uint32_t d = 0; 6307 d |= PACK(r, 0, 16); 6308 d |= PACK(g, 16, 16); 6309 (*(uint32_t *)dst) = d; 6310 } 6311 6312 static inline void 6313 pack_float_g16r16_snorm(const GLfloat src[4], void *dst) 6314 { 6315 6316 6317 int16_t g = 6318 _mesa_float_to_snorm(src[1], 16); 6319 6320 6321 int16_t r = 6322 _mesa_float_to_snorm(src[0], 16); 6323 6324 uint32_t d = 0; 6325 d |= PACK(g, 0, 16); 6326 d |= PACK(r, 16, 16); 6327 (*(uint32_t *)dst) = d; 6328 } 6329 6330 static inline void 6331 pack_float_r8g8_snorm(const GLfloat src[4], void *dst) 6332 { 6333 6334 6335 int8_t r = 6336 _mesa_float_to_snorm(src[0], 8); 6337 6338 6339 int8_t g = 6340 _mesa_float_to_snorm(src[1], 8); 6341 6342 uint16_t d = 0; 6343 d |= PACK(r, 0, 8); 6344 d |= PACK(g, 8, 8); 6345 (*(uint16_t *)dst) = d; 6346 } 6347 6348 static inline void 6349 pack_float_g8r8_snorm(const GLfloat src[4], void *dst) 6350 { 6351 6352 6353 int8_t g = 6354 _mesa_float_to_snorm(src[1], 8); 6355 6356 6357 int8_t r = 6358 _mesa_float_to_snorm(src[0], 8); 6359 6360 uint16_t d = 0; 6361 d |= PACK(g, 0, 8); 6362 d |= PACK(r, 8, 8); 6363 (*(uint16_t *)dst) = d; 6364 } 6365 6366 static inline void 6367 pack_float_l8a8_snorm(const GLfloat src[4], void *dst) 6368 { 6369 6370 6371 int8_t l = 6372 _mesa_float_to_snorm(src[0], 8); 6373 6374 6375 int8_t a = 6376 _mesa_float_to_snorm(src[3], 8); 6377 6378 uint16_t d = 0; 6379 d |= PACK(l, 0, 8); 6380 d |= PACK(a, 8, 8); 6381 (*(uint16_t *)dst) = d; 6382 } 6383 6384 static inline void 6385 pack_float_a8l8_snorm(const GLfloat src[4], void *dst) 6386 { 6387 6388 6389 int8_t a = 6390 _mesa_float_to_snorm(src[3], 8); 6391 6392 6393 int8_t l = 6394 _mesa_float_to_snorm(src[0], 8); 6395 6396 uint16_t d = 0; 6397 d |= PACK(a, 0, 8); 6398 d |= PACK(l, 8, 8); 6399 (*(uint16_t *)dst) = d; 6400 } 6401 6402 static inline void 6403 pack_float_a_snorm8(const GLfloat src[4], void *dst) 6404 { 6405 6406 6407 int8_t a = 6408 _mesa_float_to_snorm(src[3], 8); 6409 6410 int8_t *d = (int8_t *)dst; 6411 d[0] = a; 6412 } 6413 6414 static inline void 6415 pack_float_a_snorm16(const GLfloat src[4], void *dst) 6416 { 6417 6418 6419 int16_t a = 6420 _mesa_float_to_snorm(src[3], 16); 6421 6422 int16_t *d = (int16_t *)dst; 6423 d[0] = a; 6424 } 6425 6426 static inline void 6427 pack_float_l_snorm8(const GLfloat src[4], void *dst) 6428 { 6429 6430 6431 int8_t l = 6432 _mesa_float_to_snorm(src[0], 8); 6433 6434 int8_t *d = (int8_t *)dst; 6435 d[0] = l; 6436 } 6437 6438 static inline void 6439 pack_float_l_snorm16(const GLfloat src[4], void *dst) 6440 { 6441 6442 6443 int16_t l = 6444 _mesa_float_to_snorm(src[0], 16); 6445 6446 int16_t *d = (int16_t *)dst; 6447 d[0] = l; 6448 } 6449 6450 static inline void 6451 pack_float_i_snorm8(const GLfloat src[4], void *dst) 6452 { 6453 6454 6455 int8_t i = 6456 _mesa_float_to_snorm(src[0], 8); 6457 6458 int8_t *d = (int8_t *)dst; 6459 d[0] = i; 6460 } 6461 6462 static inline void 6463 pack_float_i_snorm16(const GLfloat src[4], void *dst) 6464 { 6465 6466 6467 int16_t i = 6468 _mesa_float_to_snorm(src[0], 16); 6469 6470 int16_t *d = (int16_t *)dst; 6471 d[0] = i; 6472 } 6473 6474 static inline void 6475 pack_float_r_snorm8(const GLfloat src[4], void *dst) 6476 { 6477 6478 6479 int8_t r = 6480 _mesa_float_to_snorm(src[0], 8); 6481 6482 int8_t *d = (int8_t *)dst; 6483 d[0] = r; 6484 } 6485 6486 static inline void 6487 pack_float_r_snorm16(const GLfloat src[4], void *dst) 6488 { 6489 6490 6491 int16_t r = 6492 _mesa_float_to_snorm(src[0], 16); 6493 6494 int16_t *d = (int16_t *)dst; 6495 d[0] = r; 6496 } 6497 6498 static inline void 6499 pack_float_la_snorm16(const GLfloat src[4], void *dst) 6500 { 6501 6502 6503 int16_t l = 6504 _mesa_float_to_snorm(src[0], 16); 6505 6506 6507 int16_t a = 6508 _mesa_float_to_snorm(src[3], 16); 6509 6510 int16_t *d = (int16_t *)dst; 6511 d[0] = l; 6512 d[1] = a; 6513 } 6514 6515 static inline void 6516 pack_float_rgb_snorm16(const GLfloat src[4], void *dst) 6517 { 6518 6519 6520 int16_t r = 6521 _mesa_float_to_snorm(src[0], 16); 6522 6523 6524 int16_t g = 6525 _mesa_float_to_snorm(src[1], 16); 6526 6527 6528 int16_t b = 6529 _mesa_float_to_snorm(src[2], 16); 6530 6531 int16_t *d = (int16_t *)dst; 6532 d[0] = r; 6533 d[1] = g; 6534 d[2] = b; 6535 } 6536 6537 static inline void 6538 pack_float_rgba_snorm16(const GLfloat src[4], void *dst) 6539 { 6540 6541 6542 int16_t r = 6543 _mesa_float_to_snorm(src[0], 16); 6544 6545 6546 int16_t g = 6547 _mesa_float_to_snorm(src[1], 16); 6548 6549 6550 int16_t b = 6551 _mesa_float_to_snorm(src[2], 16); 6552 6553 6554 int16_t a = 6555 _mesa_float_to_snorm(src[3], 16); 6556 6557 int16_t *d = (int16_t *)dst; 6558 d[0] = r; 6559 d[1] = g; 6560 d[2] = b; 6561 d[3] = a; 6562 } 6563 6564 static inline void 6565 pack_float_rgbx_snorm16(const GLfloat src[4], void *dst) 6566 { 6567 6568 6569 int16_t r = 6570 _mesa_float_to_snorm(src[0], 16); 6571 6572 6573 int16_t g = 6574 _mesa_float_to_snorm(src[1], 16); 6575 6576 6577 int16_t b = 6578 _mesa_float_to_snorm(src[2], 16); 6579 6580 6581 int16_t *d = (int16_t *)dst; 6582 d[0] = r; 6583 d[1] = g; 6584 d[2] = b; 6585 } 6586 6587 static inline void 6588 pack_float_a8b8g8r8_srgb(const GLfloat src[4], void *dst) 6589 { 6590 6591 6592 uint8_t a = 6593 _mesa_float_to_unorm(src[3], 8); 6594 6595 6596 uint8_t b = 6597 6598 util_format_linear_float_to_srgb_8unorm(src[2]); 6599 6600 6601 uint8_t g = 6602 6603 util_format_linear_float_to_srgb_8unorm(src[1]); 6604 6605 6606 uint8_t r = 6607 6608 util_format_linear_float_to_srgb_8unorm(src[0]); 6609 6610 uint32_t d = 0; 6611 d |= PACK(a, 0, 8); 6612 d |= PACK(b, 8, 8); 6613 d |= PACK(g, 16, 8); 6614 d |= PACK(r, 24, 8); 6615 (*(uint32_t *)dst) = d; 6616 } 6617 6618 static inline void 6619 pack_float_b8g8r8a8_srgb(const GLfloat src[4], void *dst) 6620 { 6621 6622 6623 uint8_t b = 6624 6625 util_format_linear_float_to_srgb_8unorm(src[2]); 6626 6627 6628 uint8_t g = 6629 6630 util_format_linear_float_to_srgb_8unorm(src[1]); 6631 6632 6633 uint8_t r = 6634 6635 util_format_linear_float_to_srgb_8unorm(src[0]); 6636 6637 6638 uint8_t a = 6639 _mesa_float_to_unorm(src[3], 8); 6640 6641 uint32_t d = 0; 6642 d |= PACK(b, 0, 8); 6643 d |= PACK(g, 8, 8); 6644 d |= PACK(r, 16, 8); 6645 d |= PACK(a, 24, 8); 6646 (*(uint32_t *)dst) = d; 6647 } 6648 6649 static inline void 6650 pack_float_a8r8g8b8_srgb(const GLfloat src[4], void *dst) 6651 { 6652 6653 6654 uint8_t a = 6655 _mesa_float_to_unorm(src[3], 8); 6656 6657 6658 uint8_t r = 6659 6660 util_format_linear_float_to_srgb_8unorm(src[0]); 6661 6662 6663 uint8_t g = 6664 6665 util_format_linear_float_to_srgb_8unorm(src[1]); 6666 6667 6668 uint8_t b = 6669 6670 util_format_linear_float_to_srgb_8unorm(src[2]); 6671 6672 uint32_t d = 0; 6673 d |= PACK(a, 0, 8); 6674 d |= PACK(r, 8, 8); 6675 d |= PACK(g, 16, 8); 6676 d |= PACK(b, 24, 8); 6677 (*(uint32_t *)dst) = d; 6678 } 6679 6680 static inline void 6681 pack_float_b8g8r8x8_srgb(const GLfloat src[4], void *dst) 6682 { 6683 6684 6685 uint8_t b = 6686 6687 util_format_linear_float_to_srgb_8unorm(src[2]); 6688 6689 6690 uint8_t g = 6691 6692 util_format_linear_float_to_srgb_8unorm(src[1]); 6693 6694 6695 uint8_t r = 6696 6697 util_format_linear_float_to_srgb_8unorm(src[0]); 6698 6699 6700 uint32_t d = 0; 6701 d |= PACK(b, 0, 8); 6702 d |= PACK(g, 8, 8); 6703 d |= PACK(r, 16, 8); 6704 (*(uint32_t *)dst) = d; 6705 } 6706 6707 static inline void 6708 pack_float_x8r8g8b8_srgb(const GLfloat src[4], void *dst) 6709 { 6710 6711 6712 6713 uint8_t r = 6714 6715 util_format_linear_float_to_srgb_8unorm(src[0]); 6716 6717 6718 uint8_t g = 6719 6720 util_format_linear_float_to_srgb_8unorm(src[1]); 6721 6722 6723 uint8_t b = 6724 6725 util_format_linear_float_to_srgb_8unorm(src[2]); 6726 6727 uint32_t d = 0; 6728 d |= PACK(r, 8, 8); 6729 d |= PACK(g, 16, 8); 6730 d |= PACK(b, 24, 8); 6731 (*(uint32_t *)dst) = d; 6732 } 6733 6734 static inline void 6735 pack_float_r8g8b8a8_srgb(const GLfloat src[4], void *dst) 6736 { 6737 6738 6739 uint8_t r = 6740 6741 util_format_linear_float_to_srgb_8unorm(src[0]); 6742 6743 6744 uint8_t g = 6745 6746 util_format_linear_float_to_srgb_8unorm(src[1]); 6747 6748 6749 uint8_t b = 6750 6751 util_format_linear_float_to_srgb_8unorm(src[2]); 6752 6753 6754 uint8_t a = 6755 _mesa_float_to_unorm(src[3], 8); 6756 6757 uint32_t d = 0; 6758 d |= PACK(r, 0, 8); 6759 d |= PACK(g, 8, 8); 6760 d |= PACK(b, 16, 8); 6761 d |= PACK(a, 24, 8); 6762 (*(uint32_t *)dst) = d; 6763 } 6764 6765 static inline void 6766 pack_float_r8g8b8x8_srgb(const GLfloat src[4], void *dst) 6767 { 6768 6769 6770 uint8_t r = 6771 6772 util_format_linear_float_to_srgb_8unorm(src[0]); 6773 6774 6775 uint8_t g = 6776 6777 util_format_linear_float_to_srgb_8unorm(src[1]); 6778 6779 6780 uint8_t b = 6781 6782 util_format_linear_float_to_srgb_8unorm(src[2]); 6783 6784 6785 uint32_t d = 0; 6786 d |= PACK(r, 0, 8); 6787 d |= PACK(g, 8, 8); 6788 d |= PACK(b, 16, 8); 6789 (*(uint32_t *)dst) = d; 6790 } 6791 6792 static inline void 6793 pack_float_x8b8g8r8_srgb(const GLfloat src[4], void *dst) 6794 { 6795 6796 6797 6798 uint8_t b = 6799 6800 util_format_linear_float_to_srgb_8unorm(src[2]); 6801 6802 6803 uint8_t g = 6804 6805 util_format_linear_float_to_srgb_8unorm(src[1]); 6806 6807 6808 uint8_t r = 6809 6810 util_format_linear_float_to_srgb_8unorm(src[0]); 6811 6812 uint32_t d = 0; 6813 d |= PACK(b, 8, 8); 6814 d |= PACK(g, 16, 8); 6815 d |= PACK(r, 24, 8); 6816 (*(uint32_t *)dst) = d; 6817 } 6818 6819 static inline void 6820 pack_float_l8a8_srgb(const GLfloat src[4], void *dst) 6821 { 6822 6823 6824 uint8_t l = 6825 _mesa_float_to_unorm(src[0], 8); 6826 6827 6828 uint8_t a = 6829 _mesa_float_to_unorm(src[3], 8); 6830 6831 uint16_t d = 0; 6832 d |= PACK(l, 0, 8); 6833 d |= PACK(a, 8, 8); 6834 (*(uint16_t *)dst) = d; 6835 } 6836 6837 static inline void 6838 pack_float_a8l8_srgb(const GLfloat src[4], void *dst) 6839 { 6840 6841 6842 uint8_t a = 6843 _mesa_float_to_unorm(src[3], 8); 6844 6845 6846 uint8_t l = 6847 _mesa_float_to_unorm(src[0], 8); 6848 6849 uint16_t d = 0; 6850 d |= PACK(a, 0, 8); 6851 d |= PACK(l, 8, 8); 6852 (*(uint16_t *)dst) = d; 6853 } 6854 6855 static inline void 6856 pack_float_l_srgb8(const GLfloat src[4], void *dst) 6857 { 6858 6859 6860 uint8_t l = 6861 _mesa_float_to_unorm(src[0], 8); 6862 6863 uint8_t *d = (uint8_t *)dst; 6864 d[0] = l; 6865 } 6866 6867 static inline void 6868 pack_float_bgr_srgb8(const GLfloat src[4], void *dst) 6869 { 6870 6871 6872 uint8_t b = 6873 6874 util_format_linear_float_to_srgb_8unorm(src[2]); 6875 6876 6877 uint8_t g = 6878 6879 util_format_linear_float_to_srgb_8unorm(src[1]); 6880 6881 6882 uint8_t r = 6883 6884 util_format_linear_float_to_srgb_8unorm(src[0]); 6885 6886 uint8_t *d = (uint8_t *)dst; 6887 d[0] = b; 6888 d[1] = g; 6889 d[2] = r; 6890 } 6891 6892 static inline void 6893 pack_float_a_float16(const GLfloat src[4], void *dst) 6894 { 6895 6896 6897 uint16_t a = 6898 _mesa_float_to_half(src[3]); 6899 6900 uint16_t *d = (uint16_t *)dst; 6901 d[0] = a; 6902 } 6903 6904 static inline void 6905 pack_float_a_float32(const GLfloat src[4], void *dst) 6906 { 6907 6908 6909 float a = 6910 src[3]; 6911 6912 float *d = (float *)dst; 6913 d[0] = a; 6914 } 6915 6916 static inline void 6917 pack_float_l_float16(const GLfloat src[4], void *dst) 6918 { 6919 6920 6921 uint16_t l = 6922 _mesa_float_to_half(src[0]); 6923 6924 uint16_t *d = (uint16_t *)dst; 6925 d[0] = l; 6926 } 6927 6928 static inline void 6929 pack_float_l_float32(const GLfloat src[4], void *dst) 6930 { 6931 6932 6933 float l = 6934 src[0]; 6935 6936 float *d = (float *)dst; 6937 d[0] = l; 6938 } 6939 6940 static inline void 6941 pack_float_la_float16(const GLfloat src[4], void *dst) 6942 { 6943 6944 6945 uint16_t l = 6946 _mesa_float_to_half(src[0]); 6947 6948 6949 uint16_t a = 6950 _mesa_float_to_half(src[3]); 6951 6952 uint16_t *d = (uint16_t *)dst; 6953 d[0] = l; 6954 d[1] = a; 6955 } 6956 6957 static inline void 6958 pack_float_la_float32(const GLfloat src[4], void *dst) 6959 { 6960 6961 6962 float l = 6963 src[0]; 6964 6965 6966 float a = 6967 src[3]; 6968 6969 float *d = (float *)dst; 6970 d[0] = l; 6971 d[1] = a; 6972 } 6973 6974 static inline void 6975 pack_float_i_float16(const GLfloat src[4], void *dst) 6976 { 6977 6978 6979 uint16_t i = 6980 _mesa_float_to_half(src[0]); 6981 6982 uint16_t *d = (uint16_t *)dst; 6983 d[0] = i; 6984 } 6985 6986 static inline void 6987 pack_float_i_float32(const GLfloat src[4], void *dst) 6988 { 6989 6990 6991 float i = 6992 src[0]; 6993 6994 float *d = (float *)dst; 6995 d[0] = i; 6996 } 6997 6998 static inline void 6999 pack_float_r_float16(const GLfloat src[4], void *dst) 7000 { 7001 7002 7003 uint16_t r = 7004 _mesa_float_to_half(src[0]); 7005 7006 uint16_t *d = (uint16_t *)dst; 7007 d[0] = r; 7008 } 7009 7010 static inline void 7011 pack_float_r_float32(const GLfloat src[4], void *dst) 7012 { 7013 7014 7015 float r = 7016 src[0]; 7017 7018 float *d = (float *)dst; 7019 d[0] = r; 7020 } 7021 7022 static inline void 7023 pack_float_rg_float16(const GLfloat src[4], void *dst) 7024 { 7025 7026 7027 uint16_t r = 7028 _mesa_float_to_half(src[0]); 7029 7030 7031 uint16_t g = 7032 _mesa_float_to_half(src[1]); 7033 7034 uint16_t *d = (uint16_t *)dst; 7035 d[0] = r; 7036 d[1] = g; 7037 } 7038 7039 static inline void 7040 pack_float_rg_float32(const GLfloat src[4], void *dst) 7041 { 7042 7043 7044 float r = 7045 src[0]; 7046 7047 7048 float g = 7049 src[1]; 7050 7051 float *d = (float *)dst; 7052 d[0] = r; 7053 d[1] = g; 7054 } 7055 7056 static inline void 7057 pack_float_rgb_float16(const GLfloat src[4], void *dst) 7058 { 7059 7060 7061 uint16_t r = 7062 _mesa_float_to_half(src[0]); 7063 7064 7065 uint16_t g = 7066 _mesa_float_to_half(src[1]); 7067 7068 7069 uint16_t b = 7070 _mesa_float_to_half(src[2]); 7071 7072 uint16_t *d = (uint16_t *)dst; 7073 d[0] = r; 7074 d[1] = g; 7075 d[2] = b; 7076 } 7077 7078 static inline void 7079 pack_float_rgb_float32(const GLfloat src[4], void *dst) 7080 { 7081 7082 7083 float r = 7084 src[0]; 7085 7086 7087 float g = 7088 src[1]; 7089 7090 7091 float b = 7092 src[2]; 7093 7094 float *d = (float *)dst; 7095 d[0] = r; 7096 d[1] = g; 7097 d[2] = b; 7098 } 7099 7100 static inline void 7101 pack_float_rgba_float16(const GLfloat src[4], void *dst) 7102 { 7103 7104 7105 uint16_t r = 7106 _mesa_float_to_half(src[0]); 7107 7108 7109 uint16_t g = 7110 _mesa_float_to_half(src[1]); 7111 7112 7113 uint16_t b = 7114 _mesa_float_to_half(src[2]); 7115 7116 7117 uint16_t a = 7118 _mesa_float_to_half(src[3]); 7119 7120 uint16_t *d = (uint16_t *)dst; 7121 d[0] = r; 7122 d[1] = g; 7123 d[2] = b; 7124 d[3] = a; 7125 } 7126 7127 static inline void 7128 pack_float_rgba_float32(const GLfloat src[4], void *dst) 7129 { 7130 7131 7132 float r = 7133 src[0]; 7134 7135 7136 float g = 7137 src[1]; 7138 7139 7140 float b = 7141 src[2]; 7142 7143 7144 float a = 7145 src[3]; 7146 7147 float *d = (float *)dst; 7148 d[0] = r; 7149 d[1] = g; 7150 d[2] = b; 7151 d[3] = a; 7152 } 7153 7154 static inline void 7155 pack_float_rgbx_float16(const GLfloat src[4], void *dst) 7156 { 7157 7158 7159 uint16_t r = 7160 _mesa_float_to_half(src[0]); 7161 7162 7163 uint16_t g = 7164 _mesa_float_to_half(src[1]); 7165 7166 7167 uint16_t b = 7168 _mesa_float_to_half(src[2]); 7169 7170 7171 uint16_t *d = (uint16_t *)dst; 7172 d[0] = r; 7173 d[1] = g; 7174 d[2] = b; 7175 } 7176 7177 static inline void 7178 pack_float_rgbx_float32(const GLfloat src[4], void *dst) 7179 { 7180 7181 7182 float r = 7183 src[0]; 7184 7185 7186 float g = 7187 src[1]; 7188 7189 7190 float b = 7191 src[2]; 7192 7193 7194 float *d = (float *)dst; 7195 d[0] = r; 7196 d[1] = g; 7197 d[2] = b; 7198 } 7199 7200 static inline void 7201 pack_float_r9g9b9e5_float(const GLfloat src[4], void *dst) 7202 { 7203 GLuint *d = (GLuint *) dst; 7204 *d = float3_to_rgb9e5(src); 7205 } 7206 7207 static inline void 7208 pack_float_r11g11b10_float(const GLfloat src[4], void *dst) 7209 { 7210 GLuint *d = (GLuint *) dst; 7211 *d = float3_to_r11g11b10f(src); 7212 } 7213 7214 /** 7215 * Return a function that can pack a GLubyte rgba[4] color. 7216 */ 7217 gl_pack_ubyte_rgba_func 7218 _mesa_get_pack_ubyte_rgba_function(mesa_format format) 7219 { 7220 switch (format) { 7221 7222 case MESA_FORMAT_A8B8G8R8_UNORM: 7223 return pack_ubyte_a8b8g8r8_unorm; 7224 7225 case MESA_FORMAT_X8B8G8R8_UNORM: 7226 return pack_ubyte_x8b8g8r8_unorm; 7227 7228 case MESA_FORMAT_R8G8B8A8_UNORM: 7229 return pack_ubyte_r8g8b8a8_unorm; 7230 7231 case MESA_FORMAT_R8G8B8X8_UNORM: 7232 return pack_ubyte_r8g8b8x8_unorm; 7233 7234 case MESA_FORMAT_B8G8R8A8_UNORM: 7235 return pack_ubyte_b8g8r8a8_unorm; 7236 7237 case MESA_FORMAT_B8G8R8X8_UNORM: 7238 return pack_ubyte_b8g8r8x8_unorm; 7239 7240 case MESA_FORMAT_A8R8G8B8_UNORM: 7241 return pack_ubyte_a8r8g8b8_unorm; 7242 7243 case MESA_FORMAT_X8R8G8B8_UNORM: 7244 return pack_ubyte_x8r8g8b8_unorm; 7245 7246 case MESA_FORMAT_L16A16_UNORM: 7247 return pack_ubyte_l16a16_unorm; 7248 7249 case MESA_FORMAT_A16L16_UNORM: 7250 return pack_ubyte_a16l16_unorm; 7251 7252 case MESA_FORMAT_B5G6R5_UNORM: 7253 return pack_ubyte_b5g6r5_unorm; 7254 7255 case MESA_FORMAT_R5G6B5_UNORM: 7256 return pack_ubyte_r5g6b5_unorm; 7257 7258 case MESA_FORMAT_B4G4R4A4_UNORM: 7259 return pack_ubyte_b4g4r4a4_unorm; 7260 7261 case MESA_FORMAT_B4G4R4X4_UNORM: 7262 return pack_ubyte_b4g4r4x4_unorm; 7263 7264 case MESA_FORMAT_A4R4G4B4_UNORM: 7265 return pack_ubyte_a4r4g4b4_unorm; 7266 7267 case MESA_FORMAT_A1B5G5R5_UNORM: 7268 return pack_ubyte_a1b5g5r5_unorm; 7269 7270 case MESA_FORMAT_B5G5R5A1_UNORM: 7271 return pack_ubyte_b5g5r5a1_unorm; 7272 7273 case MESA_FORMAT_B5G5R5X1_UNORM: 7274 return pack_ubyte_b5g5r5x1_unorm; 7275 7276 case MESA_FORMAT_A1R5G5B5_UNORM: 7277 return pack_ubyte_a1r5g5b5_unorm; 7278 7279 case MESA_FORMAT_L8A8_UNORM: 7280 return pack_ubyte_l8a8_unorm; 7281 7282 case MESA_FORMAT_A8L8_UNORM: 7283 return pack_ubyte_a8l8_unorm; 7284 7285 case MESA_FORMAT_R8G8_UNORM: 7286 return pack_ubyte_r8g8_unorm; 7287 7288 case MESA_FORMAT_G8R8_UNORM: 7289 return pack_ubyte_g8r8_unorm; 7290 7291 case MESA_FORMAT_L4A4_UNORM: 7292 return pack_ubyte_l4a4_unorm; 7293 7294 case MESA_FORMAT_B2G3R3_UNORM: 7295 return pack_ubyte_b2g3r3_unorm; 7296 7297 case MESA_FORMAT_R16G16_UNORM: 7298 return pack_ubyte_r16g16_unorm; 7299 7300 case MESA_FORMAT_G16R16_UNORM: 7301 return pack_ubyte_g16r16_unorm; 7302 7303 case MESA_FORMAT_B10G10R10A2_UNORM: 7304 return pack_ubyte_b10g10r10a2_unorm; 7305 7306 case MESA_FORMAT_B10G10R10X2_UNORM: 7307 return pack_ubyte_b10g10r10x2_unorm; 7308 7309 case MESA_FORMAT_R10G10B10A2_UNORM: 7310 return pack_ubyte_r10g10b10a2_unorm; 7311 7312 case MESA_FORMAT_R10G10B10X2_UNORM: 7313 return pack_ubyte_r10g10b10x2_unorm; 7314 7315 case MESA_FORMAT_R3G3B2_UNORM: 7316 return pack_ubyte_r3g3b2_unorm; 7317 7318 case MESA_FORMAT_A4B4G4R4_UNORM: 7319 return pack_ubyte_a4b4g4r4_unorm; 7320 7321 case MESA_FORMAT_R4G4B4A4_UNORM: 7322 return pack_ubyte_r4g4b4a4_unorm; 7323 7324 case MESA_FORMAT_R5G5B5A1_UNORM: 7325 return pack_ubyte_r5g5b5a1_unorm; 7326 7327 case MESA_FORMAT_A2B10G10R10_UNORM: 7328 return pack_ubyte_a2b10g10r10_unorm; 7329 7330 case MESA_FORMAT_A2R10G10B10_UNORM: 7331 return pack_ubyte_a2r10g10b10_unorm; 7332 7333 case MESA_FORMAT_A_UNORM8: 7334 return pack_ubyte_a_unorm8; 7335 7336 case MESA_FORMAT_A_UNORM16: 7337 return pack_ubyte_a_unorm16; 7338 7339 case MESA_FORMAT_L_UNORM8: 7340 return pack_ubyte_l_unorm8; 7341 7342 case MESA_FORMAT_L_UNORM16: 7343 return pack_ubyte_l_unorm16; 7344 7345 case MESA_FORMAT_I_UNORM8: 7346 return pack_ubyte_i_unorm8; 7347 7348 case MESA_FORMAT_I_UNORM16: 7349 return pack_ubyte_i_unorm16; 7350 7351 case MESA_FORMAT_R_UNORM8: 7352 return pack_ubyte_r_unorm8; 7353 7354 case MESA_FORMAT_R_UNORM16: 7355 return pack_ubyte_r_unorm16; 7356 7357 case MESA_FORMAT_BGR_UNORM8: 7358 return pack_ubyte_bgr_unorm8; 7359 7360 case MESA_FORMAT_RGB_UNORM8: 7361 return pack_ubyte_rgb_unorm8; 7362 7363 case MESA_FORMAT_RGBA_UNORM16: 7364 return pack_ubyte_rgba_unorm16; 7365 7366 case MESA_FORMAT_RGBX_UNORM16: 7367 return pack_ubyte_rgbx_unorm16; 7368 7369 case MESA_FORMAT_A8B8G8R8_SNORM: 7370 return pack_ubyte_a8b8g8r8_snorm; 7371 7372 case MESA_FORMAT_X8B8G8R8_SNORM: 7373 return pack_ubyte_x8b8g8r8_snorm; 7374 7375 case MESA_FORMAT_R8G8B8A8_SNORM: 7376 return pack_ubyte_r8g8b8a8_snorm; 7377 7378 case MESA_FORMAT_R8G8B8X8_SNORM: 7379 return pack_ubyte_r8g8b8x8_snorm; 7380 7381 case MESA_FORMAT_R16G16_SNORM: 7382 return pack_ubyte_r16g16_snorm; 7383 7384 case MESA_FORMAT_G16R16_SNORM: 7385 return pack_ubyte_g16r16_snorm; 7386 7387 case MESA_FORMAT_R8G8_SNORM: 7388 return pack_ubyte_r8g8_snorm; 7389 7390 case MESA_FORMAT_G8R8_SNORM: 7391 return pack_ubyte_g8r8_snorm; 7392 7393 case MESA_FORMAT_L8A8_SNORM: 7394 return pack_ubyte_l8a8_snorm; 7395 7396 case MESA_FORMAT_A8L8_SNORM: 7397 return pack_ubyte_a8l8_snorm; 7398 7399 case MESA_FORMAT_A_SNORM8: 7400 return pack_ubyte_a_snorm8; 7401 7402 case MESA_FORMAT_A_SNORM16: 7403 return pack_ubyte_a_snorm16; 7404 7405 case MESA_FORMAT_L_SNORM8: 7406 return pack_ubyte_l_snorm8; 7407 7408 case MESA_FORMAT_L_SNORM16: 7409 return pack_ubyte_l_snorm16; 7410 7411 case MESA_FORMAT_I_SNORM8: 7412 return pack_ubyte_i_snorm8; 7413 7414 case MESA_FORMAT_I_SNORM16: 7415 return pack_ubyte_i_snorm16; 7416 7417 case MESA_FORMAT_R_SNORM8: 7418 return pack_ubyte_r_snorm8; 7419 7420 case MESA_FORMAT_R_SNORM16: 7421 return pack_ubyte_r_snorm16; 7422 7423 case MESA_FORMAT_LA_SNORM16: 7424 return pack_ubyte_la_snorm16; 7425 7426 case MESA_FORMAT_RGB_SNORM16: 7427 return pack_ubyte_rgb_snorm16; 7428 7429 case MESA_FORMAT_RGBA_SNORM16: 7430 return pack_ubyte_rgba_snorm16; 7431 7432 case MESA_FORMAT_RGBX_SNORM16: 7433 return pack_ubyte_rgbx_snorm16; 7434 7435 case MESA_FORMAT_A8B8G8R8_SRGB: 7436 return pack_ubyte_a8b8g8r8_srgb; 7437 7438 case MESA_FORMAT_B8G8R8A8_SRGB: 7439 return pack_ubyte_b8g8r8a8_srgb; 7440 7441 case MESA_FORMAT_A8R8G8B8_SRGB: 7442 return pack_ubyte_a8r8g8b8_srgb; 7443 7444 case MESA_FORMAT_B8G8R8X8_SRGB: 7445 return pack_ubyte_b8g8r8x8_srgb; 7446 7447 case MESA_FORMAT_X8R8G8B8_SRGB: 7448 return pack_ubyte_x8r8g8b8_srgb; 7449 7450 case MESA_FORMAT_R8G8B8A8_SRGB: 7451 return pack_ubyte_r8g8b8a8_srgb; 7452 7453 case MESA_FORMAT_R8G8B8X8_SRGB: 7454 return pack_ubyte_r8g8b8x8_srgb; 7455 7456 case MESA_FORMAT_X8B8G8R8_SRGB: 7457 return pack_ubyte_x8b8g8r8_srgb; 7458 7459 case MESA_FORMAT_L8A8_SRGB: 7460 return pack_ubyte_l8a8_srgb; 7461 7462 case MESA_FORMAT_A8L8_SRGB: 7463 return pack_ubyte_a8l8_srgb; 7464 7465 case MESA_FORMAT_L_SRGB8: 7466 return pack_ubyte_l_srgb8; 7467 7468 case MESA_FORMAT_BGR_SRGB8: 7469 return pack_ubyte_bgr_srgb8; 7470 7471 case MESA_FORMAT_R9G9B9E5_FLOAT: 7472 return pack_ubyte_r9g9b9e5_float; 7473 7474 case MESA_FORMAT_R11G11B10_FLOAT: 7475 return pack_ubyte_r11g11b10_float; 7476 7477 case MESA_FORMAT_A_FLOAT16: 7478 return pack_ubyte_a_float16; 7479 7480 case MESA_FORMAT_A_FLOAT32: 7481 return pack_ubyte_a_float32; 7482 7483 case MESA_FORMAT_L_FLOAT16: 7484 return pack_ubyte_l_float16; 7485 7486 case MESA_FORMAT_L_FLOAT32: 7487 return pack_ubyte_l_float32; 7488 7489 case MESA_FORMAT_LA_FLOAT16: 7490 return pack_ubyte_la_float16; 7491 7492 case MESA_FORMAT_LA_FLOAT32: 7493 return pack_ubyte_la_float32; 7494 7495 case MESA_FORMAT_I_FLOAT16: 7496 return pack_ubyte_i_float16; 7497 7498 case MESA_FORMAT_I_FLOAT32: 7499 return pack_ubyte_i_float32; 7500 7501 case MESA_FORMAT_R_FLOAT16: 7502 return pack_ubyte_r_float16; 7503 7504 case MESA_FORMAT_R_FLOAT32: 7505 return pack_ubyte_r_float32; 7506 7507 case MESA_FORMAT_RG_FLOAT16: 7508 return pack_ubyte_rg_float16; 7509 7510 case MESA_FORMAT_RG_FLOAT32: 7511 return pack_ubyte_rg_float32; 7512 7513 case MESA_FORMAT_RGB_FLOAT16: 7514 return pack_ubyte_rgb_float16; 7515 7516 case MESA_FORMAT_RGB_FLOAT32: 7517 return pack_ubyte_rgb_float32; 7518 7519 case MESA_FORMAT_RGBA_FLOAT16: 7520 return pack_ubyte_rgba_float16; 7521 7522 case MESA_FORMAT_RGBA_FLOAT32: 7523 return pack_ubyte_rgba_float32; 7524 7525 case MESA_FORMAT_RGBX_FLOAT16: 7526 return pack_ubyte_rgbx_float16; 7527 7528 case MESA_FORMAT_RGBX_FLOAT32: 7529 return pack_ubyte_rgbx_float32; 7530 7531 case MESA_FORMAT_A8B8G8R8_UINT: 7532 return pack_ubyte_a8b8g8r8_uint; 7533 7534 case MESA_FORMAT_A8R8G8B8_UINT: 7535 return pack_ubyte_a8r8g8b8_uint; 7536 7537 case MESA_FORMAT_R8G8B8A8_UINT: 7538 return pack_ubyte_r8g8b8a8_uint; 7539 7540 case MESA_FORMAT_B8G8R8A8_UINT: 7541 return pack_ubyte_b8g8r8a8_uint; 7542 7543 case MESA_FORMAT_B10G10R10A2_UINT: 7544 return pack_ubyte_b10g10r10a2_uint; 7545 7546 case MESA_FORMAT_R10G10B10A2_UINT: 7547 return pack_ubyte_r10g10b10a2_uint; 7548 7549 case MESA_FORMAT_A2B10G10R10_UINT: 7550 return pack_ubyte_a2b10g10r10_uint; 7551 7552 case MESA_FORMAT_A2R10G10B10_UINT: 7553 return pack_ubyte_a2r10g10b10_uint; 7554 7555 case MESA_FORMAT_B5G6R5_UINT: 7556 return pack_ubyte_b5g6r5_uint; 7557 7558 case MESA_FORMAT_R5G6B5_UINT: 7559 return pack_ubyte_r5g6b5_uint; 7560 7561 case MESA_FORMAT_B2G3R3_UINT: 7562 return pack_ubyte_b2g3r3_uint; 7563 7564 case MESA_FORMAT_R3G3B2_UINT: 7565 return pack_ubyte_r3g3b2_uint; 7566 7567 case MESA_FORMAT_A4B4G4R4_UINT: 7568 return pack_ubyte_a4b4g4r4_uint; 7569 7570 case MESA_FORMAT_R4G4B4A4_UINT: 7571 return pack_ubyte_r4g4b4a4_uint; 7572 7573 case MESA_FORMAT_B4G4R4A4_UINT: 7574 return pack_ubyte_b4g4r4a4_uint; 7575 7576 case MESA_FORMAT_A4R4G4B4_UINT: 7577 return pack_ubyte_a4r4g4b4_uint; 7578 7579 case MESA_FORMAT_A1B5G5R5_UINT: 7580 return pack_ubyte_a1b5g5r5_uint; 7581 7582 case MESA_FORMAT_B5G5R5A1_UINT: 7583 return pack_ubyte_b5g5r5a1_uint; 7584 7585 case MESA_FORMAT_A1R5G5B5_UINT: 7586 return pack_ubyte_a1r5g5b5_uint; 7587 7588 case MESA_FORMAT_R5G5B5A1_UINT: 7589 return pack_ubyte_r5g5b5a1_uint; 7590 7591 case MESA_FORMAT_A_UINT8: 7592 return pack_ubyte_a_uint8; 7593 7594 case MESA_FORMAT_A_UINT16: 7595 return pack_ubyte_a_uint16; 7596 7597 case MESA_FORMAT_A_UINT32: 7598 return pack_ubyte_a_uint32; 7599 7600 case MESA_FORMAT_A_SINT8: 7601 return pack_ubyte_a_sint8; 7602 7603 case MESA_FORMAT_A_SINT16: 7604 return pack_ubyte_a_sint16; 7605 7606 case MESA_FORMAT_A_SINT32: 7607 return pack_ubyte_a_sint32; 7608 7609 case MESA_FORMAT_I_UINT8: 7610 return pack_ubyte_i_uint8; 7611 7612 case MESA_FORMAT_I_UINT16: 7613 return pack_ubyte_i_uint16; 7614 7615 case MESA_FORMAT_I_UINT32: 7616 return pack_ubyte_i_uint32; 7617 7618 case MESA_FORMAT_I_SINT8: 7619 return pack_ubyte_i_sint8; 7620 7621 case MESA_FORMAT_I_SINT16: 7622 return pack_ubyte_i_sint16; 7623 7624 case MESA_FORMAT_I_SINT32: 7625 return pack_ubyte_i_sint32; 7626 7627 case MESA_FORMAT_L_UINT8: 7628 return pack_ubyte_l_uint8; 7629 7630 case MESA_FORMAT_L_UINT16: 7631 return pack_ubyte_l_uint16; 7632 7633 case MESA_FORMAT_L_UINT32: 7634 return pack_ubyte_l_uint32; 7635 7636 case MESA_FORMAT_L_SINT8: 7637 return pack_ubyte_l_sint8; 7638 7639 case MESA_FORMAT_L_SINT16: 7640 return pack_ubyte_l_sint16; 7641 7642 case MESA_FORMAT_L_SINT32: 7643 return pack_ubyte_l_sint32; 7644 7645 case MESA_FORMAT_LA_UINT8: 7646 return pack_ubyte_la_uint8; 7647 7648 case MESA_FORMAT_LA_UINT16: 7649 return pack_ubyte_la_uint16; 7650 7651 case MESA_FORMAT_LA_UINT32: 7652 return pack_ubyte_la_uint32; 7653 7654 case MESA_FORMAT_LA_SINT8: 7655 return pack_ubyte_la_sint8; 7656 7657 case MESA_FORMAT_LA_SINT16: 7658 return pack_ubyte_la_sint16; 7659 7660 case MESA_FORMAT_LA_SINT32: 7661 return pack_ubyte_la_sint32; 7662 7663 case MESA_FORMAT_R_UINT8: 7664 return pack_ubyte_r_uint8; 7665 7666 case MESA_FORMAT_R_UINT16: 7667 return pack_ubyte_r_uint16; 7668 7669 case MESA_FORMAT_R_UINT32: 7670 return pack_ubyte_r_uint32; 7671 7672 case MESA_FORMAT_R_SINT8: 7673 return pack_ubyte_r_sint8; 7674 7675 case MESA_FORMAT_R_SINT16: 7676 return pack_ubyte_r_sint16; 7677 7678 case MESA_FORMAT_R_SINT32: 7679 return pack_ubyte_r_sint32; 7680 7681 case MESA_FORMAT_RG_UINT8: 7682 return pack_ubyte_rg_uint8; 7683 7684 case MESA_FORMAT_RG_UINT16: 7685 return pack_ubyte_rg_uint16; 7686 7687 case MESA_FORMAT_RG_UINT32: 7688 return pack_ubyte_rg_uint32; 7689 7690 case MESA_FORMAT_RG_SINT8: 7691 return pack_ubyte_rg_sint8; 7692 7693 case MESA_FORMAT_RG_SINT16: 7694 return pack_ubyte_rg_sint16; 7695 7696 case MESA_FORMAT_RG_SINT32: 7697 return pack_ubyte_rg_sint32; 7698 7699 case MESA_FORMAT_RGB_UINT8: 7700 return pack_ubyte_rgb_uint8; 7701 7702 case MESA_FORMAT_RGB_UINT16: 7703 return pack_ubyte_rgb_uint16; 7704 7705 case MESA_FORMAT_RGB_UINT32: 7706 return pack_ubyte_rgb_uint32; 7707 7708 case MESA_FORMAT_RGB_SINT8: 7709 return pack_ubyte_rgb_sint8; 7710 7711 case MESA_FORMAT_RGB_SINT16: 7712 return pack_ubyte_rgb_sint16; 7713 7714 case MESA_FORMAT_RGB_SINT32: 7715 return pack_ubyte_rgb_sint32; 7716 7717 case MESA_FORMAT_RGBA_UINT8: 7718 return pack_ubyte_rgba_uint8; 7719 7720 case MESA_FORMAT_RGBA_UINT16: 7721 return pack_ubyte_rgba_uint16; 7722 7723 case MESA_FORMAT_RGBA_UINT32: 7724 return pack_ubyte_rgba_uint32; 7725 7726 case MESA_FORMAT_RGBA_SINT8: 7727 return pack_ubyte_rgba_sint8; 7728 7729 case MESA_FORMAT_RGBA_SINT16: 7730 return pack_ubyte_rgba_sint16; 7731 7732 case MESA_FORMAT_RGBA_SINT32: 7733 return pack_ubyte_rgba_sint32; 7734 7735 case MESA_FORMAT_RGBX_UINT8: 7736 return pack_ubyte_rgbx_uint8; 7737 7738 case MESA_FORMAT_RGBX_UINT16: 7739 return pack_ubyte_rgbx_uint16; 7740 7741 case MESA_FORMAT_RGBX_UINT32: 7742 return pack_ubyte_rgbx_uint32; 7743 7744 case MESA_FORMAT_RGBX_SINT8: 7745 return pack_ubyte_rgbx_sint8; 7746 7747 case MESA_FORMAT_RGBX_SINT16: 7748 return pack_ubyte_rgbx_sint16; 7749 7750 case MESA_FORMAT_RGBX_SINT32: 7751 return pack_ubyte_rgbx_sint32; 7752 default: 7753 return NULL; 7754 } 7755 } 7756 7757 /** 7758 * Return a function that can pack a GLfloat rgba[4] color. 7759 */ 7760 gl_pack_float_rgba_func 7761 _mesa_get_pack_float_rgba_function(mesa_format format) 7762 { 7763 switch (format) { 7764 7765 case MESA_FORMAT_A8B8G8R8_UNORM: 7766 return pack_float_a8b8g8r8_unorm; 7767 7768 case MESA_FORMAT_X8B8G8R8_UNORM: 7769 return pack_float_x8b8g8r8_unorm; 7770 7771 case MESA_FORMAT_R8G8B8A8_UNORM: 7772 return pack_float_r8g8b8a8_unorm; 7773 7774 case MESA_FORMAT_R8G8B8X8_UNORM: 7775 return pack_float_r8g8b8x8_unorm; 7776 7777 case MESA_FORMAT_B8G8R8A8_UNORM: 7778 return pack_float_b8g8r8a8_unorm; 7779 7780 case MESA_FORMAT_B8G8R8X8_UNORM: 7781 return pack_float_b8g8r8x8_unorm; 7782 7783 case MESA_FORMAT_A8R8G8B8_UNORM: 7784 return pack_float_a8r8g8b8_unorm; 7785 7786 case MESA_FORMAT_X8R8G8B8_UNORM: 7787 return pack_float_x8r8g8b8_unorm; 7788 7789 case MESA_FORMAT_L16A16_UNORM: 7790 return pack_float_l16a16_unorm; 7791 7792 case MESA_FORMAT_A16L16_UNORM: 7793 return pack_float_a16l16_unorm; 7794 7795 case MESA_FORMAT_B5G6R5_UNORM: 7796 return pack_float_b5g6r5_unorm; 7797 7798 case MESA_FORMAT_R5G6B5_UNORM: 7799 return pack_float_r5g6b5_unorm; 7800 7801 case MESA_FORMAT_B4G4R4A4_UNORM: 7802 return pack_float_b4g4r4a4_unorm; 7803 7804 case MESA_FORMAT_B4G4R4X4_UNORM: 7805 return pack_float_b4g4r4x4_unorm; 7806 7807 case MESA_FORMAT_A4R4G4B4_UNORM: 7808 return pack_float_a4r4g4b4_unorm; 7809 7810 case MESA_FORMAT_A1B5G5R5_UNORM: 7811 return pack_float_a1b5g5r5_unorm; 7812 7813 case MESA_FORMAT_B5G5R5A1_UNORM: 7814 return pack_float_b5g5r5a1_unorm; 7815 7816 case MESA_FORMAT_B5G5R5X1_UNORM: 7817 return pack_float_b5g5r5x1_unorm; 7818 7819 case MESA_FORMAT_A1R5G5B5_UNORM: 7820 return pack_float_a1r5g5b5_unorm; 7821 7822 case MESA_FORMAT_L8A8_UNORM: 7823 return pack_float_l8a8_unorm; 7824 7825 case MESA_FORMAT_A8L8_UNORM: 7826 return pack_float_a8l8_unorm; 7827 7828 case MESA_FORMAT_R8G8_UNORM: 7829 return pack_float_r8g8_unorm; 7830 7831 case MESA_FORMAT_G8R8_UNORM: 7832 return pack_float_g8r8_unorm; 7833 7834 case MESA_FORMAT_L4A4_UNORM: 7835 return pack_float_l4a4_unorm; 7836 7837 case MESA_FORMAT_B2G3R3_UNORM: 7838 return pack_float_b2g3r3_unorm; 7839 7840 case MESA_FORMAT_R16G16_UNORM: 7841 return pack_float_r16g16_unorm; 7842 7843 case MESA_FORMAT_G16R16_UNORM: 7844 return pack_float_g16r16_unorm; 7845 7846 case MESA_FORMAT_B10G10R10A2_UNORM: 7847 return pack_float_b10g10r10a2_unorm; 7848 7849 case MESA_FORMAT_B10G10R10X2_UNORM: 7850 return pack_float_b10g10r10x2_unorm; 7851 7852 case MESA_FORMAT_R10G10B10A2_UNORM: 7853 return pack_float_r10g10b10a2_unorm; 7854 7855 case MESA_FORMAT_R10G10B10X2_UNORM: 7856 return pack_float_r10g10b10x2_unorm; 7857 7858 case MESA_FORMAT_R3G3B2_UNORM: 7859 return pack_float_r3g3b2_unorm; 7860 7861 case MESA_FORMAT_A4B4G4R4_UNORM: 7862 return pack_float_a4b4g4r4_unorm; 7863 7864 case MESA_FORMAT_R4G4B4A4_UNORM: 7865 return pack_float_r4g4b4a4_unorm; 7866 7867 case MESA_FORMAT_R5G5B5A1_UNORM: 7868 return pack_float_r5g5b5a1_unorm; 7869 7870 case MESA_FORMAT_A2B10G10R10_UNORM: 7871 return pack_float_a2b10g10r10_unorm; 7872 7873 case MESA_FORMAT_A2R10G10B10_UNORM: 7874 return pack_float_a2r10g10b10_unorm; 7875 7876 case MESA_FORMAT_A_UNORM8: 7877 return pack_float_a_unorm8; 7878 7879 case MESA_FORMAT_A_UNORM16: 7880 return pack_float_a_unorm16; 7881 7882 case MESA_FORMAT_L_UNORM8: 7883 return pack_float_l_unorm8; 7884 7885 case MESA_FORMAT_L_UNORM16: 7886 return pack_float_l_unorm16; 7887 7888 case MESA_FORMAT_I_UNORM8: 7889 return pack_float_i_unorm8; 7890 7891 case MESA_FORMAT_I_UNORM16: 7892 return pack_float_i_unorm16; 7893 7894 case MESA_FORMAT_R_UNORM8: 7895 return pack_float_r_unorm8; 7896 7897 case MESA_FORMAT_R_UNORM16: 7898 return pack_float_r_unorm16; 7899 7900 case MESA_FORMAT_BGR_UNORM8: 7901 return pack_float_bgr_unorm8; 7902 7903 case MESA_FORMAT_RGB_UNORM8: 7904 return pack_float_rgb_unorm8; 7905 7906 case MESA_FORMAT_RGBA_UNORM16: 7907 return pack_float_rgba_unorm16; 7908 7909 case MESA_FORMAT_RGBX_UNORM16: 7910 return pack_float_rgbx_unorm16; 7911 7912 case MESA_FORMAT_A8B8G8R8_SNORM: 7913 return pack_float_a8b8g8r8_snorm; 7914 7915 case MESA_FORMAT_X8B8G8R8_SNORM: 7916 return pack_float_x8b8g8r8_snorm; 7917 7918 case MESA_FORMAT_R8G8B8A8_SNORM: 7919 return pack_float_r8g8b8a8_snorm; 7920 7921 case MESA_FORMAT_R8G8B8X8_SNORM: 7922 return pack_float_r8g8b8x8_snorm; 7923 7924 case MESA_FORMAT_R16G16_SNORM: 7925 return pack_float_r16g16_snorm; 7926 7927 case MESA_FORMAT_G16R16_SNORM: 7928 return pack_float_g16r16_snorm; 7929 7930 case MESA_FORMAT_R8G8_SNORM: 7931 return pack_float_r8g8_snorm; 7932 7933 case MESA_FORMAT_G8R8_SNORM: 7934 return pack_float_g8r8_snorm; 7935 7936 case MESA_FORMAT_L8A8_SNORM: 7937 return pack_float_l8a8_snorm; 7938 7939 case MESA_FORMAT_A8L8_SNORM: 7940 return pack_float_a8l8_snorm; 7941 7942 case MESA_FORMAT_A_SNORM8: 7943 return pack_float_a_snorm8; 7944 7945 case MESA_FORMAT_A_SNORM16: 7946 return pack_float_a_snorm16; 7947 7948 case MESA_FORMAT_L_SNORM8: 7949 return pack_float_l_snorm8; 7950 7951 case MESA_FORMAT_L_SNORM16: 7952 return pack_float_l_snorm16; 7953 7954 case MESA_FORMAT_I_SNORM8: 7955 return pack_float_i_snorm8; 7956 7957 case MESA_FORMAT_I_SNORM16: 7958 return pack_float_i_snorm16; 7959 7960 case MESA_FORMAT_R_SNORM8: 7961 return pack_float_r_snorm8; 7962 7963 case MESA_FORMAT_R_SNORM16: 7964 return pack_float_r_snorm16; 7965 7966 case MESA_FORMAT_LA_SNORM16: 7967 return pack_float_la_snorm16; 7968 7969 case MESA_FORMAT_RGB_SNORM16: 7970 return pack_float_rgb_snorm16; 7971 7972 case MESA_FORMAT_RGBA_SNORM16: 7973 return pack_float_rgba_snorm16; 7974 7975 case MESA_FORMAT_RGBX_SNORM16: 7976 return pack_float_rgbx_snorm16; 7977 7978 case MESA_FORMAT_A8B8G8R8_SRGB: 7979 return pack_float_a8b8g8r8_srgb; 7980 7981 case MESA_FORMAT_B8G8R8A8_SRGB: 7982 return pack_float_b8g8r8a8_srgb; 7983 7984 case MESA_FORMAT_A8R8G8B8_SRGB: 7985 return pack_float_a8r8g8b8_srgb; 7986 7987 case MESA_FORMAT_B8G8R8X8_SRGB: 7988 return pack_float_b8g8r8x8_srgb; 7989 7990 case MESA_FORMAT_X8R8G8B8_SRGB: 7991 return pack_float_x8r8g8b8_srgb; 7992 7993 case MESA_FORMAT_R8G8B8A8_SRGB: 7994 return pack_float_r8g8b8a8_srgb; 7995 7996 case MESA_FORMAT_R8G8B8X8_SRGB: 7997 return pack_float_r8g8b8x8_srgb; 7998 7999 case MESA_FORMAT_X8B8G8R8_SRGB: 8000 return pack_float_x8b8g8r8_srgb; 8001 8002 case MESA_FORMAT_L8A8_SRGB: 8003 return pack_float_l8a8_srgb; 8004 8005 case MESA_FORMAT_A8L8_SRGB: 8006 return pack_float_a8l8_srgb; 8007 8008 case MESA_FORMAT_L_SRGB8: 8009 return pack_float_l_srgb8; 8010 8011 case MESA_FORMAT_BGR_SRGB8: 8012 return pack_float_bgr_srgb8; 8013 8014 case MESA_FORMAT_R9G9B9E5_FLOAT: 8015 return pack_float_r9g9b9e5_float; 8016 8017 case MESA_FORMAT_R11G11B10_FLOAT: 8018 return pack_float_r11g11b10_float; 8019 8020 case MESA_FORMAT_A_FLOAT16: 8021 return pack_float_a_float16; 8022 8023 case MESA_FORMAT_A_FLOAT32: 8024 return pack_float_a_float32; 8025 8026 case MESA_FORMAT_L_FLOAT16: 8027 return pack_float_l_float16; 8028 8029 case MESA_FORMAT_L_FLOAT32: 8030 return pack_float_l_float32; 8031 8032 case MESA_FORMAT_LA_FLOAT16: 8033 return pack_float_la_float16; 8034 8035 case MESA_FORMAT_LA_FLOAT32: 8036 return pack_float_la_float32; 8037 8038 case MESA_FORMAT_I_FLOAT16: 8039 return pack_float_i_float16; 8040 8041 case MESA_FORMAT_I_FLOAT32: 8042 return pack_float_i_float32; 8043 8044 case MESA_FORMAT_R_FLOAT16: 8045 return pack_float_r_float16; 8046 8047 case MESA_FORMAT_R_FLOAT32: 8048 return pack_float_r_float32; 8049 8050 case MESA_FORMAT_RG_FLOAT16: 8051 return pack_float_rg_float16; 8052 8053 case MESA_FORMAT_RG_FLOAT32: 8054 return pack_float_rg_float32; 8055 8056 case MESA_FORMAT_RGB_FLOAT16: 8057 return pack_float_rgb_float16; 8058 8059 case MESA_FORMAT_RGB_FLOAT32: 8060 return pack_float_rgb_float32; 8061 8062 case MESA_FORMAT_RGBA_FLOAT16: 8063 return pack_float_rgba_float16; 8064 8065 case MESA_FORMAT_RGBA_FLOAT32: 8066 return pack_float_rgba_float32; 8067 8068 case MESA_FORMAT_RGBX_FLOAT16: 8069 return pack_float_rgbx_float16; 8070 8071 case MESA_FORMAT_RGBX_FLOAT32: 8072 return pack_float_rgbx_float32; 8073 default: 8074 return NULL; 8075 } 8076 } 8077 8078 /** 8079 * Pack a row of GLubyte rgba[4] values to the destination. 8080 */ 8081 void 8082 _mesa_pack_ubyte_rgba_row(mesa_format format, GLuint n, 8083 const GLubyte src[][4], void *dst) 8084 { 8085 GLuint i; 8086 GLubyte *d = dst; 8087 8088 switch (format) { 8089 8090 case MESA_FORMAT_A8B8G8R8_UNORM: 8091 for (i = 0; i < n; ++i) { 8092 pack_ubyte_a8b8g8r8_unorm(src[i], d); 8093 d += 4; 8094 } 8095 break; 8096 8097 case MESA_FORMAT_X8B8G8R8_UNORM: 8098 for (i = 0; i < n; ++i) { 8099 pack_ubyte_x8b8g8r8_unorm(src[i], d); 8100 d += 4; 8101 } 8102 break; 8103 8104 case MESA_FORMAT_R8G8B8A8_UNORM: 8105 for (i = 0; i < n; ++i) { 8106 pack_ubyte_r8g8b8a8_unorm(src[i], d); 8107 d += 4; 8108 } 8109 break; 8110 8111 case MESA_FORMAT_R8G8B8X8_UNORM: 8112 for (i = 0; i < n; ++i) { 8113 pack_ubyte_r8g8b8x8_unorm(src[i], d); 8114 d += 4; 8115 } 8116 break; 8117 8118 case MESA_FORMAT_B8G8R8A8_UNORM: 8119 for (i = 0; i < n; ++i) { 8120 pack_ubyte_b8g8r8a8_unorm(src[i], d); 8121 d += 4; 8122 } 8123 break; 8124 8125 case MESA_FORMAT_B8G8R8X8_UNORM: 8126 for (i = 0; i < n; ++i) { 8127 pack_ubyte_b8g8r8x8_unorm(src[i], d); 8128 d += 4; 8129 } 8130 break; 8131 8132 case MESA_FORMAT_A8R8G8B8_UNORM: 8133 for (i = 0; i < n; ++i) { 8134 pack_ubyte_a8r8g8b8_unorm(src[i], d); 8135 d += 4; 8136 } 8137 break; 8138 8139 case MESA_FORMAT_X8R8G8B8_UNORM: 8140 for (i = 0; i < n; ++i) { 8141 pack_ubyte_x8r8g8b8_unorm(src[i], d); 8142 d += 4; 8143 } 8144 break; 8145 8146 case MESA_FORMAT_L16A16_UNORM: 8147 for (i = 0; i < n; ++i) { 8148 pack_ubyte_l16a16_unorm(src[i], d); 8149 d += 4; 8150 } 8151 break; 8152 8153 case MESA_FORMAT_A16L16_UNORM: 8154 for (i = 0; i < n; ++i) { 8155 pack_ubyte_a16l16_unorm(src[i], d); 8156 d += 4; 8157 } 8158 break; 8159 8160 case MESA_FORMAT_B5G6R5_UNORM: 8161 for (i = 0; i < n; ++i) { 8162 pack_ubyte_b5g6r5_unorm(src[i], d); 8163 d += 2; 8164 } 8165 break; 8166 8167 case MESA_FORMAT_R5G6B5_UNORM: 8168 for (i = 0; i < n; ++i) { 8169 pack_ubyte_r5g6b5_unorm(src[i], d); 8170 d += 2; 8171 } 8172 break; 8173 8174 case MESA_FORMAT_B4G4R4A4_UNORM: 8175 for (i = 0; i < n; ++i) { 8176 pack_ubyte_b4g4r4a4_unorm(src[i], d); 8177 d += 2; 8178 } 8179 break; 8180 8181 case MESA_FORMAT_B4G4R4X4_UNORM: 8182 for (i = 0; i < n; ++i) { 8183 pack_ubyte_b4g4r4x4_unorm(src[i], d); 8184 d += 2; 8185 } 8186 break; 8187 8188 case MESA_FORMAT_A4R4G4B4_UNORM: 8189 for (i = 0; i < n; ++i) { 8190 pack_ubyte_a4r4g4b4_unorm(src[i], d); 8191 d += 2; 8192 } 8193 break; 8194 8195 case MESA_FORMAT_A1B5G5R5_UNORM: 8196 for (i = 0; i < n; ++i) { 8197 pack_ubyte_a1b5g5r5_unorm(src[i], d); 8198 d += 2; 8199 } 8200 break; 8201 8202 case MESA_FORMAT_B5G5R5A1_UNORM: 8203 for (i = 0; i < n; ++i) { 8204 pack_ubyte_b5g5r5a1_unorm(src[i], d); 8205 d += 2; 8206 } 8207 break; 8208 8209 case MESA_FORMAT_B5G5R5X1_UNORM: 8210 for (i = 0; i < n; ++i) { 8211 pack_ubyte_b5g5r5x1_unorm(src[i], d); 8212 d += 2; 8213 } 8214 break; 8215 8216 case MESA_FORMAT_A1R5G5B5_UNORM: 8217 for (i = 0; i < n; ++i) { 8218 pack_ubyte_a1r5g5b5_unorm(src[i], d); 8219 d += 2; 8220 } 8221 break; 8222 8223 case MESA_FORMAT_L8A8_UNORM: 8224 for (i = 0; i < n; ++i) { 8225 pack_ubyte_l8a8_unorm(src[i], d); 8226 d += 2; 8227 } 8228 break; 8229 8230 case MESA_FORMAT_A8L8_UNORM: 8231 for (i = 0; i < n; ++i) { 8232 pack_ubyte_a8l8_unorm(src[i], d); 8233 d += 2; 8234 } 8235 break; 8236 8237 case MESA_FORMAT_R8G8_UNORM: 8238 for (i = 0; i < n; ++i) { 8239 pack_ubyte_r8g8_unorm(src[i], d); 8240 d += 2; 8241 } 8242 break; 8243 8244 case MESA_FORMAT_G8R8_UNORM: 8245 for (i = 0; i < n; ++i) { 8246 pack_ubyte_g8r8_unorm(src[i], d); 8247 d += 2; 8248 } 8249 break; 8250 8251 case MESA_FORMAT_L4A4_UNORM: 8252 for (i = 0; i < n; ++i) { 8253 pack_ubyte_l4a4_unorm(src[i], d); 8254 d += 1; 8255 } 8256 break; 8257 8258 case MESA_FORMAT_B2G3R3_UNORM: 8259 for (i = 0; i < n; ++i) { 8260 pack_ubyte_b2g3r3_unorm(src[i], d); 8261 d += 1; 8262 } 8263 break; 8264 8265 case MESA_FORMAT_R16G16_UNORM: 8266 for (i = 0; i < n; ++i) { 8267 pack_ubyte_r16g16_unorm(src[i], d); 8268 d += 4; 8269 } 8270 break; 8271 8272 case MESA_FORMAT_G16R16_UNORM: 8273 for (i = 0; i < n; ++i) { 8274 pack_ubyte_g16r16_unorm(src[i], d); 8275 d += 4; 8276 } 8277 break; 8278 8279 case MESA_FORMAT_B10G10R10A2_UNORM: 8280 for (i = 0; i < n; ++i) { 8281 pack_ubyte_b10g10r10a2_unorm(src[i], d); 8282 d += 4; 8283 } 8284 break; 8285 8286 case MESA_FORMAT_B10G10R10X2_UNORM: 8287 for (i = 0; i < n; ++i) { 8288 pack_ubyte_b10g10r10x2_unorm(src[i], d); 8289 d += 4; 8290 } 8291 break; 8292 8293 case MESA_FORMAT_R10G10B10A2_UNORM: 8294 for (i = 0; i < n; ++i) { 8295 pack_ubyte_r10g10b10a2_unorm(src[i], d); 8296 d += 4; 8297 } 8298 break; 8299 8300 case MESA_FORMAT_R10G10B10X2_UNORM: 8301 for (i = 0; i < n; ++i) { 8302 pack_ubyte_r10g10b10x2_unorm(src[i], d); 8303 d += 4; 8304 } 8305 break; 8306 8307 case MESA_FORMAT_R3G3B2_UNORM: 8308 for (i = 0; i < n; ++i) { 8309 pack_ubyte_r3g3b2_unorm(src[i], d); 8310 d += 1; 8311 } 8312 break; 8313 8314 case MESA_FORMAT_A4B4G4R4_UNORM: 8315 for (i = 0; i < n; ++i) { 8316 pack_ubyte_a4b4g4r4_unorm(src[i], d); 8317 d += 2; 8318 } 8319 break; 8320 8321 case MESA_FORMAT_R4G4B4A4_UNORM: 8322 for (i = 0; i < n; ++i) { 8323 pack_ubyte_r4g4b4a4_unorm(src[i], d); 8324 d += 2; 8325 } 8326 break; 8327 8328 case MESA_FORMAT_R5G5B5A1_UNORM: 8329 for (i = 0; i < n; ++i) { 8330 pack_ubyte_r5g5b5a1_unorm(src[i], d); 8331 d += 2; 8332 } 8333 break; 8334 8335 case MESA_FORMAT_A2B10G10R10_UNORM: 8336 for (i = 0; i < n; ++i) { 8337 pack_ubyte_a2b10g10r10_unorm(src[i], d); 8338 d += 4; 8339 } 8340 break; 8341 8342 case MESA_FORMAT_A2R10G10B10_UNORM: 8343 for (i = 0; i < n; ++i) { 8344 pack_ubyte_a2r10g10b10_unorm(src[i], d); 8345 d += 4; 8346 } 8347 break; 8348 8349 case MESA_FORMAT_A_UNORM8: 8350 for (i = 0; i < n; ++i) { 8351 pack_ubyte_a_unorm8(src[i], d); 8352 d += 1; 8353 } 8354 break; 8355 8356 case MESA_FORMAT_A_UNORM16: 8357 for (i = 0; i < n; ++i) { 8358 pack_ubyte_a_unorm16(src[i], d); 8359 d += 2; 8360 } 8361 break; 8362 8363 case MESA_FORMAT_L_UNORM8: 8364 for (i = 0; i < n; ++i) { 8365 pack_ubyte_l_unorm8(src[i], d); 8366 d += 1; 8367 } 8368 break; 8369 8370 case MESA_FORMAT_L_UNORM16: 8371 for (i = 0; i < n; ++i) { 8372 pack_ubyte_l_unorm16(src[i], d); 8373 d += 2; 8374 } 8375 break; 8376 8377 case MESA_FORMAT_I_UNORM8: 8378 for (i = 0; i < n; ++i) { 8379 pack_ubyte_i_unorm8(src[i], d); 8380 d += 1; 8381 } 8382 break; 8383 8384 case MESA_FORMAT_I_UNORM16: 8385 for (i = 0; i < n; ++i) { 8386 pack_ubyte_i_unorm16(src[i], d); 8387 d += 2; 8388 } 8389 break; 8390 8391 case MESA_FORMAT_R_UNORM8: 8392 for (i = 0; i < n; ++i) { 8393 pack_ubyte_r_unorm8(src[i], d); 8394 d += 1; 8395 } 8396 break; 8397 8398 case MESA_FORMAT_R_UNORM16: 8399 for (i = 0; i < n; ++i) { 8400 pack_ubyte_r_unorm16(src[i], d); 8401 d += 2; 8402 } 8403 break; 8404 8405 case MESA_FORMAT_BGR_UNORM8: 8406 for (i = 0; i < n; ++i) { 8407 pack_ubyte_bgr_unorm8(src[i], d); 8408 d += 3; 8409 } 8410 break; 8411 8412 case MESA_FORMAT_RGB_UNORM8: 8413 for (i = 0; i < n; ++i) { 8414 pack_ubyte_rgb_unorm8(src[i], d); 8415 d += 3; 8416 } 8417 break; 8418 8419 case MESA_FORMAT_RGBA_UNORM16: 8420 for (i = 0; i < n; ++i) { 8421 pack_ubyte_rgba_unorm16(src[i], d); 8422 d += 8; 8423 } 8424 break; 8425 8426 case MESA_FORMAT_RGBX_UNORM16: 8427 for (i = 0; i < n; ++i) { 8428 pack_ubyte_rgbx_unorm16(src[i], d); 8429 d += 8; 8430 } 8431 break; 8432 8433 case MESA_FORMAT_A8B8G8R8_SNORM: 8434 for (i = 0; i < n; ++i) { 8435 pack_ubyte_a8b8g8r8_snorm(src[i], d); 8436 d += 4; 8437 } 8438 break; 8439 8440 case MESA_FORMAT_X8B8G8R8_SNORM: 8441 for (i = 0; i < n; ++i) { 8442 pack_ubyte_x8b8g8r8_snorm(src[i], d); 8443 d += 4; 8444 } 8445 break; 8446 8447 case MESA_FORMAT_R8G8B8A8_SNORM: 8448 for (i = 0; i < n; ++i) { 8449 pack_ubyte_r8g8b8a8_snorm(src[i], d); 8450 d += 4; 8451 } 8452 break; 8453 8454 case MESA_FORMAT_R8G8B8X8_SNORM: 8455 for (i = 0; i < n; ++i) { 8456 pack_ubyte_r8g8b8x8_snorm(src[i], d); 8457 d += 4; 8458 } 8459 break; 8460 8461 case MESA_FORMAT_R16G16_SNORM: 8462 for (i = 0; i < n; ++i) { 8463 pack_ubyte_r16g16_snorm(src[i], d); 8464 d += 4; 8465 } 8466 break; 8467 8468 case MESA_FORMAT_G16R16_SNORM: 8469 for (i = 0; i < n; ++i) { 8470 pack_ubyte_g16r16_snorm(src[i], d); 8471 d += 4; 8472 } 8473 break; 8474 8475 case MESA_FORMAT_R8G8_SNORM: 8476 for (i = 0; i < n; ++i) { 8477 pack_ubyte_r8g8_snorm(src[i], d); 8478 d += 2; 8479 } 8480 break; 8481 8482 case MESA_FORMAT_G8R8_SNORM: 8483 for (i = 0; i < n; ++i) { 8484 pack_ubyte_g8r8_snorm(src[i], d); 8485 d += 2; 8486 } 8487 break; 8488 8489 case MESA_FORMAT_L8A8_SNORM: 8490 for (i = 0; i < n; ++i) { 8491 pack_ubyte_l8a8_snorm(src[i], d); 8492 d += 2; 8493 } 8494 break; 8495 8496 case MESA_FORMAT_A8L8_SNORM: 8497 for (i = 0; i < n; ++i) { 8498 pack_ubyte_a8l8_snorm(src[i], d); 8499 d += 2; 8500 } 8501 break; 8502 8503 case MESA_FORMAT_A_SNORM8: 8504 for (i = 0; i < n; ++i) { 8505 pack_ubyte_a_snorm8(src[i], d); 8506 d += 1; 8507 } 8508 break; 8509 8510 case MESA_FORMAT_A_SNORM16: 8511 for (i = 0; i < n; ++i) { 8512 pack_ubyte_a_snorm16(src[i], d); 8513 d += 2; 8514 } 8515 break; 8516 8517 case MESA_FORMAT_L_SNORM8: 8518 for (i = 0; i < n; ++i) { 8519 pack_ubyte_l_snorm8(src[i], d); 8520 d += 1; 8521 } 8522 break; 8523 8524 case MESA_FORMAT_L_SNORM16: 8525 for (i = 0; i < n; ++i) { 8526 pack_ubyte_l_snorm16(src[i], d); 8527 d += 2; 8528 } 8529 break; 8530 8531 case MESA_FORMAT_I_SNORM8: 8532 for (i = 0; i < n; ++i) { 8533 pack_ubyte_i_snorm8(src[i], d); 8534 d += 1; 8535 } 8536 break; 8537 8538 case MESA_FORMAT_I_SNORM16: 8539 for (i = 0; i < n; ++i) { 8540 pack_ubyte_i_snorm16(src[i], d); 8541 d += 2; 8542 } 8543 break; 8544 8545 case MESA_FORMAT_R_SNORM8: 8546 for (i = 0; i < n; ++i) { 8547 pack_ubyte_r_snorm8(src[i], d); 8548 d += 1; 8549 } 8550 break; 8551 8552 case MESA_FORMAT_R_SNORM16: 8553 for (i = 0; i < n; ++i) { 8554 pack_ubyte_r_snorm16(src[i], d); 8555 d += 2; 8556 } 8557 break; 8558 8559 case MESA_FORMAT_LA_SNORM16: 8560 for (i = 0; i < n; ++i) { 8561 pack_ubyte_la_snorm16(src[i], d); 8562 d += 4; 8563 } 8564 break; 8565 8566 case MESA_FORMAT_RGB_SNORM16: 8567 for (i = 0; i < n; ++i) { 8568 pack_ubyte_rgb_snorm16(src[i], d); 8569 d += 6; 8570 } 8571 break; 8572 8573 case MESA_FORMAT_RGBA_SNORM16: 8574 for (i = 0; i < n; ++i) { 8575 pack_ubyte_rgba_snorm16(src[i], d); 8576 d += 8; 8577 } 8578 break; 8579 8580 case MESA_FORMAT_RGBX_SNORM16: 8581 for (i = 0; i < n; ++i) { 8582 pack_ubyte_rgbx_snorm16(src[i], d); 8583 d += 8; 8584 } 8585 break; 8586 8587 case MESA_FORMAT_A8B8G8R8_SRGB: 8588 for (i = 0; i < n; ++i) { 8589 pack_ubyte_a8b8g8r8_srgb(src[i], d); 8590 d += 4; 8591 } 8592 break; 8593 8594 case MESA_FORMAT_B8G8R8A8_SRGB: 8595 for (i = 0; i < n; ++i) { 8596 pack_ubyte_b8g8r8a8_srgb(src[i], d); 8597 d += 4; 8598 } 8599 break; 8600 8601 case MESA_FORMAT_A8R8G8B8_SRGB: 8602 for (i = 0; i < n; ++i) { 8603 pack_ubyte_a8r8g8b8_srgb(src[i], d); 8604 d += 4; 8605 } 8606 break; 8607 8608 case MESA_FORMAT_B8G8R8X8_SRGB: 8609 for (i = 0; i < n; ++i) { 8610 pack_ubyte_b8g8r8x8_srgb(src[i], d); 8611 d += 4; 8612 } 8613 break; 8614 8615 case MESA_FORMAT_X8R8G8B8_SRGB: 8616 for (i = 0; i < n; ++i) { 8617 pack_ubyte_x8r8g8b8_srgb(src[i], d); 8618 d += 4; 8619 } 8620 break; 8621 8622 case MESA_FORMAT_R8G8B8A8_SRGB: 8623 for (i = 0; i < n; ++i) { 8624 pack_ubyte_r8g8b8a8_srgb(src[i], d); 8625 d += 4; 8626 } 8627 break; 8628 8629 case MESA_FORMAT_R8G8B8X8_SRGB: 8630 for (i = 0; i < n; ++i) { 8631 pack_ubyte_r8g8b8x8_srgb(src[i], d); 8632 d += 4; 8633 } 8634 break; 8635 8636 case MESA_FORMAT_X8B8G8R8_SRGB: 8637 for (i = 0; i < n; ++i) { 8638 pack_ubyte_x8b8g8r8_srgb(src[i], d); 8639 d += 4; 8640 } 8641 break; 8642 8643 case MESA_FORMAT_L8A8_SRGB: 8644 for (i = 0; i < n; ++i) { 8645 pack_ubyte_l8a8_srgb(src[i], d); 8646 d += 2; 8647 } 8648 break; 8649 8650 case MESA_FORMAT_A8L8_SRGB: 8651 for (i = 0; i < n; ++i) { 8652 pack_ubyte_a8l8_srgb(src[i], d); 8653 d += 2; 8654 } 8655 break; 8656 8657 case MESA_FORMAT_L_SRGB8: 8658 for (i = 0; i < n; ++i) { 8659 pack_ubyte_l_srgb8(src[i], d); 8660 d += 1; 8661 } 8662 break; 8663 8664 case MESA_FORMAT_BGR_SRGB8: 8665 for (i = 0; i < n; ++i) { 8666 pack_ubyte_bgr_srgb8(src[i], d); 8667 d += 3; 8668 } 8669 break; 8670 8671 case MESA_FORMAT_R9G9B9E5_FLOAT: 8672 for (i = 0; i < n; ++i) { 8673 pack_ubyte_r9g9b9e5_float(src[i], d); 8674 d += 4; 8675 } 8676 break; 8677 8678 case MESA_FORMAT_R11G11B10_FLOAT: 8679 for (i = 0; i < n; ++i) { 8680 pack_ubyte_r11g11b10_float(src[i], d); 8681 d += 4; 8682 } 8683 break; 8684 8685 case MESA_FORMAT_A_FLOAT16: 8686 for (i = 0; i < n; ++i) { 8687 pack_ubyte_a_float16(src[i], d); 8688 d += 2; 8689 } 8690 break; 8691 8692 case MESA_FORMAT_A_FLOAT32: 8693 for (i = 0; i < n; ++i) { 8694 pack_ubyte_a_float32(src[i], d); 8695 d += 4; 8696 } 8697 break; 8698 8699 case MESA_FORMAT_L_FLOAT16: 8700 for (i = 0; i < n; ++i) { 8701 pack_ubyte_l_float16(src[i], d); 8702 d += 2; 8703 } 8704 break; 8705 8706 case MESA_FORMAT_L_FLOAT32: 8707 for (i = 0; i < n; ++i) { 8708 pack_ubyte_l_float32(src[i], d); 8709 d += 4; 8710 } 8711 break; 8712 8713 case MESA_FORMAT_LA_FLOAT16: 8714 for (i = 0; i < n; ++i) { 8715 pack_ubyte_la_float16(src[i], d); 8716 d += 4; 8717 } 8718 break; 8719 8720 case MESA_FORMAT_LA_FLOAT32: 8721 for (i = 0; i < n; ++i) { 8722 pack_ubyte_la_float32(src[i], d); 8723 d += 8; 8724 } 8725 break; 8726 8727 case MESA_FORMAT_I_FLOAT16: 8728 for (i = 0; i < n; ++i) { 8729 pack_ubyte_i_float16(src[i], d); 8730 d += 2; 8731 } 8732 break; 8733 8734 case MESA_FORMAT_I_FLOAT32: 8735 for (i = 0; i < n; ++i) { 8736 pack_ubyte_i_float32(src[i], d); 8737 d += 4; 8738 } 8739 break; 8740 8741 case MESA_FORMAT_R_FLOAT16: 8742 for (i = 0; i < n; ++i) { 8743 pack_ubyte_r_float16(src[i], d); 8744 d += 2; 8745 } 8746 break; 8747 8748 case MESA_FORMAT_R_FLOAT32: 8749 for (i = 0; i < n; ++i) { 8750 pack_ubyte_r_float32(src[i], d); 8751 d += 4; 8752 } 8753 break; 8754 8755 case MESA_FORMAT_RG_FLOAT16: 8756 for (i = 0; i < n; ++i) { 8757 pack_ubyte_rg_float16(src[i], d); 8758 d += 4; 8759 } 8760 break; 8761 8762 case MESA_FORMAT_RG_FLOAT32: 8763 for (i = 0; i < n; ++i) { 8764 pack_ubyte_rg_float32(src[i], d); 8765 d += 8; 8766 } 8767 break; 8768 8769 case MESA_FORMAT_RGB_FLOAT16: 8770 for (i = 0; i < n; ++i) { 8771 pack_ubyte_rgb_float16(src[i], d); 8772 d += 6; 8773 } 8774 break; 8775 8776 case MESA_FORMAT_RGB_FLOAT32: 8777 for (i = 0; i < n; ++i) { 8778 pack_ubyte_rgb_float32(src[i], d); 8779 d += 12; 8780 } 8781 break; 8782 8783 case MESA_FORMAT_RGBA_FLOAT16: 8784 for (i = 0; i < n; ++i) { 8785 pack_ubyte_rgba_float16(src[i], d); 8786 d += 8; 8787 } 8788 break; 8789 8790 case MESA_FORMAT_RGBA_FLOAT32: 8791 for (i = 0; i < n; ++i) { 8792 pack_ubyte_rgba_float32(src[i], d); 8793 d += 16; 8794 } 8795 break; 8796 8797 case MESA_FORMAT_RGBX_FLOAT16: 8798 for (i = 0; i < n; ++i) { 8799 pack_ubyte_rgbx_float16(src[i], d); 8800 d += 8; 8801 } 8802 break; 8803 8804 case MESA_FORMAT_RGBX_FLOAT32: 8805 for (i = 0; i < n; ++i) { 8806 pack_ubyte_rgbx_float32(src[i], d); 8807 d += 16; 8808 } 8809 break; 8810 8811 case MESA_FORMAT_A8B8G8R8_UINT: 8812 for (i = 0; i < n; ++i) { 8813 pack_ubyte_a8b8g8r8_uint(src[i], d); 8814 d += 4; 8815 } 8816 break; 8817 8818 case MESA_FORMAT_A8R8G8B8_UINT: 8819 for (i = 0; i < n; ++i) { 8820 pack_ubyte_a8r8g8b8_uint(src[i], d); 8821 d += 4; 8822 } 8823 break; 8824 8825 case MESA_FORMAT_R8G8B8A8_UINT: 8826 for (i = 0; i < n; ++i) { 8827 pack_ubyte_r8g8b8a8_uint(src[i], d); 8828 d += 4; 8829 } 8830 break; 8831 8832 case MESA_FORMAT_B8G8R8A8_UINT: 8833 for (i = 0; i < n; ++i) { 8834 pack_ubyte_b8g8r8a8_uint(src[i], d); 8835 d += 4; 8836 } 8837 break; 8838 8839 case MESA_FORMAT_B10G10R10A2_UINT: 8840 for (i = 0; i < n; ++i) { 8841 pack_ubyte_b10g10r10a2_uint(src[i], d); 8842 d += 4; 8843 } 8844 break; 8845 8846 case MESA_FORMAT_R10G10B10A2_UINT: 8847 for (i = 0; i < n; ++i) { 8848 pack_ubyte_r10g10b10a2_uint(src[i], d); 8849 d += 4; 8850 } 8851 break; 8852 8853 case MESA_FORMAT_A2B10G10R10_UINT: 8854 for (i = 0; i < n; ++i) { 8855 pack_ubyte_a2b10g10r10_uint(src[i], d); 8856 d += 4; 8857 } 8858 break; 8859 8860 case MESA_FORMAT_A2R10G10B10_UINT: 8861 for (i = 0; i < n; ++i) { 8862 pack_ubyte_a2r10g10b10_uint(src[i], d); 8863 d += 4; 8864 } 8865 break; 8866 8867 case MESA_FORMAT_B5G6R5_UINT: 8868 for (i = 0; i < n; ++i) { 8869 pack_ubyte_b5g6r5_uint(src[i], d); 8870 d += 2; 8871 } 8872 break; 8873 8874 case MESA_FORMAT_R5G6B5_UINT: 8875 for (i = 0; i < n; ++i) { 8876 pack_ubyte_r5g6b5_uint(src[i], d); 8877 d += 2; 8878 } 8879 break; 8880 8881 case MESA_FORMAT_B2G3R3_UINT: 8882 for (i = 0; i < n; ++i) { 8883 pack_ubyte_b2g3r3_uint(src[i], d); 8884 d += 1; 8885 } 8886 break; 8887 8888 case MESA_FORMAT_R3G3B2_UINT: 8889 for (i = 0; i < n; ++i) { 8890 pack_ubyte_r3g3b2_uint(src[i], d); 8891 d += 1; 8892 } 8893 break; 8894 8895 case MESA_FORMAT_A4B4G4R4_UINT: 8896 for (i = 0; i < n; ++i) { 8897 pack_ubyte_a4b4g4r4_uint(src[i], d); 8898 d += 2; 8899 } 8900 break; 8901 8902 case MESA_FORMAT_R4G4B4A4_UINT: 8903 for (i = 0; i < n; ++i) { 8904 pack_ubyte_r4g4b4a4_uint(src[i], d); 8905 d += 2; 8906 } 8907 break; 8908 8909 case MESA_FORMAT_B4G4R4A4_UINT: 8910 for (i = 0; i < n; ++i) { 8911 pack_ubyte_b4g4r4a4_uint(src[i], d); 8912 d += 2; 8913 } 8914 break; 8915 8916 case MESA_FORMAT_A4R4G4B4_UINT: 8917 for (i = 0; i < n; ++i) { 8918 pack_ubyte_a4r4g4b4_uint(src[i], d); 8919 d += 2; 8920 } 8921 break; 8922 8923 case MESA_FORMAT_A1B5G5R5_UINT: 8924 for (i = 0; i < n; ++i) { 8925 pack_ubyte_a1b5g5r5_uint(src[i], d); 8926 d += 2; 8927 } 8928 break; 8929 8930 case MESA_FORMAT_B5G5R5A1_UINT: 8931 for (i = 0; i < n; ++i) { 8932 pack_ubyte_b5g5r5a1_uint(src[i], d); 8933 d += 2; 8934 } 8935 break; 8936 8937 case MESA_FORMAT_A1R5G5B5_UINT: 8938 for (i = 0; i < n; ++i) { 8939 pack_ubyte_a1r5g5b5_uint(src[i], d); 8940 d += 2; 8941 } 8942 break; 8943 8944 case MESA_FORMAT_R5G5B5A1_UINT: 8945 for (i = 0; i < n; ++i) { 8946 pack_ubyte_r5g5b5a1_uint(src[i], d); 8947 d += 2; 8948 } 8949 break; 8950 8951 case MESA_FORMAT_A_UINT8: 8952 for (i = 0; i < n; ++i) { 8953 pack_ubyte_a_uint8(src[i], d); 8954 d += 1; 8955 } 8956 break; 8957 8958 case MESA_FORMAT_A_UINT16: 8959 for (i = 0; i < n; ++i) { 8960 pack_ubyte_a_uint16(src[i], d); 8961 d += 2; 8962 } 8963 break; 8964 8965 case MESA_FORMAT_A_UINT32: 8966 for (i = 0; i < n; ++i) { 8967 pack_ubyte_a_uint32(src[i], d); 8968 d += 4; 8969 } 8970 break; 8971 8972 case MESA_FORMAT_A_SINT8: 8973 for (i = 0; i < n; ++i) { 8974 pack_ubyte_a_sint8(src[i], d); 8975 d += 1; 8976 } 8977 break; 8978 8979 case MESA_FORMAT_A_SINT16: 8980 for (i = 0; i < n; ++i) { 8981 pack_ubyte_a_sint16(src[i], d); 8982 d += 2; 8983 } 8984 break; 8985 8986 case MESA_FORMAT_A_SINT32: 8987 for (i = 0; i < n; ++i) { 8988 pack_ubyte_a_sint32(src[i], d); 8989 d += 4; 8990 } 8991 break; 8992 8993 case MESA_FORMAT_I_UINT8: 8994 for (i = 0; i < n; ++i) { 8995 pack_ubyte_i_uint8(src[i], d); 8996 d += 1; 8997 } 8998 break; 8999 9000 case MESA_FORMAT_I_UINT16: 9001 for (i = 0; i < n; ++i) { 9002 pack_ubyte_i_uint16(src[i], d); 9003 d += 2; 9004 } 9005 break; 9006 9007 case MESA_FORMAT_I_UINT32: 9008 for (i = 0; i < n; ++i) { 9009 pack_ubyte_i_uint32(src[i], d); 9010 d += 4; 9011 } 9012 break; 9013 9014 case MESA_FORMAT_I_SINT8: 9015 for (i = 0; i < n; ++i) { 9016 pack_ubyte_i_sint8(src[i], d); 9017 d += 1; 9018 } 9019 break; 9020 9021 case MESA_FORMAT_I_SINT16: 9022 for (i = 0; i < n; ++i) { 9023 pack_ubyte_i_sint16(src[i], d); 9024 d += 2; 9025 } 9026 break; 9027 9028 case MESA_FORMAT_I_SINT32: 9029 for (i = 0; i < n; ++i) { 9030 pack_ubyte_i_sint32(src[i], d); 9031 d += 4; 9032 } 9033 break; 9034 9035 case MESA_FORMAT_L_UINT8: 9036 for (i = 0; i < n; ++i) { 9037 pack_ubyte_l_uint8(src[i], d); 9038 d += 1; 9039 } 9040 break; 9041 9042 case MESA_FORMAT_L_UINT16: 9043 for (i = 0; i < n; ++i) { 9044 pack_ubyte_l_uint16(src[i], d); 9045 d += 2; 9046 } 9047 break; 9048 9049 case MESA_FORMAT_L_UINT32: 9050 for (i = 0; i < n; ++i) { 9051 pack_ubyte_l_uint32(src[i], d); 9052 d += 4; 9053 } 9054 break; 9055 9056 case MESA_FORMAT_L_SINT8: 9057 for (i = 0; i < n; ++i) { 9058 pack_ubyte_l_sint8(src[i], d); 9059 d += 1; 9060 } 9061 break; 9062 9063 case MESA_FORMAT_L_SINT16: 9064 for (i = 0; i < n; ++i) { 9065 pack_ubyte_l_sint16(src[i], d); 9066 d += 2; 9067 } 9068 break; 9069 9070 case MESA_FORMAT_L_SINT32: 9071 for (i = 0; i < n; ++i) { 9072 pack_ubyte_l_sint32(src[i], d); 9073 d += 4; 9074 } 9075 break; 9076 9077 case MESA_FORMAT_LA_UINT8: 9078 for (i = 0; i < n; ++i) { 9079 pack_ubyte_la_uint8(src[i], d); 9080 d += 2; 9081 } 9082 break; 9083 9084 case MESA_FORMAT_LA_UINT16: 9085 for (i = 0; i < n; ++i) { 9086 pack_ubyte_la_uint16(src[i], d); 9087 d += 4; 9088 } 9089 break; 9090 9091 case MESA_FORMAT_LA_UINT32: 9092 for (i = 0; i < n; ++i) { 9093 pack_ubyte_la_uint32(src[i], d); 9094 d += 8; 9095 } 9096 break; 9097 9098 case MESA_FORMAT_LA_SINT8: 9099 for (i = 0; i < n; ++i) { 9100 pack_ubyte_la_sint8(src[i], d); 9101 d += 2; 9102 } 9103 break; 9104 9105 case MESA_FORMAT_LA_SINT16: 9106 for (i = 0; i < n; ++i) { 9107 pack_ubyte_la_sint16(src[i], d); 9108 d += 4; 9109 } 9110 break; 9111 9112 case MESA_FORMAT_LA_SINT32: 9113 for (i = 0; i < n; ++i) { 9114 pack_ubyte_la_sint32(src[i], d); 9115 d += 8; 9116 } 9117 break; 9118 9119 case MESA_FORMAT_R_UINT8: 9120 for (i = 0; i < n; ++i) { 9121 pack_ubyte_r_uint8(src[i], d); 9122 d += 1; 9123 } 9124 break; 9125 9126 case MESA_FORMAT_R_UINT16: 9127 for (i = 0; i < n; ++i) { 9128 pack_ubyte_r_uint16(src[i], d); 9129 d += 2; 9130 } 9131 break; 9132 9133 case MESA_FORMAT_R_UINT32: 9134 for (i = 0; i < n; ++i) { 9135 pack_ubyte_r_uint32(src[i], d); 9136 d += 4; 9137 } 9138 break; 9139 9140 case MESA_FORMAT_R_SINT8: 9141 for (i = 0; i < n; ++i) { 9142 pack_ubyte_r_sint8(src[i], d); 9143 d += 1; 9144 } 9145 break; 9146 9147 case MESA_FORMAT_R_SINT16: 9148 for (i = 0; i < n; ++i) { 9149 pack_ubyte_r_sint16(src[i], d); 9150 d += 2; 9151 } 9152 break; 9153 9154 case MESA_FORMAT_R_SINT32: 9155 for (i = 0; i < n; ++i) { 9156 pack_ubyte_r_sint32(src[i], d); 9157 d += 4; 9158 } 9159 break; 9160 9161 case MESA_FORMAT_RG_UINT8: 9162 for (i = 0; i < n; ++i) { 9163 pack_ubyte_rg_uint8(src[i], d); 9164 d += 2; 9165 } 9166 break; 9167 9168 case MESA_FORMAT_RG_UINT16: 9169 for (i = 0; i < n; ++i) { 9170 pack_ubyte_rg_uint16(src[i], d); 9171 d += 4; 9172 } 9173 break; 9174 9175 case MESA_FORMAT_RG_UINT32: 9176 for (i = 0; i < n; ++i) { 9177 pack_ubyte_rg_uint32(src[i], d); 9178 d += 8; 9179 } 9180 break; 9181 9182 case MESA_FORMAT_RG_SINT8: 9183 for (i = 0; i < n; ++i) { 9184 pack_ubyte_rg_sint8(src[i], d); 9185 d += 2; 9186 } 9187 break; 9188 9189 case MESA_FORMAT_RG_SINT16: 9190 for (i = 0; i < n; ++i) { 9191 pack_ubyte_rg_sint16(src[i], d); 9192 d += 4; 9193 } 9194 break; 9195 9196 case MESA_FORMAT_RG_SINT32: 9197 for (i = 0; i < n; ++i) { 9198 pack_ubyte_rg_sint32(src[i], d); 9199 d += 8; 9200 } 9201 break; 9202 9203 case MESA_FORMAT_RGB_UINT8: 9204 for (i = 0; i < n; ++i) { 9205 pack_ubyte_rgb_uint8(src[i], d); 9206 d += 3; 9207 } 9208 break; 9209 9210 case MESA_FORMAT_RGB_UINT16: 9211 for (i = 0; i < n; ++i) { 9212 pack_ubyte_rgb_uint16(src[i], d); 9213 d += 6; 9214 } 9215 break; 9216 9217 case MESA_FORMAT_RGB_UINT32: 9218 for (i = 0; i < n; ++i) { 9219 pack_ubyte_rgb_uint32(src[i], d); 9220 d += 12; 9221 } 9222 break; 9223 9224 case MESA_FORMAT_RGB_SINT8: 9225 for (i = 0; i < n; ++i) { 9226 pack_ubyte_rgb_sint8(src[i], d); 9227 d += 3; 9228 } 9229 break; 9230 9231 case MESA_FORMAT_RGB_SINT16: 9232 for (i = 0; i < n; ++i) { 9233 pack_ubyte_rgb_sint16(src[i], d); 9234 d += 6; 9235 } 9236 break; 9237 9238 case MESA_FORMAT_RGB_SINT32: 9239 for (i = 0; i < n; ++i) { 9240 pack_ubyte_rgb_sint32(src[i], d); 9241 d += 12; 9242 } 9243 break; 9244 9245 case MESA_FORMAT_RGBA_UINT8: 9246 for (i = 0; i < n; ++i) { 9247 pack_ubyte_rgba_uint8(src[i], d); 9248 d += 4; 9249 } 9250 break; 9251 9252 case MESA_FORMAT_RGBA_UINT16: 9253 for (i = 0; i < n; ++i) { 9254 pack_ubyte_rgba_uint16(src[i], d); 9255 d += 8; 9256 } 9257 break; 9258 9259 case MESA_FORMAT_RGBA_UINT32: 9260 for (i = 0; i < n; ++i) { 9261 pack_ubyte_rgba_uint32(src[i], d); 9262 d += 16; 9263 } 9264 break; 9265 9266 case MESA_FORMAT_RGBA_SINT8: 9267 for (i = 0; i < n; ++i) { 9268 pack_ubyte_rgba_sint8(src[i], d); 9269 d += 4; 9270 } 9271 break; 9272 9273 case MESA_FORMAT_RGBA_SINT16: 9274 for (i = 0; i < n; ++i) { 9275 pack_ubyte_rgba_sint16(src[i], d); 9276 d += 8; 9277 } 9278 break; 9279 9280 case MESA_FORMAT_RGBA_SINT32: 9281 for (i = 0; i < n; ++i) { 9282 pack_ubyte_rgba_sint32(src[i], d); 9283 d += 16; 9284 } 9285 break; 9286 9287 case MESA_FORMAT_RGBX_UINT8: 9288 for (i = 0; i < n; ++i) { 9289 pack_ubyte_rgbx_uint8(src[i], d); 9290 d += 4; 9291 } 9292 break; 9293 9294 case MESA_FORMAT_RGBX_UINT16: 9295 for (i = 0; i < n; ++i) { 9296 pack_ubyte_rgbx_uint16(src[i], d); 9297 d += 8; 9298 } 9299 break; 9300 9301 case MESA_FORMAT_RGBX_UINT32: 9302 for (i = 0; i < n; ++i) { 9303 pack_ubyte_rgbx_uint32(src[i], d); 9304 d += 16; 9305 } 9306 break; 9307 9308 case MESA_FORMAT_RGBX_SINT8: 9309 for (i = 0; i < n; ++i) { 9310 pack_ubyte_rgbx_sint8(src[i], d); 9311 d += 4; 9312 } 9313 break; 9314 9315 case MESA_FORMAT_RGBX_SINT16: 9316 for (i = 0; i < n; ++i) { 9317 pack_ubyte_rgbx_sint16(src[i], d); 9318 d += 8; 9319 } 9320 break; 9321 9322 case MESA_FORMAT_RGBX_SINT32: 9323 for (i = 0; i < n; ++i) { 9324 pack_ubyte_rgbx_sint32(src[i], d); 9325 d += 16; 9326 } 9327 break; 9328 default: 9329 assert(!"Invalid format"); 9330 } 9331 } 9332 9333 /** 9334 * Pack a row of GLuint rgba[4] values to the destination. 9335 */ 9336 void 9337 _mesa_pack_uint_rgba_row(mesa_format format, GLuint n, 9338 const GLuint src[][4], void *dst) 9339 { 9340 GLuint i; 9341 GLubyte *d = dst; 9342 9343 switch (format) { 9344 9345 case MESA_FORMAT_A8B8G8R8_UINT: 9346 for (i = 0; i < n; ++i) { 9347 pack_uint_a8b8g8r8_uint(src[i], d); 9348 d += 4; 9349 } 9350 break; 9351 9352 case MESA_FORMAT_A8R8G8B8_UINT: 9353 for (i = 0; i < n; ++i) { 9354 pack_uint_a8r8g8b8_uint(src[i], d); 9355 d += 4; 9356 } 9357 break; 9358 9359 case MESA_FORMAT_R8G8B8A8_UINT: 9360 for (i = 0; i < n; ++i) { 9361 pack_uint_r8g8b8a8_uint(src[i], d); 9362 d += 4; 9363 } 9364 break; 9365 9366 case MESA_FORMAT_B8G8R8A8_UINT: 9367 for (i = 0; i < n; ++i) { 9368 pack_uint_b8g8r8a8_uint(src[i], d); 9369 d += 4; 9370 } 9371 break; 9372 9373 case MESA_FORMAT_B10G10R10A2_UINT: 9374 for (i = 0; i < n; ++i) { 9375 pack_uint_b10g10r10a2_uint(src[i], d); 9376 d += 4; 9377 } 9378 break; 9379 9380 case MESA_FORMAT_R10G10B10A2_UINT: 9381 for (i = 0; i < n; ++i) { 9382 pack_uint_r10g10b10a2_uint(src[i], d); 9383 d += 4; 9384 } 9385 break; 9386 9387 case MESA_FORMAT_A2B10G10R10_UINT: 9388 for (i = 0; i < n; ++i) { 9389 pack_uint_a2b10g10r10_uint(src[i], d); 9390 d += 4; 9391 } 9392 break; 9393 9394 case MESA_FORMAT_A2R10G10B10_UINT: 9395 for (i = 0; i < n; ++i) { 9396 pack_uint_a2r10g10b10_uint(src[i], d); 9397 d += 4; 9398 } 9399 break; 9400 9401 case MESA_FORMAT_B5G6R5_UINT: 9402 for (i = 0; i < n; ++i) { 9403 pack_uint_b5g6r5_uint(src[i], d); 9404 d += 2; 9405 } 9406 break; 9407 9408 case MESA_FORMAT_R5G6B5_UINT: 9409 for (i = 0; i < n; ++i) { 9410 pack_uint_r5g6b5_uint(src[i], d); 9411 d += 2; 9412 } 9413 break; 9414 9415 case MESA_FORMAT_B2G3R3_UINT: 9416 for (i = 0; i < n; ++i) { 9417 pack_uint_b2g3r3_uint(src[i], d); 9418 d += 1; 9419 } 9420 break; 9421 9422 case MESA_FORMAT_R3G3B2_UINT: 9423 for (i = 0; i < n; ++i) { 9424 pack_uint_r3g3b2_uint(src[i], d); 9425 d += 1; 9426 } 9427 break; 9428 9429 case MESA_FORMAT_A4B4G4R4_UINT: 9430 for (i = 0; i < n; ++i) { 9431 pack_uint_a4b4g4r4_uint(src[i], d); 9432 d += 2; 9433 } 9434 break; 9435 9436 case MESA_FORMAT_R4G4B4A4_UINT: 9437 for (i = 0; i < n; ++i) { 9438 pack_uint_r4g4b4a4_uint(src[i], d); 9439 d += 2; 9440 } 9441 break; 9442 9443 case MESA_FORMAT_B4G4R4A4_UINT: 9444 for (i = 0; i < n; ++i) { 9445 pack_uint_b4g4r4a4_uint(src[i], d); 9446 d += 2; 9447 } 9448 break; 9449 9450 case MESA_FORMAT_A4R4G4B4_UINT: 9451 for (i = 0; i < n; ++i) { 9452 pack_uint_a4r4g4b4_uint(src[i], d); 9453 d += 2; 9454 } 9455 break; 9456 9457 case MESA_FORMAT_A1B5G5R5_UINT: 9458 for (i = 0; i < n; ++i) { 9459 pack_uint_a1b5g5r5_uint(src[i], d); 9460 d += 2; 9461 } 9462 break; 9463 9464 case MESA_FORMAT_B5G5R5A1_UINT: 9465 for (i = 0; i < n; ++i) { 9466 pack_uint_b5g5r5a1_uint(src[i], d); 9467 d += 2; 9468 } 9469 break; 9470 9471 case MESA_FORMAT_A1R5G5B5_UINT: 9472 for (i = 0; i < n; ++i) { 9473 pack_uint_a1r5g5b5_uint(src[i], d); 9474 d += 2; 9475 } 9476 break; 9477 9478 case MESA_FORMAT_R5G5B5A1_UINT: 9479 for (i = 0; i < n; ++i) { 9480 pack_uint_r5g5b5a1_uint(src[i], d); 9481 d += 2; 9482 } 9483 break; 9484 9485 case MESA_FORMAT_A_UINT8: 9486 for (i = 0; i < n; ++i) { 9487 pack_uint_a_uint8(src[i], d); 9488 d += 1; 9489 } 9490 break; 9491 9492 case MESA_FORMAT_A_UINT16: 9493 for (i = 0; i < n; ++i) { 9494 pack_uint_a_uint16(src[i], d); 9495 d += 2; 9496 } 9497 break; 9498 9499 case MESA_FORMAT_A_UINT32: 9500 for (i = 0; i < n; ++i) { 9501 pack_uint_a_uint32(src[i], d); 9502 d += 4; 9503 } 9504 break; 9505 9506 case MESA_FORMAT_A_SINT8: 9507 for (i = 0; i < n; ++i) { 9508 pack_uint_a_sint8(src[i], d); 9509 d += 1; 9510 } 9511 break; 9512 9513 case MESA_FORMAT_A_SINT16: 9514 for (i = 0; i < n; ++i) { 9515 pack_uint_a_sint16(src[i], d); 9516 d += 2; 9517 } 9518 break; 9519 9520 case MESA_FORMAT_A_SINT32: 9521 for (i = 0; i < n; ++i) { 9522 pack_uint_a_sint32(src[i], d); 9523 d += 4; 9524 } 9525 break; 9526 9527 case MESA_FORMAT_I_UINT8: 9528 for (i = 0; i < n; ++i) { 9529 pack_uint_i_uint8(src[i], d); 9530 d += 1; 9531 } 9532 break; 9533 9534 case MESA_FORMAT_I_UINT16: 9535 for (i = 0; i < n; ++i) { 9536 pack_uint_i_uint16(src[i], d); 9537 d += 2; 9538 } 9539 break; 9540 9541 case MESA_FORMAT_I_UINT32: 9542 for (i = 0; i < n; ++i) { 9543 pack_uint_i_uint32(src[i], d); 9544 d += 4; 9545 } 9546 break; 9547 9548 case MESA_FORMAT_I_SINT8: 9549 for (i = 0; i < n; ++i) { 9550 pack_uint_i_sint8(src[i], d); 9551 d += 1; 9552 } 9553 break; 9554 9555 case MESA_FORMAT_I_SINT16: 9556 for (i = 0; i < n; ++i) { 9557 pack_uint_i_sint16(src[i], d); 9558 d += 2; 9559 } 9560 break; 9561 9562 case MESA_FORMAT_I_SINT32: 9563 for (i = 0; i < n; ++i) { 9564 pack_uint_i_sint32(src[i], d); 9565 d += 4; 9566 } 9567 break; 9568 9569 case MESA_FORMAT_L_UINT8: 9570 for (i = 0; i < n; ++i) { 9571 pack_uint_l_uint8(src[i], d); 9572 d += 1; 9573 } 9574 break; 9575 9576 case MESA_FORMAT_L_UINT16: 9577 for (i = 0; i < n; ++i) { 9578 pack_uint_l_uint16(src[i], d); 9579 d += 2; 9580 } 9581 break; 9582 9583 case MESA_FORMAT_L_UINT32: 9584 for (i = 0; i < n; ++i) { 9585 pack_uint_l_uint32(src[i], d); 9586 d += 4; 9587 } 9588 break; 9589 9590 case MESA_FORMAT_L_SINT8: 9591 for (i = 0; i < n; ++i) { 9592 pack_uint_l_sint8(src[i], d); 9593 d += 1; 9594 } 9595 break; 9596 9597 case MESA_FORMAT_L_SINT16: 9598 for (i = 0; i < n; ++i) { 9599 pack_uint_l_sint16(src[i], d); 9600 d += 2; 9601 } 9602 break; 9603 9604 case MESA_FORMAT_L_SINT32: 9605 for (i = 0; i < n; ++i) { 9606 pack_uint_l_sint32(src[i], d); 9607 d += 4; 9608 } 9609 break; 9610 9611 case MESA_FORMAT_LA_UINT8: 9612 for (i = 0; i < n; ++i) { 9613 pack_uint_la_uint8(src[i], d); 9614 d += 2; 9615 } 9616 break; 9617 9618 case MESA_FORMAT_LA_UINT16: 9619 for (i = 0; i < n; ++i) { 9620 pack_uint_la_uint16(src[i], d); 9621 d += 4; 9622 } 9623 break; 9624 9625 case MESA_FORMAT_LA_UINT32: 9626 for (i = 0; i < n; ++i) { 9627 pack_uint_la_uint32(src[i], d); 9628 d += 8; 9629 } 9630 break; 9631 9632 case MESA_FORMAT_LA_SINT8: 9633 for (i = 0; i < n; ++i) { 9634 pack_uint_la_sint8(src[i], d); 9635 d += 2; 9636 } 9637 break; 9638 9639 case MESA_FORMAT_LA_SINT16: 9640 for (i = 0; i < n; ++i) { 9641 pack_uint_la_sint16(src[i], d); 9642 d += 4; 9643 } 9644 break; 9645 9646 case MESA_FORMAT_LA_SINT32: 9647 for (i = 0; i < n; ++i) { 9648 pack_uint_la_sint32(src[i], d); 9649 d += 8; 9650 } 9651 break; 9652 9653 case MESA_FORMAT_R_UINT8: 9654 for (i = 0; i < n; ++i) { 9655 pack_uint_r_uint8(src[i], d); 9656 d += 1; 9657 } 9658 break; 9659 9660 case MESA_FORMAT_R_UINT16: 9661 for (i = 0; i < n; ++i) { 9662 pack_uint_r_uint16(src[i], d); 9663 d += 2; 9664 } 9665 break; 9666 9667 case MESA_FORMAT_R_UINT32: 9668 for (i = 0; i < n; ++i) { 9669 pack_uint_r_uint32(src[i], d); 9670 d += 4; 9671 } 9672 break; 9673 9674 case MESA_FORMAT_R_SINT8: 9675 for (i = 0; i < n; ++i) { 9676 pack_uint_r_sint8(src[i], d); 9677 d += 1; 9678 } 9679 break; 9680 9681 case MESA_FORMAT_R_SINT16: 9682 for (i = 0; i < n; ++i) { 9683 pack_uint_r_sint16(src[i], d); 9684 d += 2; 9685 } 9686 break; 9687 9688 case MESA_FORMAT_R_SINT32: 9689 for (i = 0; i < n; ++i) { 9690 pack_uint_r_sint32(src[i], d); 9691 d += 4; 9692 } 9693 break; 9694 9695 case MESA_FORMAT_RG_UINT8: 9696 for (i = 0; i < n; ++i) { 9697 pack_uint_rg_uint8(src[i], d); 9698 d += 2; 9699 } 9700 break; 9701 9702 case MESA_FORMAT_RG_UINT16: 9703 for (i = 0; i < n; ++i) { 9704 pack_uint_rg_uint16(src[i], d); 9705 d += 4; 9706 } 9707 break; 9708 9709 case MESA_FORMAT_RG_UINT32: 9710 for (i = 0; i < n; ++i) { 9711 pack_uint_rg_uint32(src[i], d); 9712 d += 8; 9713 } 9714 break; 9715 9716 case MESA_FORMAT_RG_SINT8: 9717 for (i = 0; i < n; ++i) { 9718 pack_uint_rg_sint8(src[i], d); 9719 d += 2; 9720 } 9721 break; 9722 9723 case MESA_FORMAT_RG_SINT16: 9724 for (i = 0; i < n; ++i) { 9725 pack_uint_rg_sint16(src[i], d); 9726 d += 4; 9727 } 9728 break; 9729 9730 case MESA_FORMAT_RG_SINT32: 9731 for (i = 0; i < n; ++i) { 9732 pack_uint_rg_sint32(src[i], d); 9733 d += 8; 9734 } 9735 break; 9736 9737 case MESA_FORMAT_RGB_UINT8: 9738 for (i = 0; i < n; ++i) { 9739 pack_uint_rgb_uint8(src[i], d); 9740 d += 3; 9741 } 9742 break; 9743 9744 case MESA_FORMAT_RGB_UINT16: 9745 for (i = 0; i < n; ++i) { 9746 pack_uint_rgb_uint16(src[i], d); 9747 d += 6; 9748 } 9749 break; 9750 9751 case MESA_FORMAT_RGB_UINT32: 9752 for (i = 0; i < n; ++i) { 9753 pack_uint_rgb_uint32(src[i], d); 9754 d += 12; 9755 } 9756 break; 9757 9758 case MESA_FORMAT_RGB_SINT8: 9759 for (i = 0; i < n; ++i) { 9760 pack_uint_rgb_sint8(src[i], d); 9761 d += 3; 9762 } 9763 break; 9764 9765 case MESA_FORMAT_RGB_SINT16: 9766 for (i = 0; i < n; ++i) { 9767 pack_uint_rgb_sint16(src[i], d); 9768 d += 6; 9769 } 9770 break; 9771 9772 case MESA_FORMAT_RGB_SINT32: 9773 for (i = 0; i < n; ++i) { 9774 pack_uint_rgb_sint32(src[i], d); 9775 d += 12; 9776 } 9777 break; 9778 9779 case MESA_FORMAT_RGBA_UINT8: 9780 for (i = 0; i < n; ++i) { 9781 pack_uint_rgba_uint8(src[i], d); 9782 d += 4; 9783 } 9784 break; 9785 9786 case MESA_FORMAT_RGBA_UINT16: 9787 for (i = 0; i < n; ++i) { 9788 pack_uint_rgba_uint16(src[i], d); 9789 d += 8; 9790 } 9791 break; 9792 9793 case MESA_FORMAT_RGBA_UINT32: 9794 for (i = 0; i < n; ++i) { 9795 pack_uint_rgba_uint32(src[i], d); 9796 d += 16; 9797 } 9798 break; 9799 9800 case MESA_FORMAT_RGBA_SINT8: 9801 for (i = 0; i < n; ++i) { 9802 pack_uint_rgba_sint8(src[i], d); 9803 d += 4; 9804 } 9805 break; 9806 9807 case MESA_FORMAT_RGBA_SINT16: 9808 for (i = 0; i < n; ++i) { 9809 pack_uint_rgba_sint16(src[i], d); 9810 d += 8; 9811 } 9812 break; 9813 9814 case MESA_FORMAT_RGBA_SINT32: 9815 for (i = 0; i < n; ++i) { 9816 pack_uint_rgba_sint32(src[i], d); 9817 d += 16; 9818 } 9819 break; 9820 9821 case MESA_FORMAT_RGBX_UINT8: 9822 for (i = 0; i < n; ++i) { 9823 pack_uint_rgbx_uint8(src[i], d); 9824 d += 4; 9825 } 9826 break; 9827 9828 case MESA_FORMAT_RGBX_UINT16: 9829 for (i = 0; i < n; ++i) { 9830 pack_uint_rgbx_uint16(src[i], d); 9831 d += 8; 9832 } 9833 break; 9834 9835 case MESA_FORMAT_RGBX_UINT32: 9836 for (i = 0; i < n; ++i) { 9837 pack_uint_rgbx_uint32(src[i], d); 9838 d += 16; 9839 } 9840 break; 9841 9842 case MESA_FORMAT_RGBX_SINT8: 9843 for (i = 0; i < n; ++i) { 9844 pack_uint_rgbx_sint8(src[i], d); 9845 d += 4; 9846 } 9847 break; 9848 9849 case MESA_FORMAT_RGBX_SINT16: 9850 for (i = 0; i < n; ++i) { 9851 pack_uint_rgbx_sint16(src[i], d); 9852 d += 8; 9853 } 9854 break; 9855 9856 case MESA_FORMAT_RGBX_SINT32: 9857 for (i = 0; i < n; ++i) { 9858 pack_uint_rgbx_sint32(src[i], d); 9859 d += 16; 9860 } 9861 break; 9862 default: 9863 assert(!"Invalid format"); 9864 } 9865 } 9866 9867 /** 9868 * Pack a row of GLfloat rgba[4] values to the destination. 9869 */ 9870 void 9871 _mesa_pack_float_rgba_row(mesa_format format, GLuint n, 9872 const GLfloat src[][4], void *dst) 9873 { 9874 GLuint i; 9875 GLubyte *d = dst; 9876 9877 switch (format) { 9878 9879 case MESA_FORMAT_A8B8G8R8_UNORM: 9880 for (i = 0; i < n; ++i) { 9881 pack_float_a8b8g8r8_unorm(src[i], d); 9882 d += 4; 9883 } 9884 break; 9885 9886 case MESA_FORMAT_X8B8G8R8_UNORM: 9887 for (i = 0; i < n; ++i) { 9888 pack_float_x8b8g8r8_unorm(src[i], d); 9889 d += 4; 9890 } 9891 break; 9892 9893 case MESA_FORMAT_R8G8B8A8_UNORM: 9894 for (i = 0; i < n; ++i) { 9895 pack_float_r8g8b8a8_unorm(src[i], d); 9896 d += 4; 9897 } 9898 break; 9899 9900 case MESA_FORMAT_R8G8B8X8_UNORM: 9901 for (i = 0; i < n; ++i) { 9902 pack_float_r8g8b8x8_unorm(src[i], d); 9903 d += 4; 9904 } 9905 break; 9906 9907 case MESA_FORMAT_B8G8R8A8_UNORM: 9908 for (i = 0; i < n; ++i) { 9909 pack_float_b8g8r8a8_unorm(src[i], d); 9910 d += 4; 9911 } 9912 break; 9913 9914 case MESA_FORMAT_B8G8R8X8_UNORM: 9915 for (i = 0; i < n; ++i) { 9916 pack_float_b8g8r8x8_unorm(src[i], d); 9917 d += 4; 9918 } 9919 break; 9920 9921 case MESA_FORMAT_A8R8G8B8_UNORM: 9922 for (i = 0; i < n; ++i) { 9923 pack_float_a8r8g8b8_unorm(src[i], d); 9924 d += 4; 9925 } 9926 break; 9927 9928 case MESA_FORMAT_X8R8G8B8_UNORM: 9929 for (i = 0; i < n; ++i) { 9930 pack_float_x8r8g8b8_unorm(src[i], d); 9931 d += 4; 9932 } 9933 break; 9934 9935 case MESA_FORMAT_L16A16_UNORM: 9936 for (i = 0; i < n; ++i) { 9937 pack_float_l16a16_unorm(src[i], d); 9938 d += 4; 9939 } 9940 break; 9941 9942 case MESA_FORMAT_A16L16_UNORM: 9943 for (i = 0; i < n; ++i) { 9944 pack_float_a16l16_unorm(src[i], d); 9945 d += 4; 9946 } 9947 break; 9948 9949 case MESA_FORMAT_B5G6R5_UNORM: 9950 for (i = 0; i < n; ++i) { 9951 pack_float_b5g6r5_unorm(src[i], d); 9952 d += 2; 9953 } 9954 break; 9955 9956 case MESA_FORMAT_R5G6B5_UNORM: 9957 for (i = 0; i < n; ++i) { 9958 pack_float_r5g6b5_unorm(src[i], d); 9959 d += 2; 9960 } 9961 break; 9962 9963 case MESA_FORMAT_B4G4R4A4_UNORM: 9964 for (i = 0; i < n; ++i) { 9965 pack_float_b4g4r4a4_unorm(src[i], d); 9966 d += 2; 9967 } 9968 break; 9969 9970 case MESA_FORMAT_B4G4R4X4_UNORM: 9971 for (i = 0; i < n; ++i) { 9972 pack_float_b4g4r4x4_unorm(src[i], d); 9973 d += 2; 9974 } 9975 break; 9976 9977 case MESA_FORMAT_A4R4G4B4_UNORM: 9978 for (i = 0; i < n; ++i) { 9979 pack_float_a4r4g4b4_unorm(src[i], d); 9980 d += 2; 9981 } 9982 break; 9983 9984 case MESA_FORMAT_A1B5G5R5_UNORM: 9985 for (i = 0; i < n; ++i) { 9986 pack_float_a1b5g5r5_unorm(src[i], d); 9987 d += 2; 9988 } 9989 break; 9990 9991 case MESA_FORMAT_B5G5R5A1_UNORM: 9992 for (i = 0; i < n; ++i) { 9993 pack_float_b5g5r5a1_unorm(src[i], d); 9994 d += 2; 9995 } 9996 break; 9997 9998 case MESA_FORMAT_B5G5R5X1_UNORM: 9999 for (i = 0; i < n; ++i) { 10000 pack_float_b5g5r5x1_unorm(src[i], d); 10001 d += 2; 10002 } 10003 break; 10004 10005 case MESA_FORMAT_A1R5G5B5_UNORM: 10006 for (i = 0; i < n; ++i) { 10007 pack_float_a1r5g5b5_unorm(src[i], d); 10008 d += 2; 10009 } 10010 break; 10011 10012 case MESA_FORMAT_L8A8_UNORM: 10013 for (i = 0; i < n; ++i) { 10014 pack_float_l8a8_unorm(src[i], d); 10015 d += 2; 10016 } 10017 break; 10018 10019 case MESA_FORMAT_A8L8_UNORM: 10020 for (i = 0; i < n; ++i) { 10021 pack_float_a8l8_unorm(src[i], d); 10022 d += 2; 10023 } 10024 break; 10025 10026 case MESA_FORMAT_R8G8_UNORM: 10027 for (i = 0; i < n; ++i) { 10028 pack_float_r8g8_unorm(src[i], d); 10029 d += 2; 10030 } 10031 break; 10032 10033 case MESA_FORMAT_G8R8_UNORM: 10034 for (i = 0; i < n; ++i) { 10035 pack_float_g8r8_unorm(src[i], d); 10036 d += 2; 10037 } 10038 break; 10039 10040 case MESA_FORMAT_L4A4_UNORM: 10041 for (i = 0; i < n; ++i) { 10042 pack_float_l4a4_unorm(src[i], d); 10043 d += 1; 10044 } 10045 break; 10046 10047 case MESA_FORMAT_B2G3R3_UNORM: 10048 for (i = 0; i < n; ++i) { 10049 pack_float_b2g3r3_unorm(src[i], d); 10050 d += 1; 10051 } 10052 break; 10053 10054 case MESA_FORMAT_R16G16_UNORM: 10055 for (i = 0; i < n; ++i) { 10056 pack_float_r16g16_unorm(src[i], d); 10057 d += 4; 10058 } 10059 break; 10060 10061 case MESA_FORMAT_G16R16_UNORM: 10062 for (i = 0; i < n; ++i) { 10063 pack_float_g16r16_unorm(src[i], d); 10064 d += 4; 10065 } 10066 break; 10067 10068 case MESA_FORMAT_B10G10R10A2_UNORM: 10069 for (i = 0; i < n; ++i) { 10070 pack_float_b10g10r10a2_unorm(src[i], d); 10071 d += 4; 10072 } 10073 break; 10074 10075 case MESA_FORMAT_B10G10R10X2_UNORM: 10076 for (i = 0; i < n; ++i) { 10077 pack_float_b10g10r10x2_unorm(src[i], d); 10078 d += 4; 10079 } 10080 break; 10081 10082 case MESA_FORMAT_R10G10B10A2_UNORM: 10083 for (i = 0; i < n; ++i) { 10084 pack_float_r10g10b10a2_unorm(src[i], d); 10085 d += 4; 10086 } 10087 break; 10088 10089 case MESA_FORMAT_R10G10B10X2_UNORM: 10090 for (i = 0; i < n; ++i) { 10091 pack_float_r10g10b10x2_unorm(src[i], d); 10092 d += 4; 10093 } 10094 break; 10095 10096 case MESA_FORMAT_R3G3B2_UNORM: 10097 for (i = 0; i < n; ++i) { 10098 pack_float_r3g3b2_unorm(src[i], d); 10099 d += 1; 10100 } 10101 break; 10102 10103 case MESA_FORMAT_A4B4G4R4_UNORM: 10104 for (i = 0; i < n; ++i) { 10105 pack_float_a4b4g4r4_unorm(src[i], d); 10106 d += 2; 10107 } 10108 break; 10109 10110 case MESA_FORMAT_R4G4B4A4_UNORM: 10111 for (i = 0; i < n; ++i) { 10112 pack_float_r4g4b4a4_unorm(src[i], d); 10113 d += 2; 10114 } 10115 break; 10116 10117 case MESA_FORMAT_R5G5B5A1_UNORM: 10118 for (i = 0; i < n; ++i) { 10119 pack_float_r5g5b5a1_unorm(src[i], d); 10120 d += 2; 10121 } 10122 break; 10123 10124 case MESA_FORMAT_A2B10G10R10_UNORM: 10125 for (i = 0; i < n; ++i) { 10126 pack_float_a2b10g10r10_unorm(src[i], d); 10127 d += 4; 10128 } 10129 break; 10130 10131 case MESA_FORMAT_A2R10G10B10_UNORM: 10132 for (i = 0; i < n; ++i) { 10133 pack_float_a2r10g10b10_unorm(src[i], d); 10134 d += 4; 10135 } 10136 break; 10137 10138 case MESA_FORMAT_A_UNORM8: 10139 for (i = 0; i < n; ++i) { 10140 pack_float_a_unorm8(src[i], d); 10141 d += 1; 10142 } 10143 break; 10144 10145 case MESA_FORMAT_A_UNORM16: 10146 for (i = 0; i < n; ++i) { 10147 pack_float_a_unorm16(src[i], d); 10148 d += 2; 10149 } 10150 break; 10151 10152 case MESA_FORMAT_L_UNORM8: 10153 for (i = 0; i < n; ++i) { 10154 pack_float_l_unorm8(src[i], d); 10155 d += 1; 10156 } 10157 break; 10158 10159 case MESA_FORMAT_L_UNORM16: 10160 for (i = 0; i < n; ++i) { 10161 pack_float_l_unorm16(src[i], d); 10162 d += 2; 10163 } 10164 break; 10165 10166 case MESA_FORMAT_I_UNORM8: 10167 for (i = 0; i < n; ++i) { 10168 pack_float_i_unorm8(src[i], d); 10169 d += 1; 10170 } 10171 break; 10172 10173 case MESA_FORMAT_I_UNORM16: 10174 for (i = 0; i < n; ++i) { 10175 pack_float_i_unorm16(src[i], d); 10176 d += 2; 10177 } 10178 break; 10179 10180 case MESA_FORMAT_R_UNORM8: 10181 for (i = 0; i < n; ++i) { 10182 pack_float_r_unorm8(src[i], d); 10183 d += 1; 10184 } 10185 break; 10186 10187 case MESA_FORMAT_R_UNORM16: 10188 for (i = 0; i < n; ++i) { 10189 pack_float_r_unorm16(src[i], d); 10190 d += 2; 10191 } 10192 break; 10193 10194 case MESA_FORMAT_BGR_UNORM8: 10195 for (i = 0; i < n; ++i) { 10196 pack_float_bgr_unorm8(src[i], d); 10197 d += 3; 10198 } 10199 break; 10200 10201 case MESA_FORMAT_RGB_UNORM8: 10202 for (i = 0; i < n; ++i) { 10203 pack_float_rgb_unorm8(src[i], d); 10204 d += 3; 10205 } 10206 break; 10207 10208 case MESA_FORMAT_RGBA_UNORM16: 10209 for (i = 0; i < n; ++i) { 10210 pack_float_rgba_unorm16(src[i], d); 10211 d += 8; 10212 } 10213 break; 10214 10215 case MESA_FORMAT_RGBX_UNORM16: 10216 for (i = 0; i < n; ++i) { 10217 pack_float_rgbx_unorm16(src[i], d); 10218 d += 8; 10219 } 10220 break; 10221 10222 case MESA_FORMAT_A8B8G8R8_SNORM: 10223 for (i = 0; i < n; ++i) { 10224 pack_float_a8b8g8r8_snorm(src[i], d); 10225 d += 4; 10226 } 10227 break; 10228 10229 case MESA_FORMAT_X8B8G8R8_SNORM: 10230 for (i = 0; i < n; ++i) { 10231 pack_float_x8b8g8r8_snorm(src[i], d); 10232 d += 4; 10233 } 10234 break; 10235 10236 case MESA_FORMAT_R8G8B8A8_SNORM: 10237 for (i = 0; i < n; ++i) { 10238 pack_float_r8g8b8a8_snorm(src[i], d); 10239 d += 4; 10240 } 10241 break; 10242 10243 case MESA_FORMAT_R8G8B8X8_SNORM: 10244 for (i = 0; i < n; ++i) { 10245 pack_float_r8g8b8x8_snorm(src[i], d); 10246 d += 4; 10247 } 10248 break; 10249 10250 case MESA_FORMAT_R16G16_SNORM: 10251 for (i = 0; i < n; ++i) { 10252 pack_float_r16g16_snorm(src[i], d); 10253 d += 4; 10254 } 10255 break; 10256 10257 case MESA_FORMAT_G16R16_SNORM: 10258 for (i = 0; i < n; ++i) { 10259 pack_float_g16r16_snorm(src[i], d); 10260 d += 4; 10261 } 10262 break; 10263 10264 case MESA_FORMAT_R8G8_SNORM: 10265 for (i = 0; i < n; ++i) { 10266 pack_float_r8g8_snorm(src[i], d); 10267 d += 2; 10268 } 10269 break; 10270 10271 case MESA_FORMAT_G8R8_SNORM: 10272 for (i = 0; i < n; ++i) { 10273 pack_float_g8r8_snorm(src[i], d); 10274 d += 2; 10275 } 10276 break; 10277 10278 case MESA_FORMAT_L8A8_SNORM: 10279 for (i = 0; i < n; ++i) { 10280 pack_float_l8a8_snorm(src[i], d); 10281 d += 2; 10282 } 10283 break; 10284 10285 case MESA_FORMAT_A8L8_SNORM: 10286 for (i = 0; i < n; ++i) { 10287 pack_float_a8l8_snorm(src[i], d); 10288 d += 2; 10289 } 10290 break; 10291 10292 case MESA_FORMAT_A_SNORM8: 10293 for (i = 0; i < n; ++i) { 10294 pack_float_a_snorm8(src[i], d); 10295 d += 1; 10296 } 10297 break; 10298 10299 case MESA_FORMAT_A_SNORM16: 10300 for (i = 0; i < n; ++i) { 10301 pack_float_a_snorm16(src[i], d); 10302 d += 2; 10303 } 10304 break; 10305 10306 case MESA_FORMAT_L_SNORM8: 10307 for (i = 0; i < n; ++i) { 10308 pack_float_l_snorm8(src[i], d); 10309 d += 1; 10310 } 10311 break; 10312 10313 case MESA_FORMAT_L_SNORM16: 10314 for (i = 0; i < n; ++i) { 10315 pack_float_l_snorm16(src[i], d); 10316 d += 2; 10317 } 10318 break; 10319 10320 case MESA_FORMAT_I_SNORM8: 10321 for (i = 0; i < n; ++i) { 10322 pack_float_i_snorm8(src[i], d); 10323 d += 1; 10324 } 10325 break; 10326 10327 case MESA_FORMAT_I_SNORM16: 10328 for (i = 0; i < n; ++i) { 10329 pack_float_i_snorm16(src[i], d); 10330 d += 2; 10331 } 10332 break; 10333 10334 case MESA_FORMAT_R_SNORM8: 10335 for (i = 0; i < n; ++i) { 10336 pack_float_r_snorm8(src[i], d); 10337 d += 1; 10338 } 10339 break; 10340 10341 case MESA_FORMAT_R_SNORM16: 10342 for (i = 0; i < n; ++i) { 10343 pack_float_r_snorm16(src[i], d); 10344 d += 2; 10345 } 10346 break; 10347 10348 case MESA_FORMAT_LA_SNORM16: 10349 for (i = 0; i < n; ++i) { 10350 pack_float_la_snorm16(src[i], d); 10351 d += 4; 10352 } 10353 break; 10354 10355 case MESA_FORMAT_RGB_SNORM16: 10356 for (i = 0; i < n; ++i) { 10357 pack_float_rgb_snorm16(src[i], d); 10358 d += 6; 10359 } 10360 break; 10361 10362 case MESA_FORMAT_RGBA_SNORM16: 10363 for (i = 0; i < n; ++i) { 10364 pack_float_rgba_snorm16(src[i], d); 10365 d += 8; 10366 } 10367 break; 10368 10369 case MESA_FORMAT_RGBX_SNORM16: 10370 for (i = 0; i < n; ++i) { 10371 pack_float_rgbx_snorm16(src[i], d); 10372 d += 8; 10373 } 10374 break; 10375 10376 case MESA_FORMAT_A8B8G8R8_SRGB: 10377 for (i = 0; i < n; ++i) { 10378 pack_float_a8b8g8r8_srgb(src[i], d); 10379 d += 4; 10380 } 10381 break; 10382 10383 case MESA_FORMAT_B8G8R8A8_SRGB: 10384 for (i = 0; i < n; ++i) { 10385 pack_float_b8g8r8a8_srgb(src[i], d); 10386 d += 4; 10387 } 10388 break; 10389 10390 case MESA_FORMAT_A8R8G8B8_SRGB: 10391 for (i = 0; i < n; ++i) { 10392 pack_float_a8r8g8b8_srgb(src[i], d); 10393 d += 4; 10394 } 10395 break; 10396 10397 case MESA_FORMAT_B8G8R8X8_SRGB: 10398 for (i = 0; i < n; ++i) { 10399 pack_float_b8g8r8x8_srgb(src[i], d); 10400 d += 4; 10401 } 10402 break; 10403 10404 case MESA_FORMAT_X8R8G8B8_SRGB: 10405 for (i = 0; i < n; ++i) { 10406 pack_float_x8r8g8b8_srgb(src[i], d); 10407 d += 4; 10408 } 10409 break; 10410 10411 case MESA_FORMAT_R8G8B8A8_SRGB: 10412 for (i = 0; i < n; ++i) { 10413 pack_float_r8g8b8a8_srgb(src[i], d); 10414 d += 4; 10415 } 10416 break; 10417 10418 case MESA_FORMAT_R8G8B8X8_SRGB: 10419 for (i = 0; i < n; ++i) { 10420 pack_float_r8g8b8x8_srgb(src[i], d); 10421 d += 4; 10422 } 10423 break; 10424 10425 case MESA_FORMAT_X8B8G8R8_SRGB: 10426 for (i = 0; i < n; ++i) { 10427 pack_float_x8b8g8r8_srgb(src[i], d); 10428 d += 4; 10429 } 10430 break; 10431 10432 case MESA_FORMAT_L8A8_SRGB: 10433 for (i = 0; i < n; ++i) { 10434 pack_float_l8a8_srgb(src[i], d); 10435 d += 2; 10436 } 10437 break; 10438 10439 case MESA_FORMAT_A8L8_SRGB: 10440 for (i = 0; i < n; ++i) { 10441 pack_float_a8l8_srgb(src[i], d); 10442 d += 2; 10443 } 10444 break; 10445 10446 case MESA_FORMAT_L_SRGB8: 10447 for (i = 0; i < n; ++i) { 10448 pack_float_l_srgb8(src[i], d); 10449 d += 1; 10450 } 10451 break; 10452 10453 case MESA_FORMAT_BGR_SRGB8: 10454 for (i = 0; i < n; ++i) { 10455 pack_float_bgr_srgb8(src[i], d); 10456 d += 3; 10457 } 10458 break; 10459 10460 case MESA_FORMAT_R9G9B9E5_FLOAT: 10461 for (i = 0; i < n; ++i) { 10462 pack_float_r9g9b9e5_float(src[i], d); 10463 d += 4; 10464 } 10465 break; 10466 10467 case MESA_FORMAT_R11G11B10_FLOAT: 10468 for (i = 0; i < n; ++i) { 10469 pack_float_r11g11b10_float(src[i], d); 10470 d += 4; 10471 } 10472 break; 10473 10474 case MESA_FORMAT_A_FLOAT16: 10475 for (i = 0; i < n; ++i) { 10476 pack_float_a_float16(src[i], d); 10477 d += 2; 10478 } 10479 break; 10480 10481 case MESA_FORMAT_A_FLOAT32: 10482 for (i = 0; i < n; ++i) { 10483 pack_float_a_float32(src[i], d); 10484 d += 4; 10485 } 10486 break; 10487 10488 case MESA_FORMAT_L_FLOAT16: 10489 for (i = 0; i < n; ++i) { 10490 pack_float_l_float16(src[i], d); 10491 d += 2; 10492 } 10493 break; 10494 10495 case MESA_FORMAT_L_FLOAT32: 10496 for (i = 0; i < n; ++i) { 10497 pack_float_l_float32(src[i], d); 10498 d += 4; 10499 } 10500 break; 10501 10502 case MESA_FORMAT_LA_FLOAT16: 10503 for (i = 0; i < n; ++i) { 10504 pack_float_la_float16(src[i], d); 10505 d += 4; 10506 } 10507 break; 10508 10509 case MESA_FORMAT_LA_FLOAT32: 10510 for (i = 0; i < n; ++i) { 10511 pack_float_la_float32(src[i], d); 10512 d += 8; 10513 } 10514 break; 10515 10516 case MESA_FORMAT_I_FLOAT16: 10517 for (i = 0; i < n; ++i) { 10518 pack_float_i_float16(src[i], d); 10519 d += 2; 10520 } 10521 break; 10522 10523 case MESA_FORMAT_I_FLOAT32: 10524 for (i = 0; i < n; ++i) { 10525 pack_float_i_float32(src[i], d); 10526 d += 4; 10527 } 10528 break; 10529 10530 case MESA_FORMAT_R_FLOAT16: 10531 for (i = 0; i < n; ++i) { 10532 pack_float_r_float16(src[i], d); 10533 d += 2; 10534 } 10535 break; 10536 10537 case MESA_FORMAT_R_FLOAT32: 10538 for (i = 0; i < n; ++i) { 10539 pack_float_r_float32(src[i], d); 10540 d += 4; 10541 } 10542 break; 10543 10544 case MESA_FORMAT_RG_FLOAT16: 10545 for (i = 0; i < n; ++i) { 10546 pack_float_rg_float16(src[i], d); 10547 d += 4; 10548 } 10549 break; 10550 10551 case MESA_FORMAT_RG_FLOAT32: 10552 for (i = 0; i < n; ++i) { 10553 pack_float_rg_float32(src[i], d); 10554 d += 8; 10555 } 10556 break; 10557 10558 case MESA_FORMAT_RGB_FLOAT16: 10559 for (i = 0; i < n; ++i) { 10560 pack_float_rgb_float16(src[i], d); 10561 d += 6; 10562 } 10563 break; 10564 10565 case MESA_FORMAT_RGB_FLOAT32: 10566 for (i = 0; i < n; ++i) { 10567 pack_float_rgb_float32(src[i], d); 10568 d += 12; 10569 } 10570 break; 10571 10572 case MESA_FORMAT_RGBA_FLOAT16: 10573 for (i = 0; i < n; ++i) { 10574 pack_float_rgba_float16(src[i], d); 10575 d += 8; 10576 } 10577 break; 10578 10579 case MESA_FORMAT_RGBA_FLOAT32: 10580 for (i = 0; i < n; ++i) { 10581 pack_float_rgba_float32(src[i], d); 10582 d += 16; 10583 } 10584 break; 10585 10586 case MESA_FORMAT_RGBX_FLOAT16: 10587 for (i = 0; i < n; ++i) { 10588 pack_float_rgbx_float16(src[i], d); 10589 d += 8; 10590 } 10591 break; 10592 10593 case MESA_FORMAT_RGBX_FLOAT32: 10594 for (i = 0; i < n; ++i) { 10595 pack_float_rgbx_float32(src[i], d); 10596 d += 16; 10597 } 10598 break; 10599 default: 10600 assert(!"Invalid format"); 10601 } 10602 } 10603 10604 /** 10605 * Pack a 2D image of ubyte RGBA pixels in the given format. 10606 * \param srcRowStride source image row stride in bytes 10607 * \param dstRowStride destination image row stride in bytes 10608 */ 10609 void 10610 _mesa_pack_ubyte_rgba_rect(mesa_format format, GLuint width, GLuint height, 10611 const GLubyte *src, GLint srcRowStride, 10612 void *dst, GLint dstRowStride) 10613 { 10614 GLubyte *dstUB = dst; 10615 GLuint i; 10616 10617 if (srcRowStride == width * 4 * sizeof(GLubyte) && 10618 dstRowStride == _mesa_format_row_stride(format, width)) { 10619 /* do whole image at once */ 10620 _mesa_pack_ubyte_rgba_row(format, width * height, 10621 (const GLubyte (*)[4]) src, dst); 10622 } 10623 else { 10624 /* row by row */ 10625 for (i = 0; i < height; i++) { 10626 _mesa_pack_ubyte_rgba_row(format, width, 10627 (const GLubyte (*)[4]) src, dstUB); 10628 src += srcRowStride; 10629 dstUB += dstRowStride; 10630 } 10631 } 10632 } 10633 10634 10635 /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */ 10636 struct z32f_x24s8 10637 { 10638 float z; 10639 uint32_t x24s8; 10640 }; 10641 10642 10643 /** 10644 ** Pack float Z pixels 10645 **/ 10646 10647 static void 10648 pack_float_S8_UINT_Z24_UNORM(const GLfloat *src, void *dst) 10649 { 10650 /* don't disturb the stencil values */ 10651 GLuint *d = ((GLuint *) dst); 10652 const GLdouble scale = (GLdouble) 0xffffff; 10653 GLuint s = *d & 0xff; 10654 GLuint z = (GLuint) (*src * scale); 10655 assert(z <= 0xffffff); 10656 *d = (z << 8) | s; 10657 } 10658 10659 static void 10660 pack_float_Z24_UNORM_S8_UINT(const GLfloat *src, void *dst) 10661 { 10662 /* don't disturb the stencil values */ 10663 GLuint *d = ((GLuint *) dst); 10664 const GLdouble scale = (GLdouble) 0xffffff; 10665 GLuint s = *d & 0xff000000; 10666 GLuint z = (GLuint) (*src * scale); 10667 assert(z <= 0xffffff); 10668 *d = s | z; 10669 } 10670 10671 static void 10672 pack_float_Z_UNORM16(const GLfloat *src, void *dst) 10673 { 10674 GLushort *d = ((GLushort *) dst); 10675 const GLfloat scale = (GLfloat) 0xffff; 10676 *d = (GLushort) (*src * scale); 10677 } 10678 10679 static void 10680 pack_float_Z_UNORM32(const GLfloat *src, void *dst) 10681 { 10682 GLuint *d = ((GLuint *) dst); 10683 const GLdouble scale = (GLdouble) 0xffffffff; 10684 *d = (GLuint) (*src * scale); 10685 } 10686 10687 static void 10688 pack_float_Z_FLOAT32(const GLfloat *src, void *dst) 10689 { 10690 GLfloat *d = (GLfloat *) dst; 10691 *d = *src; 10692 } 10693 10694 gl_pack_float_z_func 10695 _mesa_get_pack_float_z_func(mesa_format format) 10696 { 10697 switch (format) { 10698 case MESA_FORMAT_S8_UINT_Z24_UNORM: 10699 case MESA_FORMAT_X8_UINT_Z24_UNORM: 10700 return pack_float_S8_UINT_Z24_UNORM; 10701 case MESA_FORMAT_Z24_UNORM_S8_UINT: 10702 case MESA_FORMAT_Z24_UNORM_X8_UINT: 10703 return pack_float_Z24_UNORM_S8_UINT; 10704 case MESA_FORMAT_Z_UNORM16: 10705 return pack_float_Z_UNORM16; 10706 case MESA_FORMAT_Z_UNORM32: 10707 return pack_float_Z_UNORM32; 10708 case MESA_FORMAT_Z_FLOAT32: 10709 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 10710 return pack_float_Z_FLOAT32; 10711 default: 10712 _mesa_problem(NULL, 10713 "unexpected format in _mesa_get_pack_float_z_func()"); 10714 return NULL; 10715 } 10716 } 10717 10718 10719 10720 /** 10721 ** Pack uint Z pixels. The incoming src value is always in 10722 ** the range [0, 2^32-1]. 10723 **/ 10724 10725 static void 10726 pack_uint_S8_UINT_Z24_UNORM(const GLuint *src, void *dst) 10727 { 10728 /* don't disturb the stencil values */ 10729 GLuint *d = ((GLuint *) dst); 10730 GLuint s = *d & 0xff; 10731 GLuint z = *src & 0xffffff00; 10732 *d = z | s; 10733 } 10734 10735 static void 10736 pack_uint_Z24_UNORM_S8_UINT(const GLuint *src, void *dst) 10737 { 10738 /* don't disturb the stencil values */ 10739 GLuint *d = ((GLuint *) dst); 10740 GLuint s = *d & 0xff000000; 10741 GLuint z = *src >> 8; 10742 *d = s | z; 10743 } 10744 10745 static void 10746 pack_uint_Z_UNORM16(const GLuint *src, void *dst) 10747 { 10748 GLushort *d = ((GLushort *) dst); 10749 *d = *src >> 16; 10750 } 10751 10752 static void 10753 pack_uint_Z_UNORM32(const GLuint *src, void *dst) 10754 { 10755 GLuint *d = ((GLuint *) dst); 10756 *d = *src; 10757 } 10758 10759 static void 10760 pack_uint_Z_FLOAT32(const GLuint *src, void *dst) 10761 { 10762 GLuint *d = ((GLuint *) dst); 10763 const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; 10764 *d = (GLuint) (*src * scale); 10765 assert(*d >= 0.0f); 10766 assert(*d <= 1.0f); 10767 } 10768 10769 static void 10770 pack_uint_Z_FLOAT32_X24S8(const GLuint *src, void *dst) 10771 { 10772 GLfloat *d = ((GLfloat *) dst); 10773 const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; 10774 *d = (GLfloat) (*src * scale); 10775 assert(*d >= 0.0f); 10776 assert(*d <= 1.0f); 10777 } 10778 10779 gl_pack_uint_z_func 10780 _mesa_get_pack_uint_z_func(mesa_format format) 10781 { 10782 switch (format) { 10783 case MESA_FORMAT_S8_UINT_Z24_UNORM: 10784 case MESA_FORMAT_X8_UINT_Z24_UNORM: 10785 return pack_uint_S8_UINT_Z24_UNORM; 10786 case MESA_FORMAT_Z24_UNORM_S8_UINT: 10787 case MESA_FORMAT_Z24_UNORM_X8_UINT: 10788 return pack_uint_Z24_UNORM_S8_UINT; 10789 case MESA_FORMAT_Z_UNORM16: 10790 return pack_uint_Z_UNORM16; 10791 case MESA_FORMAT_Z_UNORM32: 10792 return pack_uint_Z_UNORM32; 10793 case MESA_FORMAT_Z_FLOAT32: 10794 return pack_uint_Z_FLOAT32; 10795 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 10796 return pack_uint_Z_FLOAT32_X24S8; 10797 default: 10798 _mesa_problem(NULL, "unexpected format in _mesa_get_pack_uint_z_func()"); 10799 return NULL; 10800 } 10801 } 10802 10803 10804 /** 10805 ** Pack ubyte stencil pixels 10806 **/ 10807 10808 static void 10809 pack_ubyte_stencil_Z24_S8(const GLubyte *src, void *dst) 10810 { 10811 /* don't disturb the Z values */ 10812 GLuint *d = ((GLuint *) dst); 10813 GLuint s = *src; 10814 GLuint z = *d & 0xffffff00; 10815 *d = z | s; 10816 } 10817 10818 static void 10819 pack_ubyte_stencil_S8_Z24(const GLubyte *src, void *dst) 10820 { 10821 /* don't disturb the Z values */ 10822 GLuint *d = ((GLuint *) dst); 10823 GLuint s = *src << 24; 10824 GLuint z = *d & 0xffffff; 10825 *d = s | z; 10826 } 10827 10828 static void 10829 pack_ubyte_stencil_S8(const GLubyte *src, void *dst) 10830 { 10831 GLubyte *d = (GLubyte *) dst; 10832 *d = *src; 10833 } 10834 10835 static void 10836 pack_ubyte_stencil_Z32_FLOAT_X24S8(const GLubyte *src, void *dst) 10837 { 10838 GLfloat *d = ((GLfloat *) dst); 10839 d[1] = *src; 10840 } 10841 10842 10843 gl_pack_ubyte_stencil_func 10844 _mesa_get_pack_ubyte_stencil_func(mesa_format format) 10845 { 10846 switch (format) { 10847 case MESA_FORMAT_S8_UINT_Z24_UNORM: 10848 return pack_ubyte_stencil_Z24_S8; 10849 case MESA_FORMAT_Z24_UNORM_S8_UINT: 10850 return pack_ubyte_stencil_S8_Z24; 10851 case MESA_FORMAT_S_UINT8: 10852 return pack_ubyte_stencil_S8; 10853 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 10854 return pack_ubyte_stencil_Z32_FLOAT_X24S8; 10855 default: 10856 _mesa_problem(NULL, 10857 "unexpected format in _mesa_pack_ubyte_stencil_func()"); 10858 return NULL; 10859 } 10860 } 10861 10862 10863 10864 void 10865 _mesa_pack_float_z_row(mesa_format format, GLuint n, 10866 const GLfloat *src, void *dst) 10867 { 10868 switch (format) { 10869 case MESA_FORMAT_S8_UINT_Z24_UNORM: 10870 case MESA_FORMAT_X8_UINT_Z24_UNORM: 10871 { 10872 /* don't disturb the stencil values */ 10873 GLuint *d = ((GLuint *) dst); 10874 const GLdouble scale = (GLdouble) 0xffffff; 10875 GLuint i; 10876 for (i = 0; i < n; i++) { 10877 GLuint s = d[i] & 0xff; 10878 GLuint z = (GLuint) (src[i] * scale); 10879 assert(z <= 0xffffff); 10880 d[i] = (z << 8) | s; 10881 } 10882 } 10883 break; 10884 case MESA_FORMAT_Z24_UNORM_S8_UINT: 10885 case MESA_FORMAT_Z24_UNORM_X8_UINT: 10886 { 10887 /* don't disturb the stencil values */ 10888 GLuint *d = ((GLuint *) dst); 10889 const GLdouble scale = (GLdouble) 0xffffff; 10890 GLuint i; 10891 for (i = 0; i < n; i++) { 10892 GLuint s = d[i] & 0xff000000; 10893 GLuint z = (GLuint) (src[i] * scale); 10894 assert(z <= 0xffffff); 10895 d[i] = s | z; 10896 } 10897 } 10898 break; 10899 case MESA_FORMAT_Z_UNORM16: 10900 { 10901 GLushort *d = ((GLushort *) dst); 10902 const GLfloat scale = (GLfloat) 0xffff; 10903 GLuint i; 10904 for (i = 0; i < n; i++) { 10905 d[i] = (GLushort) (src[i] * scale); 10906 } 10907 } 10908 break; 10909 case MESA_FORMAT_Z_UNORM32: 10910 { 10911 GLuint *d = ((GLuint *) dst); 10912 const GLdouble scale = (GLdouble) 0xffffffff; 10913 GLuint i; 10914 for (i = 0; i < n; i++) { 10915 d[i] = (GLuint) (src[i] * scale); 10916 } 10917 } 10918 break; 10919 case MESA_FORMAT_Z_FLOAT32: 10920 memcpy(dst, src, n * sizeof(GLfloat)); 10921 break; 10922 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 10923 { 10924 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst; 10925 GLuint i; 10926 for (i = 0; i < n; i++) { 10927 d[i].z = src[i]; 10928 } 10929 } 10930 break; 10931 default: 10932 _mesa_problem(NULL, "unexpected format in _mesa_pack_float_z_row()"); 10933 } 10934 } 10935 10936 10937 /** 10938 * The incoming Z values are always in the range [0, 0xffffffff]. 10939 */ 10940 void 10941 _mesa_pack_uint_z_row(mesa_format format, GLuint n, 10942 const GLuint *src, void *dst) 10943 { 10944 switch (format) { 10945 case MESA_FORMAT_S8_UINT_Z24_UNORM: 10946 case MESA_FORMAT_X8_UINT_Z24_UNORM: 10947 { 10948 /* don't disturb the stencil values */ 10949 GLuint *d = ((GLuint *) dst); 10950 GLuint i; 10951 for (i = 0; i < n; i++) { 10952 GLuint s = d[i] & 0xff; 10953 GLuint z = src[i] & 0xffffff00; 10954 d[i] = z | s; 10955 } 10956 } 10957 break; 10958 case MESA_FORMAT_Z24_UNORM_S8_UINT: 10959 case MESA_FORMAT_Z24_UNORM_X8_UINT: 10960 { 10961 /* don't disturb the stencil values */ 10962 GLuint *d = ((GLuint *) dst); 10963 GLuint i; 10964 for (i = 0; i < n; i++) { 10965 GLuint s = d[i] & 0xff000000; 10966 GLuint z = src[i] >> 8; 10967 d[i] = s | z; 10968 } 10969 } 10970 break; 10971 case MESA_FORMAT_Z_UNORM16: 10972 { 10973 GLushort *d = ((GLushort *) dst); 10974 GLuint i; 10975 for (i = 0; i < n; i++) { 10976 d[i] = src[i] >> 16; 10977 } 10978 } 10979 break; 10980 case MESA_FORMAT_Z_UNORM32: 10981 memcpy(dst, src, n * sizeof(GLfloat)); 10982 break; 10983 case MESA_FORMAT_Z_FLOAT32: 10984 { 10985 GLuint *d = ((GLuint *) dst); 10986 const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; 10987 GLuint i; 10988 for (i = 0; i < n; i++) { 10989 d[i] = (GLuint) (src[i] * scale); 10990 assert(d[i] >= 0.0f); 10991 assert(d[i] <= 1.0f); 10992 } 10993 } 10994 break; 10995 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 10996 { 10997 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst; 10998 const GLdouble scale = 1.0 / (GLdouble) 0xffffffff; 10999 GLuint i; 11000 for (i = 0; i < n; i++) { 11001 d[i].z = (GLfloat) (src[i] * scale); 11002 assert(d[i].z >= 0.0f); 11003 assert(d[i].z <= 1.0f); 11004 } 11005 } 11006 break; 11007 default: 11008 _mesa_problem(NULL, "unexpected format in _mesa_pack_uint_z_row()"); 11009 } 11010 } 11011 11012 11013 void 11014 _mesa_pack_ubyte_stencil_row(mesa_format format, GLuint n, 11015 const GLubyte *src, void *dst) 11016 { 11017 switch (format) { 11018 case MESA_FORMAT_S8_UINT_Z24_UNORM: 11019 { 11020 /* don't disturb the Z values */ 11021 GLuint *d = ((GLuint *) dst); 11022 GLuint i; 11023 for (i = 0; i < n; i++) { 11024 GLuint s = src[i]; 11025 GLuint z = d[i] & 0xffffff00; 11026 d[i] = z | s; 11027 } 11028 } 11029 break; 11030 case MESA_FORMAT_Z24_UNORM_S8_UINT: 11031 { 11032 /* don't disturb the Z values */ 11033 GLuint *d = ((GLuint *) dst); 11034 GLuint i; 11035 for (i = 0; i < n; i++) { 11036 GLuint s = src[i] << 24; 11037 GLuint z = d[i] & 0xffffff; 11038 d[i] = s | z; 11039 } 11040 } 11041 break; 11042 case MESA_FORMAT_S_UINT8: 11043 memcpy(dst, src, n * sizeof(GLubyte)); 11044 break; 11045 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 11046 { 11047 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst; 11048 GLuint i; 11049 for (i = 0; i < n; i++) { 11050 d[i].x24s8 = src[i]; 11051 } 11052 } 11053 break; 11054 default: 11055 _mesa_problem(NULL, "unexpected format in _mesa_pack_ubyte_stencil_row()"); 11056 } 11057 } 11058 11059 11060 /** 11061 * Incoming Z/stencil values are always in uint_24_8 format. 11062 */ 11063 void 11064 _mesa_pack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n, 11065 const GLuint *src, void *dst) 11066 { 11067 switch (format) { 11068 case MESA_FORMAT_S8_UINT_Z24_UNORM: 11069 memcpy(dst, src, n * sizeof(GLuint)); 11070 break; 11071 case MESA_FORMAT_Z24_UNORM_S8_UINT: 11072 { 11073 GLuint *d = ((GLuint *) dst); 11074 GLuint i; 11075 for (i = 0; i < n; i++) { 11076 GLuint s = src[i] << 24; 11077 GLuint z = src[i] >> 8; 11078 d[i] = s | z; 11079 } 11080 } 11081 break; 11082 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT: 11083 { 11084 const GLdouble scale = 1.0 / (GLdouble) 0xffffff; 11085 struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst; 11086 GLuint i; 11087 for (i = 0; i < n; i++) { 11088 GLfloat z = (GLfloat) ((src[i] >> 8) * scale); 11089 d[i].z = z; 11090 d[i].x24s8 = src[i]; 11091 } 11092 } 11093 break; 11094 default: 11095 _mesa_problem(NULL, "bad format %s in _mesa_pack_ubyte_s_row", 11096 _mesa_get_format_name(format)); 11097 return; 11098 } 11099 } 11100 11101 11102 11103 /** 11104 * Convert a boolean color mask to a packed color where each channel of 11105 * the packed value at dst will be 0 or ~0 depending on the colorMask. 11106 */ 11107 void 11108 _mesa_pack_colormask(mesa_format format, const GLubyte colorMask[4], void *dst) 11109 { 11110 GLfloat maskColor[4]; 11111 11112 switch (_mesa_get_format_datatype(format)) { 11113 case GL_UNSIGNED_NORMALIZED: 11114 /* simple: 1.0 will convert to ~0 in the right bit positions */ 11115 maskColor[0] = colorMask[0] ? 1.0f : 0.0f; 11116 maskColor[1] = colorMask[1] ? 1.0f : 0.0f; 11117 maskColor[2] = colorMask[2] ? 1.0f : 0.0f; 11118 maskColor[3] = colorMask[3] ? 1.0f : 0.0f; 11119 _mesa_pack_float_rgba_row(format, 1, 11120 (const GLfloat (*)[4]) maskColor, dst); 11121 break; 11122 case GL_SIGNED_NORMALIZED: 11123 case GL_FLOAT: 11124 /* These formats are harder because it's hard to know the floating 11125 * point values that will convert to ~0 for each color channel's bits. 11126 * This solution just generates a non-zero value for each color channel 11127 * then fixes up the non-zero values to be ~0. 11128 * Note: we'll need to add special case code if we ever have to deal 11129 * with formats with unequal color channel sizes, like R11_G11_B10. 11130 * We issue a warning below for channel sizes other than 8,16,32. 11131 */ 11132 { 11133 GLuint bits = _mesa_get_format_max_bits(format); /* bits per chan */ 11134 GLuint bytes = _mesa_get_format_bytes(format); 11135 GLuint i; 11136 11137 /* this should put non-zero values into the channels of dst */ 11138 maskColor[0] = colorMask[0] ? -1.0f : 0.0f; 11139 maskColor[1] = colorMask[1] ? -1.0f : 0.0f; 11140 maskColor[2] = colorMask[2] ? -1.0f : 0.0f; 11141 maskColor[3] = colorMask[3] ? -1.0f : 0.0f; 11142 _mesa_pack_float_rgba_row(format, 1, 11143 (const GLfloat (*)[4]) maskColor, dst); 11144 11145 /* fix-up the dst channels by converting non-zero values to ~0 */ 11146 if (bits == 8) { 11147 GLubyte *d = (GLubyte *) dst; 11148 for (i = 0; i < bytes; i++) { 11149 d[i] = d[i] ? 0xff : 0x0; 11150 } 11151 } 11152 else if (bits == 16) { 11153 GLushort *d = (GLushort *) dst; 11154 for (i = 0; i < bytes / 2; i++) { 11155 d[i] = d[i] ? 0xffff : 0x0; 11156 } 11157 } 11158 else if (bits == 32) { 11159 GLuint *d = (GLuint *) dst; 11160 for (i = 0; i < bytes / 4; i++) { 11161 d[i] = d[i] ? 0xffffffffU : 0x0; 11162 } 11163 } 11164 else { 11165 _mesa_problem(NULL, "unexpected size in _mesa_pack_colormask()"); 11166 return; 11167 } 11168 } 11169 break; 11170 default: 11171 _mesa_problem(NULL, "unexpected format data type in gen_color_mask()"); 11172 return; 11173 } 11174 } 11175 11176