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