Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

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