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_unpack.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.  
  50.  
  51.  
  52. /* float unpacking functions */
  53.  
  54.  
  55. static inline void
  56. unpack_float_a8b8g8r8_unorm(const void *void_src, GLfloat dst[4])
  57. {
  58.    uint32_t *src = (uint32_t *)void_src;
  59.             uint8_t a = UNPACK(*src, 0, 8);
  60.             uint8_t b = UNPACK(*src, 8, 8);
  61.             uint8_t g = UNPACK(*src, 16, 8);
  62.             uint8_t r = UNPACK(*src, 24, 8);
  63.  
  64.      
  65.          
  66.                dst[0] = _mesa_unorm_to_float(r, 8);
  67.      
  68.          
  69.                dst[1] = _mesa_unorm_to_float(g, 8);
  70.      
  71.          
  72.                dst[2] = _mesa_unorm_to_float(b, 8);
  73.      
  74.          
  75.                dst[3] = _mesa_unorm_to_float(a, 8);
  76. }
  77.  
  78. static inline void
  79. unpack_float_x8b8g8r8_unorm(const void *void_src, GLfloat dst[4])
  80. {
  81.    uint32_t *src = (uint32_t *)void_src;
  82.             uint8_t b = UNPACK(*src, 8, 8);
  83.             uint8_t g = UNPACK(*src, 16, 8);
  84.             uint8_t r = UNPACK(*src, 24, 8);
  85.  
  86.      
  87.          
  88.                dst[0] = _mesa_unorm_to_float(r, 8);
  89.      
  90.          
  91.                dst[1] = _mesa_unorm_to_float(g, 8);
  92.      
  93.          
  94.                dst[2] = _mesa_unorm_to_float(b, 8);
  95.      
  96.          dst[3] = 1.0f;
  97. }
  98.  
  99. static inline void
  100. unpack_float_r8g8b8a8_unorm(const void *void_src, GLfloat dst[4])
  101. {
  102.    uint32_t *src = (uint32_t *)void_src;
  103.             uint8_t r = UNPACK(*src, 0, 8);
  104.             uint8_t g = UNPACK(*src, 8, 8);
  105.             uint8_t b = UNPACK(*src, 16, 8);
  106.             uint8_t a = UNPACK(*src, 24, 8);
  107.  
  108.      
  109.          
  110.                dst[0] = _mesa_unorm_to_float(r, 8);
  111.      
  112.          
  113.                dst[1] = _mesa_unorm_to_float(g, 8);
  114.      
  115.          
  116.                dst[2] = _mesa_unorm_to_float(b, 8);
  117.      
  118.          
  119.                dst[3] = _mesa_unorm_to_float(a, 8);
  120. }
  121.  
  122. static inline void
  123. unpack_float_r8g8b8x8_unorm(const void *void_src, GLfloat dst[4])
  124. {
  125.    uint32_t *src = (uint32_t *)void_src;
  126.             uint8_t r = UNPACK(*src, 0, 8);
  127.             uint8_t g = UNPACK(*src, 8, 8);
  128.             uint8_t b = UNPACK(*src, 16, 8);
  129.  
  130.      
  131.          
  132.                dst[0] = _mesa_unorm_to_float(r, 8);
  133.      
  134.          
  135.                dst[1] = _mesa_unorm_to_float(g, 8);
  136.      
  137.          
  138.                dst[2] = _mesa_unorm_to_float(b, 8);
  139.      
  140.          dst[3] = 1.0f;
  141. }
  142.  
  143. static inline void
  144. unpack_float_b8g8r8a8_unorm(const void *void_src, GLfloat dst[4])
  145. {
  146.    uint32_t *src = (uint32_t *)void_src;
  147.             uint8_t b = UNPACK(*src, 0, 8);
  148.             uint8_t g = UNPACK(*src, 8, 8);
  149.             uint8_t r = UNPACK(*src, 16, 8);
  150.             uint8_t a = UNPACK(*src, 24, 8);
  151.  
  152.      
  153.          
  154.                dst[0] = _mesa_unorm_to_float(r, 8);
  155.      
  156.          
  157.                dst[1] = _mesa_unorm_to_float(g, 8);
  158.      
  159.          
  160.                dst[2] = _mesa_unorm_to_float(b, 8);
  161.      
  162.          
  163.                dst[3] = _mesa_unorm_to_float(a, 8);
  164. }
  165.  
  166. static inline void
  167. unpack_float_b8g8r8x8_unorm(const void *void_src, GLfloat dst[4])
  168. {
  169.    uint32_t *src = (uint32_t *)void_src;
  170.             uint8_t b = UNPACK(*src, 0, 8);
  171.             uint8_t g = UNPACK(*src, 8, 8);
  172.             uint8_t r = UNPACK(*src, 16, 8);
  173.  
  174.      
  175.          
  176.                dst[0] = _mesa_unorm_to_float(r, 8);
  177.      
  178.          
  179.                dst[1] = _mesa_unorm_to_float(g, 8);
  180.      
  181.          
  182.                dst[2] = _mesa_unorm_to_float(b, 8);
  183.      
  184.          dst[3] = 1.0f;
  185. }
  186.  
  187. static inline void
  188. unpack_float_a8r8g8b8_unorm(const void *void_src, GLfloat dst[4])
  189. {
  190.    uint32_t *src = (uint32_t *)void_src;
  191.             uint8_t a = UNPACK(*src, 0, 8);
  192.             uint8_t r = UNPACK(*src, 8, 8);
  193.             uint8_t g = UNPACK(*src, 16, 8);
  194.             uint8_t b = UNPACK(*src, 24, 8);
  195.  
  196.      
  197.          
  198.                dst[0] = _mesa_unorm_to_float(r, 8);
  199.      
  200.          
  201.                dst[1] = _mesa_unorm_to_float(g, 8);
  202.      
  203.          
  204.                dst[2] = _mesa_unorm_to_float(b, 8);
  205.      
  206.          
  207.                dst[3] = _mesa_unorm_to_float(a, 8);
  208. }
  209.  
  210. static inline void
  211. unpack_float_x8r8g8b8_unorm(const void *void_src, GLfloat dst[4])
  212. {
  213.    uint32_t *src = (uint32_t *)void_src;
  214.             uint8_t r = UNPACK(*src, 8, 8);
  215.             uint8_t g = UNPACK(*src, 16, 8);
  216.             uint8_t b = UNPACK(*src, 24, 8);
  217.  
  218.      
  219.          
  220.                dst[0] = _mesa_unorm_to_float(r, 8);
  221.      
  222.          
  223.                dst[1] = _mesa_unorm_to_float(g, 8);
  224.      
  225.          
  226.                dst[2] = _mesa_unorm_to_float(b, 8);
  227.      
  228.          dst[3] = 1.0f;
  229. }
  230.  
  231. static inline void
  232. unpack_float_l16a16_unorm(const void *void_src, GLfloat dst[4])
  233. {
  234.    uint32_t *src = (uint32_t *)void_src;
  235.             uint16_t l = UNPACK(*src, 0, 16);
  236.             uint16_t a = UNPACK(*src, 16, 16);
  237.  
  238.      
  239.          
  240.                dst[0] = _mesa_unorm_to_float(l, 16);
  241.      
  242.          
  243.                dst[1] = _mesa_unorm_to_float(l, 16);
  244.      
  245.          
  246.                dst[2] = _mesa_unorm_to_float(l, 16);
  247.      
  248.          
  249.                dst[3] = _mesa_unorm_to_float(a, 16);
  250. }
  251.  
  252. static inline void
  253. unpack_float_a16l16_unorm(const void *void_src, GLfloat dst[4])
  254. {
  255.    uint32_t *src = (uint32_t *)void_src;
  256.             uint16_t a = UNPACK(*src, 0, 16);
  257.             uint16_t l = UNPACK(*src, 16, 16);
  258.  
  259.      
  260.          
  261.                dst[0] = _mesa_unorm_to_float(l, 16);
  262.      
  263.          
  264.                dst[1] = _mesa_unorm_to_float(l, 16);
  265.      
  266.          
  267.                dst[2] = _mesa_unorm_to_float(l, 16);
  268.      
  269.          
  270.                dst[3] = _mesa_unorm_to_float(a, 16);
  271. }
  272.  
  273. static inline void
  274. unpack_float_b5g6r5_unorm(const void *void_src, GLfloat dst[4])
  275. {
  276.    uint16_t *src = (uint16_t *)void_src;
  277.             uint8_t b = UNPACK(*src, 0, 5);
  278.             uint8_t g = UNPACK(*src, 5, 6);
  279.             uint8_t r = UNPACK(*src, 11, 5);
  280.  
  281.      
  282.          
  283.                dst[0] = _mesa_unorm_to_float(r, 5);
  284.      
  285.          
  286.                dst[1] = _mesa_unorm_to_float(g, 6);
  287.      
  288.          
  289.                dst[2] = _mesa_unorm_to_float(b, 5);
  290.      
  291.          dst[3] = 1.0f;
  292. }
  293.  
  294. static inline void
  295. unpack_float_r5g6b5_unorm(const void *void_src, GLfloat dst[4])
  296. {
  297.    uint16_t *src = (uint16_t *)void_src;
  298.             uint8_t r = UNPACK(*src, 0, 5);
  299.             uint8_t g = UNPACK(*src, 5, 6);
  300.             uint8_t b = UNPACK(*src, 11, 5);
  301.  
  302.      
  303.          
  304.                dst[0] = _mesa_unorm_to_float(r, 5);
  305.      
  306.          
  307.                dst[1] = _mesa_unorm_to_float(g, 6);
  308.      
  309.          
  310.                dst[2] = _mesa_unorm_to_float(b, 5);
  311.      
  312.          dst[3] = 1.0f;
  313. }
  314.  
  315. static inline void
  316. unpack_float_b4g4r4a4_unorm(const void *void_src, GLfloat dst[4])
  317. {
  318.    uint16_t *src = (uint16_t *)void_src;
  319.             uint8_t b = UNPACK(*src, 0, 4);
  320.             uint8_t g = UNPACK(*src, 4, 4);
  321.             uint8_t r = UNPACK(*src, 8, 4);
  322.             uint8_t a = UNPACK(*src, 12, 4);
  323.  
  324.      
  325.          
  326.                dst[0] = _mesa_unorm_to_float(r, 4);
  327.      
  328.          
  329.                dst[1] = _mesa_unorm_to_float(g, 4);
  330.      
  331.          
  332.                dst[2] = _mesa_unorm_to_float(b, 4);
  333.      
  334.          
  335.                dst[3] = _mesa_unorm_to_float(a, 4);
  336. }
  337.  
  338. static inline void
  339. unpack_float_b4g4r4x4_unorm(const void *void_src, GLfloat dst[4])
  340. {
  341.    uint16_t *src = (uint16_t *)void_src;
  342.             uint8_t b = UNPACK(*src, 0, 4);
  343.             uint8_t g = UNPACK(*src, 4, 4);
  344.             uint8_t r = UNPACK(*src, 8, 4);
  345.  
  346.      
  347.          
  348.                dst[0] = _mesa_unorm_to_float(r, 4);
  349.      
  350.          
  351.                dst[1] = _mesa_unorm_to_float(g, 4);
  352.      
  353.          
  354.                dst[2] = _mesa_unorm_to_float(b, 4);
  355.      
  356.          dst[3] = 1.0f;
  357. }
  358.  
  359. static inline void
  360. unpack_float_a4r4g4b4_unorm(const void *void_src, GLfloat dst[4])
  361. {
  362.    uint16_t *src = (uint16_t *)void_src;
  363.             uint8_t a = UNPACK(*src, 0, 4);
  364.             uint8_t r = UNPACK(*src, 4, 4);
  365.             uint8_t g = UNPACK(*src, 8, 4);
  366.             uint8_t b = UNPACK(*src, 12, 4);
  367.  
  368.      
  369.          
  370.                dst[0] = _mesa_unorm_to_float(r, 4);
  371.      
  372.          
  373.                dst[1] = _mesa_unorm_to_float(g, 4);
  374.      
  375.          
  376.                dst[2] = _mesa_unorm_to_float(b, 4);
  377.      
  378.          
  379.                dst[3] = _mesa_unorm_to_float(a, 4);
  380. }
  381.  
  382. static inline void
  383. unpack_float_a1b5g5r5_unorm(const void *void_src, GLfloat dst[4])
  384. {
  385.    uint16_t *src = (uint16_t *)void_src;
  386.             uint8_t a = UNPACK(*src, 0, 1);
  387.             uint8_t b = UNPACK(*src, 1, 5);
  388.             uint8_t g = UNPACK(*src, 6, 5);
  389.             uint8_t r = UNPACK(*src, 11, 5);
  390.  
  391.      
  392.          
  393.                dst[0] = _mesa_unorm_to_float(r, 5);
  394.      
  395.          
  396.                dst[1] = _mesa_unorm_to_float(g, 5);
  397.      
  398.          
  399.                dst[2] = _mesa_unorm_to_float(b, 5);
  400.      
  401.          
  402.                dst[3] = _mesa_unorm_to_float(a, 1);
  403. }
  404.  
  405. static inline void
  406. unpack_float_b5g5r5a1_unorm(const void *void_src, GLfloat dst[4])
  407. {
  408.    uint16_t *src = (uint16_t *)void_src;
  409.             uint8_t b = UNPACK(*src, 0, 5);
  410.             uint8_t g = UNPACK(*src, 5, 5);
  411.             uint8_t r = UNPACK(*src, 10, 5);
  412.             uint8_t a = UNPACK(*src, 15, 1);
  413.  
  414.      
  415.          
  416.                dst[0] = _mesa_unorm_to_float(r, 5);
  417.      
  418.          
  419.                dst[1] = _mesa_unorm_to_float(g, 5);
  420.      
  421.          
  422.                dst[2] = _mesa_unorm_to_float(b, 5);
  423.      
  424.          
  425.                dst[3] = _mesa_unorm_to_float(a, 1);
  426. }
  427.  
  428. static inline void
  429. unpack_float_b5g5r5x1_unorm(const void *void_src, GLfloat dst[4])
  430. {
  431.    uint16_t *src = (uint16_t *)void_src;
  432.             uint8_t b = UNPACK(*src, 0, 5);
  433.             uint8_t g = UNPACK(*src, 5, 5);
  434.             uint8_t r = UNPACK(*src, 10, 5);
  435.  
  436.      
  437.          
  438.                dst[0] = _mesa_unorm_to_float(r, 5);
  439.      
  440.          
  441.                dst[1] = _mesa_unorm_to_float(g, 5);
  442.      
  443.          
  444.                dst[2] = _mesa_unorm_to_float(b, 5);
  445.      
  446.          dst[3] = 1.0f;
  447. }
  448.  
  449. static inline void
  450. unpack_float_a1r5g5b5_unorm(const void *void_src, GLfloat dst[4])
  451. {
  452.    uint16_t *src = (uint16_t *)void_src;
  453.             uint8_t a = UNPACK(*src, 0, 1);
  454.             uint8_t r = UNPACK(*src, 1, 5);
  455.             uint8_t g = UNPACK(*src, 6, 5);
  456.             uint8_t b = UNPACK(*src, 11, 5);
  457.  
  458.      
  459.          
  460.                dst[0] = _mesa_unorm_to_float(r, 5);
  461.      
  462.          
  463.                dst[1] = _mesa_unorm_to_float(g, 5);
  464.      
  465.          
  466.                dst[2] = _mesa_unorm_to_float(b, 5);
  467.      
  468.          
  469.                dst[3] = _mesa_unorm_to_float(a, 1);
  470. }
  471.  
  472. static inline void
  473. unpack_float_l8a8_unorm(const void *void_src, GLfloat dst[4])
  474. {
  475.    uint16_t *src = (uint16_t *)void_src;
  476.             uint8_t l = UNPACK(*src, 0, 8);
  477.             uint8_t a = UNPACK(*src, 8, 8);
  478.  
  479.      
  480.          
  481.                dst[0] = _mesa_unorm_to_float(l, 8);
  482.      
  483.          
  484.                dst[1] = _mesa_unorm_to_float(l, 8);
  485.      
  486.          
  487.                dst[2] = _mesa_unorm_to_float(l, 8);
  488.      
  489.          
  490.                dst[3] = _mesa_unorm_to_float(a, 8);
  491. }
  492.  
  493. static inline void
  494. unpack_float_a8l8_unorm(const void *void_src, GLfloat dst[4])
  495. {
  496.    uint16_t *src = (uint16_t *)void_src;
  497.             uint8_t a = UNPACK(*src, 0, 8);
  498.             uint8_t l = UNPACK(*src, 8, 8);
  499.  
  500.      
  501.          
  502.                dst[0] = _mesa_unorm_to_float(l, 8);
  503.      
  504.          
  505.                dst[1] = _mesa_unorm_to_float(l, 8);
  506.      
  507.          
  508.                dst[2] = _mesa_unorm_to_float(l, 8);
  509.      
  510.          
  511.                dst[3] = _mesa_unorm_to_float(a, 8);
  512. }
  513.  
  514. static inline void
  515. unpack_float_r8g8_unorm(const void *void_src, GLfloat dst[4])
  516. {
  517.    uint16_t *src = (uint16_t *)void_src;
  518.             uint8_t r = UNPACK(*src, 0, 8);
  519.             uint8_t g = UNPACK(*src, 8, 8);
  520.  
  521.      
  522.          
  523.                dst[0] = _mesa_unorm_to_float(r, 8);
  524.      
  525.          
  526.                dst[1] = _mesa_unorm_to_float(g, 8);
  527.      
  528.          dst[2] = 0.0f;
  529.      
  530.          dst[3] = 1.0f;
  531. }
  532.  
  533. static inline void
  534. unpack_float_g8r8_unorm(const void *void_src, GLfloat dst[4])
  535. {
  536.    uint16_t *src = (uint16_t *)void_src;
  537.             uint8_t g = UNPACK(*src, 0, 8);
  538.             uint8_t r = UNPACK(*src, 8, 8);
  539.  
  540.      
  541.          
  542.                dst[0] = _mesa_unorm_to_float(r, 8);
  543.      
  544.          
  545.                dst[1] = _mesa_unorm_to_float(g, 8);
  546.      
  547.          dst[2] = 0.0f;
  548.      
  549.          dst[3] = 1.0f;
  550. }
  551.  
  552. static inline void
  553. unpack_float_l4a4_unorm(const void *void_src, GLfloat dst[4])
  554. {
  555.    uint8_t *src = (uint8_t *)void_src;
  556.             uint8_t l = UNPACK(*src, 0, 4);
  557.             uint8_t a = UNPACK(*src, 4, 4);
  558.  
  559.      
  560.          
  561.                dst[0] = _mesa_unorm_to_float(l, 4);
  562.      
  563.          
  564.                dst[1] = _mesa_unorm_to_float(l, 4);
  565.      
  566.          
  567.                dst[2] = _mesa_unorm_to_float(l, 4);
  568.      
  569.          
  570.                dst[3] = _mesa_unorm_to_float(a, 4);
  571. }
  572.  
  573. static inline void
  574. unpack_float_b2g3r3_unorm(const void *void_src, GLfloat dst[4])
  575. {
  576.    uint8_t *src = (uint8_t *)void_src;
  577.             uint8_t b = UNPACK(*src, 0, 2);
  578.             uint8_t g = UNPACK(*src, 2, 3);
  579.             uint8_t r = UNPACK(*src, 5, 3);
  580.  
  581.      
  582.          
  583.                dst[0] = _mesa_unorm_to_float(r, 3);
  584.      
  585.          
  586.                dst[1] = _mesa_unorm_to_float(g, 3);
  587.      
  588.          
  589.                dst[2] = _mesa_unorm_to_float(b, 2);
  590.      
  591.          dst[3] = 1.0f;
  592. }
  593.  
  594. static inline void
  595. unpack_float_r16g16_unorm(const void *void_src, GLfloat dst[4])
  596. {
  597.    uint32_t *src = (uint32_t *)void_src;
  598.             uint16_t r = UNPACK(*src, 0, 16);
  599.             uint16_t g = UNPACK(*src, 16, 16);
  600.  
  601.      
  602.          
  603.                dst[0] = _mesa_unorm_to_float(r, 16);
  604.      
  605.          
  606.                dst[1] = _mesa_unorm_to_float(g, 16);
  607.      
  608.          dst[2] = 0.0f;
  609.      
  610.          dst[3] = 1.0f;
  611. }
  612.  
  613. static inline void
  614. unpack_float_g16r16_unorm(const void *void_src, GLfloat dst[4])
  615. {
  616.    uint32_t *src = (uint32_t *)void_src;
  617.             uint16_t g = UNPACK(*src, 0, 16);
  618.             uint16_t r = UNPACK(*src, 16, 16);
  619.  
  620.      
  621.          
  622.                dst[0] = _mesa_unorm_to_float(r, 16);
  623.      
  624.          
  625.                dst[1] = _mesa_unorm_to_float(g, 16);
  626.      
  627.          dst[2] = 0.0f;
  628.      
  629.          dst[3] = 1.0f;
  630. }
  631.  
  632. static inline void
  633. unpack_float_b10g10r10a2_unorm(const void *void_src, GLfloat dst[4])
  634. {
  635.    uint32_t *src = (uint32_t *)void_src;
  636.             uint16_t b = UNPACK(*src, 0, 10);
  637.             uint16_t g = UNPACK(*src, 10, 10);
  638.             uint16_t r = UNPACK(*src, 20, 10);
  639.             uint8_t a = UNPACK(*src, 30, 2);
  640.  
  641.      
  642.          
  643.                dst[0] = _mesa_unorm_to_float(r, 10);
  644.      
  645.          
  646.                dst[1] = _mesa_unorm_to_float(g, 10);
  647.      
  648.          
  649.                dst[2] = _mesa_unorm_to_float(b, 10);
  650.      
  651.          
  652.                dst[3] = _mesa_unorm_to_float(a, 2);
  653. }
  654.  
  655. static inline void
  656. unpack_float_b10g10r10x2_unorm(const void *void_src, GLfloat dst[4])
  657. {
  658.    uint32_t *src = (uint32_t *)void_src;
  659.             uint16_t b = UNPACK(*src, 0, 10);
  660.             uint16_t g = UNPACK(*src, 10, 10);
  661.             uint16_t r = UNPACK(*src, 20, 10);
  662.  
  663.      
  664.          
  665.                dst[0] = _mesa_unorm_to_float(r, 10);
  666.      
  667.          
  668.                dst[1] = _mesa_unorm_to_float(g, 10);
  669.      
  670.          
  671.                dst[2] = _mesa_unorm_to_float(b, 10);
  672.      
  673.          dst[3] = 1.0f;
  674. }
  675.  
  676. static inline void
  677. unpack_float_r10g10b10a2_unorm(const void *void_src, GLfloat dst[4])
  678. {
  679.    uint32_t *src = (uint32_t *)void_src;
  680.             uint16_t r = UNPACK(*src, 0, 10);
  681.             uint16_t g = UNPACK(*src, 10, 10);
  682.             uint16_t b = UNPACK(*src, 20, 10);
  683.             uint8_t a = UNPACK(*src, 30, 2);
  684.  
  685.      
  686.          
  687.                dst[0] = _mesa_unorm_to_float(r, 10);
  688.      
  689.          
  690.                dst[1] = _mesa_unorm_to_float(g, 10);
  691.      
  692.          
  693.                dst[2] = _mesa_unorm_to_float(b, 10);
  694.      
  695.          
  696.                dst[3] = _mesa_unorm_to_float(a, 2);
  697. }
  698.  
  699. static inline void
  700. unpack_float_r10g10b10x2_unorm(const void *void_src, GLfloat dst[4])
  701. {
  702.    uint32_t *src = (uint32_t *)void_src;
  703.             uint16_t r = UNPACK(*src, 0, 10);
  704.             uint16_t g = UNPACK(*src, 10, 10);
  705.             uint16_t b = UNPACK(*src, 20, 10);
  706.  
  707.      
  708.          
  709.                dst[0] = _mesa_unorm_to_float(r, 10);
  710.      
  711.          
  712.                dst[1] = _mesa_unorm_to_float(g, 10);
  713.      
  714.          
  715.                dst[2] = _mesa_unorm_to_float(b, 10);
  716.      
  717.          dst[3] = 1.0f;
  718. }
  719.  
  720. static inline void
  721. unpack_float_r3g3b2_unorm(const void *void_src, GLfloat dst[4])
  722. {
  723.    uint8_t *src = (uint8_t *)void_src;
  724.             uint8_t r = UNPACK(*src, 0, 3);
  725.             uint8_t g = UNPACK(*src, 3, 3);
  726.             uint8_t b = UNPACK(*src, 6, 2);
  727.  
  728.      
  729.          
  730.                dst[0] = _mesa_unorm_to_float(r, 3);
  731.      
  732.          
  733.                dst[1] = _mesa_unorm_to_float(g, 3);
  734.      
  735.          
  736.                dst[2] = _mesa_unorm_to_float(b, 2);
  737.      
  738.          dst[3] = 1.0f;
  739. }
  740.  
  741. static inline void
  742. unpack_float_a4b4g4r4_unorm(const void *void_src, GLfloat dst[4])
  743. {
  744.    uint16_t *src = (uint16_t *)void_src;
  745.             uint8_t a = UNPACK(*src, 0, 4);
  746.             uint8_t b = UNPACK(*src, 4, 4);
  747.             uint8_t g = UNPACK(*src, 8, 4);
  748.             uint8_t r = UNPACK(*src, 12, 4);
  749.  
  750.      
  751.          
  752.                dst[0] = _mesa_unorm_to_float(r, 4);
  753.      
  754.          
  755.                dst[1] = _mesa_unorm_to_float(g, 4);
  756.      
  757.          
  758.                dst[2] = _mesa_unorm_to_float(b, 4);
  759.      
  760.          
  761.                dst[3] = _mesa_unorm_to_float(a, 4);
  762. }
  763.  
  764. static inline void
  765. unpack_float_r4g4b4a4_unorm(const void *void_src, GLfloat dst[4])
  766. {
  767.    uint16_t *src = (uint16_t *)void_src;
  768.             uint8_t r = UNPACK(*src, 0, 4);
  769.             uint8_t g = UNPACK(*src, 4, 4);
  770.             uint8_t b = UNPACK(*src, 8, 4);
  771.             uint8_t a = UNPACK(*src, 12, 4);
  772.  
  773.      
  774.          
  775.                dst[0] = _mesa_unorm_to_float(r, 4);
  776.      
  777.          
  778.                dst[1] = _mesa_unorm_to_float(g, 4);
  779.      
  780.          
  781.                dst[2] = _mesa_unorm_to_float(b, 4);
  782.      
  783.          
  784.                dst[3] = _mesa_unorm_to_float(a, 4);
  785. }
  786.  
  787. static inline void
  788. unpack_float_r5g5b5a1_unorm(const void *void_src, GLfloat dst[4])
  789. {
  790.    uint16_t *src = (uint16_t *)void_src;
  791.             uint8_t r = UNPACK(*src, 0, 5);
  792.             uint8_t g = UNPACK(*src, 5, 5);
  793.             uint8_t b = UNPACK(*src, 10, 5);
  794.             uint8_t a = UNPACK(*src, 15, 1);
  795.  
  796.      
  797.          
  798.                dst[0] = _mesa_unorm_to_float(r, 5);
  799.      
  800.          
  801.                dst[1] = _mesa_unorm_to_float(g, 5);
  802.      
  803.          
  804.                dst[2] = _mesa_unorm_to_float(b, 5);
  805.      
  806.          
  807.                dst[3] = _mesa_unorm_to_float(a, 1);
  808. }
  809.  
  810. static inline void
  811. unpack_float_a2b10g10r10_unorm(const void *void_src, GLfloat dst[4])
  812. {
  813.    uint32_t *src = (uint32_t *)void_src;
  814.             uint8_t a = UNPACK(*src, 0, 2);
  815.             uint16_t b = UNPACK(*src, 2, 10);
  816.             uint16_t g = UNPACK(*src, 12, 10);
  817.             uint16_t r = UNPACK(*src, 22, 10);
  818.  
  819.      
  820.          
  821.                dst[0] = _mesa_unorm_to_float(r, 10);
  822.      
  823.          
  824.                dst[1] = _mesa_unorm_to_float(g, 10);
  825.      
  826.          
  827.                dst[2] = _mesa_unorm_to_float(b, 10);
  828.      
  829.          
  830.                dst[3] = _mesa_unorm_to_float(a, 2);
  831. }
  832.  
  833. static inline void
  834. unpack_float_a2r10g10b10_unorm(const void *void_src, GLfloat dst[4])
  835. {
  836.    uint32_t *src = (uint32_t *)void_src;
  837.             uint8_t a = UNPACK(*src, 0, 2);
  838.             uint16_t r = UNPACK(*src, 2, 10);
  839.             uint16_t g = UNPACK(*src, 12, 10);
  840.             uint16_t b = UNPACK(*src, 22, 10);
  841.  
  842.      
  843.          
  844.                dst[0] = _mesa_unorm_to_float(r, 10);
  845.      
  846.          
  847.                dst[1] = _mesa_unorm_to_float(g, 10);
  848.      
  849.          
  850.                dst[2] = _mesa_unorm_to_float(b, 10);
  851.      
  852.          
  853.                dst[3] = _mesa_unorm_to_float(a, 2);
  854. }
  855.  
  856. static inline void
  857. unpack_float_a_unorm8(const void *void_src, GLfloat dst[4])
  858. {
  859.    uint8_t *src = (uint8_t *)void_src;
  860.             uint8_t a = src[0];
  861.  
  862.      
  863.          dst[0] = 0.0f;
  864.      
  865.          dst[1] = 0.0f;
  866.      
  867.          dst[2] = 0.0f;
  868.      
  869.          
  870.                dst[3] = _mesa_unorm_to_float(a, 8);
  871. }
  872.  
  873. static inline void
  874. unpack_float_a_unorm16(const void *void_src, GLfloat dst[4])
  875. {
  876.    uint16_t *src = (uint16_t *)void_src;
  877.             uint16_t a = src[0];
  878.  
  879.      
  880.          dst[0] = 0.0f;
  881.      
  882.          dst[1] = 0.0f;
  883.      
  884.          dst[2] = 0.0f;
  885.      
  886.          
  887.                dst[3] = _mesa_unorm_to_float(a, 16);
  888. }
  889.  
  890. static inline void
  891. unpack_float_l_unorm8(const void *void_src, GLfloat dst[4])
  892. {
  893.    uint8_t *src = (uint8_t *)void_src;
  894.             uint8_t l = src[0];
  895.  
  896.      
  897.          
  898.                dst[0] = _mesa_unorm_to_float(l, 8);
  899.      
  900.          
  901.                dst[1] = _mesa_unorm_to_float(l, 8);
  902.      
  903.          
  904.                dst[2] = _mesa_unorm_to_float(l, 8);
  905.      
  906.          dst[3] = 1.0f;
  907. }
  908.  
  909. static inline void
  910. unpack_float_l_unorm16(const void *void_src, GLfloat dst[4])
  911. {
  912.    uint16_t *src = (uint16_t *)void_src;
  913.             uint16_t l = src[0];
  914.  
  915.      
  916.          
  917.                dst[0] = _mesa_unorm_to_float(l, 16);
  918.      
  919.          
  920.                dst[1] = _mesa_unorm_to_float(l, 16);
  921.      
  922.          
  923.                dst[2] = _mesa_unorm_to_float(l, 16);
  924.      
  925.          dst[3] = 1.0f;
  926. }
  927.  
  928. static inline void
  929. unpack_float_i_unorm8(const void *void_src, GLfloat dst[4])
  930. {
  931.    uint8_t *src = (uint8_t *)void_src;
  932.             uint8_t i = src[0];
  933.  
  934.      
  935.          
  936.                dst[0] = _mesa_unorm_to_float(i, 8);
  937.      
  938.          
  939.                dst[1] = _mesa_unorm_to_float(i, 8);
  940.      
  941.          
  942.                dst[2] = _mesa_unorm_to_float(i, 8);
  943.      
  944.          
  945.                dst[3] = _mesa_unorm_to_float(i, 8);
  946. }
  947.  
  948. static inline void
  949. unpack_float_i_unorm16(const void *void_src, GLfloat dst[4])
  950. {
  951.    uint16_t *src = (uint16_t *)void_src;
  952.             uint16_t i = src[0];
  953.  
  954.      
  955.          
  956.                dst[0] = _mesa_unorm_to_float(i, 16);
  957.      
  958.          
  959.                dst[1] = _mesa_unorm_to_float(i, 16);
  960.      
  961.          
  962.                dst[2] = _mesa_unorm_to_float(i, 16);
  963.      
  964.          
  965.                dst[3] = _mesa_unorm_to_float(i, 16);
  966. }
  967.  
  968. static inline void
  969. unpack_float_r_unorm8(const void *void_src, GLfloat dst[4])
  970. {
  971.    uint8_t *src = (uint8_t *)void_src;
  972.             uint8_t r = src[0];
  973.  
  974.      
  975.          
  976.                dst[0] = _mesa_unorm_to_float(r, 8);
  977.      
  978.          dst[1] = 0.0f;
  979.      
  980.          dst[2] = 0.0f;
  981.      
  982.          dst[3] = 1.0f;
  983. }
  984.  
  985. static inline void
  986. unpack_float_r_unorm16(const void *void_src, GLfloat dst[4])
  987. {
  988.    uint16_t *src = (uint16_t *)void_src;
  989.             uint16_t r = src[0];
  990.  
  991.      
  992.          
  993.                dst[0] = _mesa_unorm_to_float(r, 16);
  994.      
  995.          dst[1] = 0.0f;
  996.      
  997.          dst[2] = 0.0f;
  998.      
  999.          dst[3] = 1.0f;
  1000. }
  1001.  
  1002. static inline void
  1003. unpack_float_bgr_unorm8(const void *void_src, GLfloat dst[4])
  1004. {
  1005.    uint8_t *src = (uint8_t *)void_src;
  1006.             uint8_t b = src[0];
  1007.             uint8_t g = src[1];
  1008.             uint8_t r = src[2];
  1009.  
  1010.      
  1011.          
  1012.                dst[0] = _mesa_unorm_to_float(r, 8);
  1013.      
  1014.          
  1015.                dst[1] = _mesa_unorm_to_float(g, 8);
  1016.      
  1017.          
  1018.                dst[2] = _mesa_unorm_to_float(b, 8);
  1019.      
  1020.          dst[3] = 1.0f;
  1021. }
  1022.  
  1023. static inline void
  1024. unpack_float_rgb_unorm8(const void *void_src, GLfloat dst[4])
  1025. {
  1026.    uint8_t *src = (uint8_t *)void_src;
  1027.             uint8_t r = src[0];
  1028.             uint8_t g = src[1];
  1029.             uint8_t b = src[2];
  1030.  
  1031.      
  1032.          
  1033.                dst[0] = _mesa_unorm_to_float(r, 8);
  1034.      
  1035.          
  1036.                dst[1] = _mesa_unorm_to_float(g, 8);
  1037.      
  1038.          
  1039.                dst[2] = _mesa_unorm_to_float(b, 8);
  1040.      
  1041.          dst[3] = 1.0f;
  1042. }
  1043.  
  1044. static inline void
  1045. unpack_float_rgba_unorm16(const void *void_src, GLfloat dst[4])
  1046. {
  1047.    uint16_t *src = (uint16_t *)void_src;
  1048.             uint16_t r = src[0];
  1049.             uint16_t g = src[1];
  1050.             uint16_t b = src[2];
  1051.             uint16_t a = src[3];
  1052.  
  1053.      
  1054.          
  1055.                dst[0] = _mesa_unorm_to_float(r, 16);
  1056.      
  1057.          
  1058.                dst[1] = _mesa_unorm_to_float(g, 16);
  1059.      
  1060.          
  1061.                dst[2] = _mesa_unorm_to_float(b, 16);
  1062.      
  1063.          
  1064.                dst[3] = _mesa_unorm_to_float(a, 16);
  1065. }
  1066.  
  1067. static inline void
  1068. unpack_float_rgbx_unorm16(const void *void_src, GLfloat dst[4])
  1069. {
  1070.    uint16_t *src = (uint16_t *)void_src;
  1071.             uint16_t r = src[0];
  1072.             uint16_t g = src[1];
  1073.             uint16_t b = src[2];
  1074.  
  1075.      
  1076.          
  1077.                dst[0] = _mesa_unorm_to_float(r, 16);
  1078.      
  1079.          
  1080.                dst[1] = _mesa_unorm_to_float(g, 16);
  1081.      
  1082.          
  1083.                dst[2] = _mesa_unorm_to_float(b, 16);
  1084.      
  1085.          dst[3] = 1.0f;
  1086. }
  1087.  
  1088. static inline void
  1089. unpack_float_a8b8g8r8_snorm(const void *void_src, GLfloat dst[4])
  1090. {
  1091.    uint32_t *src = (uint32_t *)void_src;
  1092.             int8_t a = UNPACK(*src, 0, 8);
  1093.             int8_t b = UNPACK(*src, 8, 8);
  1094.             int8_t g = UNPACK(*src, 16, 8);
  1095.             int8_t r = UNPACK(*src, 24, 8);
  1096.  
  1097.      
  1098.          
  1099.             dst[0] = _mesa_snorm_to_float(r, 8);
  1100.      
  1101.          
  1102.             dst[1] = _mesa_snorm_to_float(g, 8);
  1103.      
  1104.          
  1105.             dst[2] = _mesa_snorm_to_float(b, 8);
  1106.      
  1107.          
  1108.             dst[3] = _mesa_snorm_to_float(a, 8);
  1109. }
  1110.  
  1111. static inline void
  1112. unpack_float_x8b8g8r8_snorm(const void *void_src, GLfloat dst[4])
  1113. {
  1114.    uint32_t *src = (uint32_t *)void_src;
  1115.             int8_t b = UNPACK(*src, 8, 8);
  1116.             int8_t g = UNPACK(*src, 16, 8);
  1117.             int8_t r = UNPACK(*src, 24, 8);
  1118.  
  1119.      
  1120.          
  1121.             dst[0] = _mesa_snorm_to_float(r, 8);
  1122.      
  1123.          
  1124.             dst[1] = _mesa_snorm_to_float(g, 8);
  1125.      
  1126.          
  1127.             dst[2] = _mesa_snorm_to_float(b, 8);
  1128.      
  1129.          dst[3] = 1.0f;
  1130. }
  1131.  
  1132. static inline void
  1133. unpack_float_r8g8b8a8_snorm(const void *void_src, GLfloat dst[4])
  1134. {
  1135.    uint32_t *src = (uint32_t *)void_src;
  1136.             int8_t r = UNPACK(*src, 0, 8);
  1137.             int8_t g = UNPACK(*src, 8, 8);
  1138.             int8_t b = UNPACK(*src, 16, 8);
  1139.             int8_t a = UNPACK(*src, 24, 8);
  1140.  
  1141.      
  1142.          
  1143.             dst[0] = _mesa_snorm_to_float(r, 8);
  1144.      
  1145.          
  1146.             dst[1] = _mesa_snorm_to_float(g, 8);
  1147.      
  1148.          
  1149.             dst[2] = _mesa_snorm_to_float(b, 8);
  1150.      
  1151.          
  1152.             dst[3] = _mesa_snorm_to_float(a, 8);
  1153. }
  1154.  
  1155. static inline void
  1156. unpack_float_r8g8b8x8_snorm(const void *void_src, GLfloat dst[4])
  1157. {
  1158.    uint32_t *src = (uint32_t *)void_src;
  1159.             int8_t r = UNPACK(*src, 0, 8);
  1160.             int8_t g = UNPACK(*src, 8, 8);
  1161.             int8_t b = UNPACK(*src, 16, 8);
  1162.  
  1163.      
  1164.          
  1165.             dst[0] = _mesa_snorm_to_float(r, 8);
  1166.      
  1167.          
  1168.             dst[1] = _mesa_snorm_to_float(g, 8);
  1169.      
  1170.          
  1171.             dst[2] = _mesa_snorm_to_float(b, 8);
  1172.      
  1173.          dst[3] = 1.0f;
  1174. }
  1175.  
  1176. static inline void
  1177. unpack_float_r16g16_snorm(const void *void_src, GLfloat dst[4])
  1178. {
  1179.    uint32_t *src = (uint32_t *)void_src;
  1180.             int16_t r = UNPACK(*src, 0, 16);
  1181.             int16_t g = UNPACK(*src, 16, 16);
  1182.  
  1183.      
  1184.          
  1185.             dst[0] = _mesa_snorm_to_float(r, 16);
  1186.      
  1187.          
  1188.             dst[1] = _mesa_snorm_to_float(g, 16);
  1189.      
  1190.          dst[2] = 0.0f;
  1191.      
  1192.          dst[3] = 1.0f;
  1193. }
  1194.  
  1195. static inline void
  1196. unpack_float_g16r16_snorm(const void *void_src, GLfloat dst[4])
  1197. {
  1198.    uint32_t *src = (uint32_t *)void_src;
  1199.             int16_t g = UNPACK(*src, 0, 16);
  1200.             int16_t r = UNPACK(*src, 16, 16);
  1201.  
  1202.      
  1203.          
  1204.             dst[0] = _mesa_snorm_to_float(r, 16);
  1205.      
  1206.          
  1207.             dst[1] = _mesa_snorm_to_float(g, 16);
  1208.      
  1209.          dst[2] = 0.0f;
  1210.      
  1211.          dst[3] = 1.0f;
  1212. }
  1213.  
  1214. static inline void
  1215. unpack_float_r8g8_snorm(const void *void_src, GLfloat dst[4])
  1216. {
  1217.    uint16_t *src = (uint16_t *)void_src;
  1218.             int8_t r = UNPACK(*src, 0, 8);
  1219.             int8_t g = UNPACK(*src, 8, 8);
  1220.  
  1221.      
  1222.          
  1223.             dst[0] = _mesa_snorm_to_float(r, 8);
  1224.      
  1225.          
  1226.             dst[1] = _mesa_snorm_to_float(g, 8);
  1227.      
  1228.          dst[2] = 0.0f;
  1229.      
  1230.          dst[3] = 1.0f;
  1231. }
  1232.  
  1233. static inline void
  1234. unpack_float_g8r8_snorm(const void *void_src, GLfloat dst[4])
  1235. {
  1236.    uint16_t *src = (uint16_t *)void_src;
  1237.             int8_t g = UNPACK(*src, 0, 8);
  1238.             int8_t r = UNPACK(*src, 8, 8);
  1239.  
  1240.      
  1241.          
  1242.             dst[0] = _mesa_snorm_to_float(r, 8);
  1243.      
  1244.          
  1245.             dst[1] = _mesa_snorm_to_float(g, 8);
  1246.      
  1247.          dst[2] = 0.0f;
  1248.      
  1249.          dst[3] = 1.0f;
  1250. }
  1251.  
  1252. static inline void
  1253. unpack_float_l8a8_snorm(const void *void_src, GLfloat dst[4])
  1254. {
  1255.    uint16_t *src = (uint16_t *)void_src;
  1256.             int8_t l = UNPACK(*src, 0, 8);
  1257.             int8_t a = UNPACK(*src, 8, 8);
  1258.  
  1259.      
  1260.          
  1261.             dst[0] = _mesa_snorm_to_float(l, 8);
  1262.      
  1263.          
  1264.             dst[1] = _mesa_snorm_to_float(l, 8);
  1265.      
  1266.          
  1267.             dst[2] = _mesa_snorm_to_float(l, 8);
  1268.      
  1269.          
  1270.             dst[3] = _mesa_snorm_to_float(a, 8);
  1271. }
  1272.  
  1273. static inline void
  1274. unpack_float_a8l8_snorm(const void *void_src, GLfloat dst[4])
  1275. {
  1276.    uint16_t *src = (uint16_t *)void_src;
  1277.             int8_t a = UNPACK(*src, 0, 8);
  1278.             int8_t l = UNPACK(*src, 8, 8);
  1279.  
  1280.      
  1281.          
  1282.             dst[0] = _mesa_snorm_to_float(l, 8);
  1283.      
  1284.          
  1285.             dst[1] = _mesa_snorm_to_float(l, 8);
  1286.      
  1287.          
  1288.             dst[2] = _mesa_snorm_to_float(l, 8);
  1289.      
  1290.          
  1291.             dst[3] = _mesa_snorm_to_float(a, 8);
  1292. }
  1293.  
  1294. static inline void
  1295. unpack_float_a_snorm8(const void *void_src, GLfloat dst[4])
  1296. {
  1297.    int8_t *src = (int8_t *)void_src;
  1298.             int8_t a = src[0];
  1299.  
  1300.      
  1301.          dst[0] = 0.0f;
  1302.      
  1303.          dst[1] = 0.0f;
  1304.      
  1305.          dst[2] = 0.0f;
  1306.      
  1307.          
  1308.             dst[3] = _mesa_snorm_to_float(a, 8);
  1309. }
  1310.  
  1311. static inline void
  1312. unpack_float_a_snorm16(const void *void_src, GLfloat dst[4])
  1313. {
  1314.    int16_t *src = (int16_t *)void_src;
  1315.             int16_t a = src[0];
  1316.  
  1317.      
  1318.          dst[0] = 0.0f;
  1319.      
  1320.          dst[1] = 0.0f;
  1321.      
  1322.          dst[2] = 0.0f;
  1323.      
  1324.          
  1325.             dst[3] = _mesa_snorm_to_float(a, 16);
  1326. }
  1327.  
  1328. static inline void
  1329. unpack_float_l_snorm8(const void *void_src, GLfloat dst[4])
  1330. {
  1331.    int8_t *src = (int8_t *)void_src;
  1332.             int8_t l = src[0];
  1333.  
  1334.      
  1335.          
  1336.             dst[0] = _mesa_snorm_to_float(l, 8);
  1337.      
  1338.          
  1339.             dst[1] = _mesa_snorm_to_float(l, 8);
  1340.      
  1341.          
  1342.             dst[2] = _mesa_snorm_to_float(l, 8);
  1343.      
  1344.          dst[3] = 1.0f;
  1345. }
  1346.  
  1347. static inline void
  1348. unpack_float_l_snorm16(const void *void_src, GLfloat dst[4])
  1349. {
  1350.    int16_t *src = (int16_t *)void_src;
  1351.             int16_t l = src[0];
  1352.  
  1353.      
  1354.          
  1355.             dst[0] = _mesa_snorm_to_float(l, 16);
  1356.      
  1357.          
  1358.             dst[1] = _mesa_snorm_to_float(l, 16);
  1359.      
  1360.          
  1361.             dst[2] = _mesa_snorm_to_float(l, 16);
  1362.      
  1363.          dst[3] = 1.0f;
  1364. }
  1365.  
  1366. static inline void
  1367. unpack_float_i_snorm8(const void *void_src, GLfloat dst[4])
  1368. {
  1369.    int8_t *src = (int8_t *)void_src;
  1370.             int8_t i = src[0];
  1371.  
  1372.      
  1373.          
  1374.             dst[0] = _mesa_snorm_to_float(i, 8);
  1375.      
  1376.          
  1377.             dst[1] = _mesa_snorm_to_float(i, 8);
  1378.      
  1379.          
  1380.             dst[2] = _mesa_snorm_to_float(i, 8);
  1381.      
  1382.          
  1383.             dst[3] = _mesa_snorm_to_float(i, 8);
  1384. }
  1385.  
  1386. static inline void
  1387. unpack_float_i_snorm16(const void *void_src, GLfloat dst[4])
  1388. {
  1389.    int16_t *src = (int16_t *)void_src;
  1390.             int16_t i = src[0];
  1391.  
  1392.      
  1393.          
  1394.             dst[0] = _mesa_snorm_to_float(i, 16);
  1395.      
  1396.          
  1397.             dst[1] = _mesa_snorm_to_float(i, 16);
  1398.      
  1399.          
  1400.             dst[2] = _mesa_snorm_to_float(i, 16);
  1401.      
  1402.          
  1403.             dst[3] = _mesa_snorm_to_float(i, 16);
  1404. }
  1405.  
  1406. static inline void
  1407. unpack_float_r_snorm8(const void *void_src, GLfloat dst[4])
  1408. {
  1409.    int8_t *src = (int8_t *)void_src;
  1410.             int8_t r = src[0];
  1411.  
  1412.      
  1413.          
  1414.             dst[0] = _mesa_snorm_to_float(r, 8);
  1415.      
  1416.          dst[1] = 0.0f;
  1417.      
  1418.          dst[2] = 0.0f;
  1419.      
  1420.          dst[3] = 1.0f;
  1421. }
  1422.  
  1423. static inline void
  1424. unpack_float_r_snorm16(const void *void_src, GLfloat dst[4])
  1425. {
  1426.    int16_t *src = (int16_t *)void_src;
  1427.             int16_t r = src[0];
  1428.  
  1429.      
  1430.          
  1431.             dst[0] = _mesa_snorm_to_float(r, 16);
  1432.      
  1433.          dst[1] = 0.0f;
  1434.      
  1435.          dst[2] = 0.0f;
  1436.      
  1437.          dst[3] = 1.0f;
  1438. }
  1439.  
  1440. static inline void
  1441. unpack_float_la_snorm16(const void *void_src, GLfloat dst[4])
  1442. {
  1443.    int16_t *src = (int16_t *)void_src;
  1444.             int16_t l = src[0];
  1445.             int16_t a = src[1];
  1446.  
  1447.      
  1448.          
  1449.             dst[0] = _mesa_snorm_to_float(l, 16);
  1450.      
  1451.          
  1452.             dst[1] = _mesa_snorm_to_float(l, 16);
  1453.      
  1454.          
  1455.             dst[2] = _mesa_snorm_to_float(l, 16);
  1456.      
  1457.          
  1458.             dst[3] = _mesa_snorm_to_float(a, 16);
  1459. }
  1460.  
  1461. static inline void
  1462. unpack_float_rgb_snorm16(const void *void_src, GLfloat dst[4])
  1463. {
  1464.    int16_t *src = (int16_t *)void_src;
  1465.             int16_t r = src[0];
  1466.             int16_t g = src[1];
  1467.             int16_t b = src[2];
  1468.  
  1469.      
  1470.          
  1471.             dst[0] = _mesa_snorm_to_float(r, 16);
  1472.      
  1473.          
  1474.             dst[1] = _mesa_snorm_to_float(g, 16);
  1475.      
  1476.          
  1477.             dst[2] = _mesa_snorm_to_float(b, 16);
  1478.      
  1479.          dst[3] = 1.0f;
  1480. }
  1481.  
  1482. static inline void
  1483. unpack_float_rgba_snorm16(const void *void_src, GLfloat dst[4])
  1484. {
  1485.    int16_t *src = (int16_t *)void_src;
  1486.             int16_t r = src[0];
  1487.             int16_t g = src[1];
  1488.             int16_t b = src[2];
  1489.             int16_t a = src[3];
  1490.  
  1491.      
  1492.          
  1493.             dst[0] = _mesa_snorm_to_float(r, 16);
  1494.      
  1495.          
  1496.             dst[1] = _mesa_snorm_to_float(g, 16);
  1497.      
  1498.          
  1499.             dst[2] = _mesa_snorm_to_float(b, 16);
  1500.      
  1501.          
  1502.             dst[3] = _mesa_snorm_to_float(a, 16);
  1503. }
  1504.  
  1505. static inline void
  1506. unpack_float_rgbx_snorm16(const void *void_src, GLfloat dst[4])
  1507. {
  1508.    int16_t *src = (int16_t *)void_src;
  1509.             int16_t r = src[0];
  1510.             int16_t g = src[1];
  1511.             int16_t b = src[2];
  1512.  
  1513.      
  1514.          
  1515.             dst[0] = _mesa_snorm_to_float(r, 16);
  1516.      
  1517.          
  1518.             dst[1] = _mesa_snorm_to_float(g, 16);
  1519.      
  1520.          
  1521.             dst[2] = _mesa_snorm_to_float(b, 16);
  1522.      
  1523.          dst[3] = 1.0f;
  1524. }
  1525.  
  1526. static inline void
  1527. unpack_float_a8b8g8r8_srgb(const void *void_src, GLfloat dst[4])
  1528. {
  1529.    uint32_t *src = (uint32_t *)void_src;
  1530.             uint8_t a = UNPACK(*src, 0, 8);
  1531.             uint8_t b = UNPACK(*src, 8, 8);
  1532.             uint8_t g = UNPACK(*src, 16, 8);
  1533.             uint8_t r = UNPACK(*src, 24, 8);
  1534.  
  1535.      
  1536.          
  1537.                
  1538.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1539.      
  1540.          
  1541.                
  1542.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1543.      
  1544.          
  1545.                
  1546.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1547.      
  1548.          
  1549.                dst[3] = _mesa_unorm_to_float(a, 8);
  1550. }
  1551.  
  1552. static inline void
  1553. unpack_float_b8g8r8a8_srgb(const void *void_src, GLfloat dst[4])
  1554. {
  1555.    uint32_t *src = (uint32_t *)void_src;
  1556.             uint8_t b = UNPACK(*src, 0, 8);
  1557.             uint8_t g = UNPACK(*src, 8, 8);
  1558.             uint8_t r = UNPACK(*src, 16, 8);
  1559.             uint8_t a = UNPACK(*src, 24, 8);
  1560.  
  1561.      
  1562.          
  1563.                
  1564.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1565.      
  1566.          
  1567.                
  1568.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1569.      
  1570.          
  1571.                
  1572.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1573.      
  1574.          
  1575.                dst[3] = _mesa_unorm_to_float(a, 8);
  1576. }
  1577.  
  1578. static inline void
  1579. unpack_float_a8r8g8b8_srgb(const void *void_src, GLfloat dst[4])
  1580. {
  1581.    uint32_t *src = (uint32_t *)void_src;
  1582.             uint8_t a = UNPACK(*src, 0, 8);
  1583.             uint8_t r = UNPACK(*src, 8, 8);
  1584.             uint8_t g = UNPACK(*src, 16, 8);
  1585.             uint8_t b = UNPACK(*src, 24, 8);
  1586.  
  1587.      
  1588.          
  1589.                
  1590.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1591.      
  1592.          
  1593.                
  1594.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1595.      
  1596.          
  1597.                
  1598.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1599.      
  1600.          
  1601.                dst[3] = _mesa_unorm_to_float(a, 8);
  1602. }
  1603.  
  1604. static inline void
  1605. unpack_float_b8g8r8x8_srgb(const void *void_src, GLfloat dst[4])
  1606. {
  1607.    uint32_t *src = (uint32_t *)void_src;
  1608.             uint8_t b = UNPACK(*src, 0, 8);
  1609.             uint8_t g = UNPACK(*src, 8, 8);
  1610.             uint8_t r = UNPACK(*src, 16, 8);
  1611.  
  1612.      
  1613.          
  1614.                
  1615.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1616.      
  1617.          
  1618.                
  1619.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1620.      
  1621.          
  1622.                
  1623.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1624.      
  1625.          dst[3] = 1.0f;
  1626. }
  1627.  
  1628. static inline void
  1629. unpack_float_x8r8g8b8_srgb(const void *void_src, GLfloat dst[4])
  1630. {
  1631.    uint32_t *src = (uint32_t *)void_src;
  1632.             uint8_t r = UNPACK(*src, 8, 8);
  1633.             uint8_t g = UNPACK(*src, 16, 8);
  1634.             uint8_t b = UNPACK(*src, 24, 8);
  1635.  
  1636.      
  1637.          
  1638.                
  1639.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1640.      
  1641.          
  1642.                
  1643.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1644.      
  1645.          
  1646.                
  1647.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1648.      
  1649.          dst[3] = 1.0f;
  1650. }
  1651.  
  1652. static inline void
  1653. unpack_float_r8g8b8a8_srgb(const void *void_src, GLfloat dst[4])
  1654. {
  1655.    uint32_t *src = (uint32_t *)void_src;
  1656.             uint8_t r = UNPACK(*src, 0, 8);
  1657.             uint8_t g = UNPACK(*src, 8, 8);
  1658.             uint8_t b = UNPACK(*src, 16, 8);
  1659.             uint8_t a = UNPACK(*src, 24, 8);
  1660.  
  1661.      
  1662.          
  1663.                
  1664.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1665.      
  1666.          
  1667.                
  1668.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1669.      
  1670.          
  1671.                
  1672.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1673.      
  1674.          
  1675.                dst[3] = _mesa_unorm_to_float(a, 8);
  1676. }
  1677.  
  1678. static inline void
  1679. unpack_float_r8g8b8x8_srgb(const void *void_src, GLfloat dst[4])
  1680. {
  1681.    uint32_t *src = (uint32_t *)void_src;
  1682.             uint8_t r = UNPACK(*src, 0, 8);
  1683.             uint8_t g = UNPACK(*src, 8, 8);
  1684.             uint8_t b = UNPACK(*src, 16, 8);
  1685.  
  1686.      
  1687.          
  1688.                
  1689.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1690.      
  1691.          
  1692.                
  1693.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1694.      
  1695.          
  1696.                
  1697.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1698.      
  1699.          dst[3] = 1.0f;
  1700. }
  1701.  
  1702. static inline void
  1703. unpack_float_x8b8g8r8_srgb(const void *void_src, GLfloat dst[4])
  1704. {
  1705.    uint32_t *src = (uint32_t *)void_src;
  1706.             uint8_t b = UNPACK(*src, 8, 8);
  1707.             uint8_t g = UNPACK(*src, 16, 8);
  1708.             uint8_t r = UNPACK(*src, 24, 8);
  1709.  
  1710.      
  1711.          
  1712.                
  1713.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1714.      
  1715.          
  1716.                
  1717.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1718.      
  1719.          
  1720.                
  1721.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1722.      
  1723.          dst[3] = 1.0f;
  1724. }
  1725.  
  1726. static inline void
  1727. unpack_float_l8a8_srgb(const void *void_src, GLfloat dst[4])
  1728. {
  1729.    uint16_t *src = (uint16_t *)void_src;
  1730.             uint8_t l = UNPACK(*src, 0, 8);
  1731.             uint8_t a = UNPACK(*src, 8, 8);
  1732.  
  1733.      
  1734.          
  1735.                dst[0] = _mesa_unorm_to_float(l, 8);
  1736.      
  1737.          
  1738.                dst[1] = _mesa_unorm_to_float(l, 8);
  1739.      
  1740.          
  1741.                dst[2] = _mesa_unorm_to_float(l, 8);
  1742.      
  1743.          
  1744.                dst[3] = _mesa_unorm_to_float(a, 8);
  1745. }
  1746.  
  1747. static inline void
  1748. unpack_float_a8l8_srgb(const void *void_src, GLfloat dst[4])
  1749. {
  1750.    uint16_t *src = (uint16_t *)void_src;
  1751.             uint8_t a = UNPACK(*src, 0, 8);
  1752.             uint8_t l = UNPACK(*src, 8, 8);
  1753.  
  1754.      
  1755.          
  1756.                dst[0] = _mesa_unorm_to_float(l, 8);
  1757.      
  1758.          
  1759.                dst[1] = _mesa_unorm_to_float(l, 8);
  1760.      
  1761.          
  1762.                dst[2] = _mesa_unorm_to_float(l, 8);
  1763.      
  1764.          
  1765.                dst[3] = _mesa_unorm_to_float(a, 8);
  1766. }
  1767.  
  1768. static inline void
  1769. unpack_float_l_srgb8(const void *void_src, GLfloat dst[4])
  1770. {
  1771.    uint8_t *src = (uint8_t *)void_src;
  1772.             uint8_t l = src[0];
  1773.  
  1774.      
  1775.          
  1776.                dst[0] = _mesa_unorm_to_float(l, 8);
  1777.      
  1778.          
  1779.                dst[1] = _mesa_unorm_to_float(l, 8);
  1780.      
  1781.          
  1782.                dst[2] = _mesa_unorm_to_float(l, 8);
  1783.      
  1784.          dst[3] = 1.0f;
  1785. }
  1786.  
  1787. static inline void
  1788. unpack_float_bgr_srgb8(const void *void_src, GLfloat dst[4])
  1789. {
  1790.    uint8_t *src = (uint8_t *)void_src;
  1791.             uint8_t b = src[0];
  1792.             uint8_t g = src[1];
  1793.             uint8_t r = src[2];
  1794.  
  1795.      
  1796.          
  1797.                
  1798.                dst[0] = util_format_srgb_8unorm_to_linear_float(r);
  1799.      
  1800.          
  1801.                
  1802.                dst[1] = util_format_srgb_8unorm_to_linear_float(g);
  1803.      
  1804.          
  1805.                
  1806.                dst[2] = util_format_srgb_8unorm_to_linear_float(b);
  1807.      
  1808.          dst[3] = 1.0f;
  1809. }
  1810.            
  1811. static inline void
  1812. unpack_float_a_float16(const void *void_src, GLfloat dst[4])
  1813. {
  1814.    uint16_t *src = (uint16_t *)void_src;
  1815.             uint16_t a = src[0];
  1816.  
  1817.      
  1818.          dst[0] = 0.0f;
  1819.      
  1820.          dst[1] = 0.0f;
  1821.      
  1822.          dst[2] = 0.0f;
  1823.      
  1824.          
  1825.                dst[3] = _mesa_half_to_float(a);
  1826. }
  1827.  
  1828. static inline void
  1829. unpack_float_a_float32(const void *void_src, GLfloat dst[4])
  1830. {
  1831.    float *src = (float *)void_src;
  1832.             float a = src[0];
  1833.  
  1834.      
  1835.          dst[0] = 0.0f;
  1836.      
  1837.          dst[1] = 0.0f;
  1838.      
  1839.          dst[2] = 0.0f;
  1840.      
  1841.          
  1842.                dst[3] = a;
  1843. }
  1844.  
  1845. static inline void
  1846. unpack_float_l_float16(const void *void_src, GLfloat dst[4])
  1847. {
  1848.    uint16_t *src = (uint16_t *)void_src;
  1849.             uint16_t l = src[0];
  1850.  
  1851.      
  1852.          
  1853.                dst[0] = _mesa_half_to_float(l);
  1854.      
  1855.          
  1856.                dst[1] = _mesa_half_to_float(l);
  1857.      
  1858.          
  1859.                dst[2] = _mesa_half_to_float(l);
  1860.      
  1861.          dst[3] = 1.0f;
  1862. }
  1863.  
  1864. static inline void
  1865. unpack_float_l_float32(const void *void_src, GLfloat dst[4])
  1866. {
  1867.    float *src = (float *)void_src;
  1868.             float l = src[0];
  1869.  
  1870.      
  1871.          
  1872.                dst[0] = l;
  1873.      
  1874.          
  1875.                dst[1] = l;
  1876.      
  1877.          
  1878.                dst[2] = l;
  1879.      
  1880.          dst[3] = 1.0f;
  1881. }
  1882.  
  1883. static inline void
  1884. unpack_float_la_float16(const void *void_src, GLfloat dst[4])
  1885. {
  1886.    uint16_t *src = (uint16_t *)void_src;
  1887.             uint16_t l = src[0];
  1888.             uint16_t a = src[1];
  1889.  
  1890.      
  1891.          
  1892.                dst[0] = _mesa_half_to_float(l);
  1893.      
  1894.          
  1895.                dst[1] = _mesa_half_to_float(l);
  1896.      
  1897.          
  1898.                dst[2] = _mesa_half_to_float(l);
  1899.      
  1900.          
  1901.                dst[3] = _mesa_half_to_float(a);
  1902. }
  1903.  
  1904. static inline void
  1905. unpack_float_la_float32(const void *void_src, GLfloat dst[4])
  1906. {
  1907.    float *src = (float *)void_src;
  1908.             float l = src[0];
  1909.             float a = src[1];
  1910.  
  1911.      
  1912.          
  1913.                dst[0] = l;
  1914.      
  1915.          
  1916.                dst[1] = l;
  1917.      
  1918.          
  1919.                dst[2] = l;
  1920.      
  1921.          
  1922.                dst[3] = a;
  1923. }
  1924.  
  1925. static inline void
  1926. unpack_float_i_float16(const void *void_src, GLfloat dst[4])
  1927. {
  1928.    uint16_t *src = (uint16_t *)void_src;
  1929.             uint16_t i = src[0];
  1930.  
  1931.      
  1932.          
  1933.                dst[0] = _mesa_half_to_float(i);
  1934.      
  1935.          
  1936.                dst[1] = _mesa_half_to_float(i);
  1937.      
  1938.          
  1939.                dst[2] = _mesa_half_to_float(i);
  1940.      
  1941.          
  1942.                dst[3] = _mesa_half_to_float(i);
  1943. }
  1944.  
  1945. static inline void
  1946. unpack_float_i_float32(const void *void_src, GLfloat dst[4])
  1947. {
  1948.    float *src = (float *)void_src;
  1949.             float i = src[0];
  1950.  
  1951.      
  1952.          
  1953.                dst[0] = i;
  1954.      
  1955.          
  1956.                dst[1] = i;
  1957.      
  1958.          
  1959.                dst[2] = i;
  1960.      
  1961.          
  1962.                dst[3] = i;
  1963. }
  1964.  
  1965. static inline void
  1966. unpack_float_r_float16(const void *void_src, GLfloat dst[4])
  1967. {
  1968.    uint16_t *src = (uint16_t *)void_src;
  1969.             uint16_t r = src[0];
  1970.  
  1971.      
  1972.          
  1973.                dst[0] = _mesa_half_to_float(r);
  1974.      
  1975.          dst[1] = 0.0f;
  1976.      
  1977.          dst[2] = 0.0f;
  1978.      
  1979.          dst[3] = 1.0f;
  1980. }
  1981.  
  1982. static inline void
  1983. unpack_float_r_float32(const void *void_src, GLfloat dst[4])
  1984. {
  1985.    float *src = (float *)void_src;
  1986.             float r = src[0];
  1987.  
  1988.      
  1989.          
  1990.                dst[0] = r;
  1991.      
  1992.          dst[1] = 0.0f;
  1993.      
  1994.          dst[2] = 0.0f;
  1995.      
  1996.          dst[3] = 1.0f;
  1997. }
  1998.  
  1999. static inline void
  2000. unpack_float_rg_float16(const void *void_src, GLfloat dst[4])
  2001. {
  2002.    uint16_t *src = (uint16_t *)void_src;
  2003.             uint16_t r = src[0];
  2004.             uint16_t g = src[1];
  2005.  
  2006.      
  2007.          
  2008.                dst[0] = _mesa_half_to_float(r);
  2009.      
  2010.          
  2011.                dst[1] = _mesa_half_to_float(g);
  2012.      
  2013.          dst[2] = 0.0f;
  2014.      
  2015.          dst[3] = 1.0f;
  2016. }
  2017.  
  2018. static inline void
  2019. unpack_float_rg_float32(const void *void_src, GLfloat dst[4])
  2020. {
  2021.    float *src = (float *)void_src;
  2022.             float r = src[0];
  2023.             float g = src[1];
  2024.  
  2025.      
  2026.          
  2027.                dst[0] = r;
  2028.      
  2029.          
  2030.                dst[1] = g;
  2031.      
  2032.          dst[2] = 0.0f;
  2033.      
  2034.          dst[3] = 1.0f;
  2035. }
  2036.  
  2037. static inline void
  2038. unpack_float_rgb_float16(const void *void_src, GLfloat dst[4])
  2039. {
  2040.    uint16_t *src = (uint16_t *)void_src;
  2041.             uint16_t r = src[0];
  2042.             uint16_t g = src[1];
  2043.             uint16_t b = src[2];
  2044.  
  2045.      
  2046.          
  2047.                dst[0] = _mesa_half_to_float(r);
  2048.      
  2049.          
  2050.                dst[1] = _mesa_half_to_float(g);
  2051.      
  2052.          
  2053.                dst[2] = _mesa_half_to_float(b);
  2054.      
  2055.          dst[3] = 1.0f;
  2056. }
  2057.  
  2058. static inline void
  2059. unpack_float_rgb_float32(const void *void_src, GLfloat dst[4])
  2060. {
  2061.    float *src = (float *)void_src;
  2062.             float r = src[0];
  2063.             float g = src[1];
  2064.             float b = src[2];
  2065.  
  2066.      
  2067.          
  2068.                dst[0] = r;
  2069.      
  2070.          
  2071.                dst[1] = g;
  2072.      
  2073.          
  2074.                dst[2] = b;
  2075.      
  2076.          dst[3] = 1.0f;
  2077. }
  2078.  
  2079. static inline void
  2080. unpack_float_rgba_float16(const void *void_src, GLfloat dst[4])
  2081. {
  2082.    uint16_t *src = (uint16_t *)void_src;
  2083.             uint16_t r = src[0];
  2084.             uint16_t g = src[1];
  2085.             uint16_t b = src[2];
  2086.             uint16_t a = src[3];
  2087.  
  2088.      
  2089.          
  2090.                dst[0] = _mesa_half_to_float(r);
  2091.      
  2092.          
  2093.                dst[1] = _mesa_half_to_float(g);
  2094.      
  2095.          
  2096.                dst[2] = _mesa_half_to_float(b);
  2097.      
  2098.          
  2099.                dst[3] = _mesa_half_to_float(a);
  2100. }
  2101.  
  2102. static inline void
  2103. unpack_float_rgba_float32(const void *void_src, GLfloat dst[4])
  2104. {
  2105.    float *src = (float *)void_src;
  2106.             float r = src[0];
  2107.             float g = src[1];
  2108.             float b = src[2];
  2109.             float a = src[3];
  2110.  
  2111.      
  2112.          
  2113.                dst[0] = r;
  2114.      
  2115.          
  2116.                dst[1] = g;
  2117.      
  2118.          
  2119.                dst[2] = b;
  2120.      
  2121.          
  2122.                dst[3] = a;
  2123. }
  2124.  
  2125. static inline void
  2126. unpack_float_rgbx_float16(const void *void_src, GLfloat dst[4])
  2127. {
  2128.    uint16_t *src = (uint16_t *)void_src;
  2129.             uint16_t r = src[0];
  2130.             uint16_t g = src[1];
  2131.             uint16_t b = src[2];
  2132.  
  2133.      
  2134.          
  2135.                dst[0] = _mesa_half_to_float(r);
  2136.      
  2137.          
  2138.                dst[1] = _mesa_half_to_float(g);
  2139.      
  2140.          
  2141.                dst[2] = _mesa_half_to_float(b);
  2142.      
  2143.          dst[3] = 1.0f;
  2144. }
  2145.  
  2146. static inline void
  2147. unpack_float_rgbx_float32(const void *void_src, GLfloat dst[4])
  2148. {
  2149.    float *src = (float *)void_src;
  2150.             float r = src[0];
  2151.             float g = src[1];
  2152.             float b = src[2];
  2153.  
  2154.      
  2155.          
  2156.                dst[0] = r;
  2157.      
  2158.          
  2159.                dst[1] = g;
  2160.      
  2161.          
  2162.                dst[2] = b;
  2163.      
  2164.          dst[3] = 1.0f;
  2165. }
  2166.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  2167. static void
  2168. unpack_float_r9g9b9e5_float(const void *src, GLfloat dst[4])
  2169. {
  2170.    rgb9e5_to_float3(*(const GLuint *)src, dst);
  2171.    dst[3] = 1.0f;
  2172. }
  2173.  
  2174. static void
  2175. unpack_float_r11g11b10_float(const void *src, GLfloat dst[4])
  2176. {
  2177.    r11g11b10f_to_float3(*(const GLuint *)src, dst);
  2178.    dst[3] = 1.0f;
  2179. }
  2180.  
  2181. static void
  2182. unpack_float_ycbcr(const void *src, GLfloat dst[][4], GLuint n)
  2183. {
  2184.    GLuint i;
  2185.    for (i = 0; i < n; i++) {
  2186.       const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
  2187.       const GLushort *src1 = src0 + 1;         /* odd */
  2188.       const GLubyte y0 = (*src0 >> 8) & 0xff;  /* luminance */
  2189.       const GLubyte cb = *src0 & 0xff;         /* chroma U */
  2190.       const GLubyte y1 = (*src1 >> 8) & 0xff;  /* luminance */
  2191.       const GLubyte cr = *src1 & 0xff;         /* chroma V */
  2192.       const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
  2193.       GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
  2194.       GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
  2195.       GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
  2196.       r *= (1.0F / 255.0F);
  2197.       g *= (1.0F / 255.0F);
  2198.       b *= (1.0F / 255.0F);
  2199.       dst[i][0] = CLAMP(r, 0.0F, 1.0F);
  2200.       dst[i][1] = CLAMP(g, 0.0F, 1.0F);
  2201.       dst[i][2] = CLAMP(b, 0.0F, 1.0F);
  2202.       dst[i][3] = 1.0F;
  2203.    }
  2204. }
  2205.  
  2206. static void
  2207. unpack_float_ycbcr_rev(const void *src, GLfloat dst[][4], GLuint n)
  2208. {
  2209.    GLuint i;
  2210.    for (i = 0; i < n; i++) {
  2211.       const GLushort *src0 = ((const GLushort *) src) + i * 2; /* even */
  2212.       const GLushort *src1 = src0 + 1;         /* odd */
  2213.       const GLubyte y0 = *src0 & 0xff;         /* luminance */
  2214.       const GLubyte cr = (*src0 >> 8) & 0xff;  /* chroma V */
  2215.       const GLubyte y1 = *src1 & 0xff;         /* luminance */
  2216.       const GLubyte cb = (*src1 >> 8) & 0xff;  /* chroma U */
  2217.       const GLubyte y = (i & 1) ? y1 : y0;     /* choose even/odd luminance */
  2218.       GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
  2219.       GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
  2220.       GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
  2221.       r *= (1.0F / 255.0F);
  2222.       g *= (1.0F / 255.0F);
  2223.       b *= (1.0F / 255.0F);
  2224.       dst[i][0] = CLAMP(r, 0.0F, 1.0F);
  2225.       dst[i][1] = CLAMP(g, 0.0F, 1.0F);
  2226.       dst[i][2] = CLAMP(b, 0.0F, 1.0F);
  2227.       dst[i][3] = 1.0F;
  2228.    }
  2229. }
  2230.  
  2231. /* ubyte packing functions */
  2232.  
  2233.  
  2234. static inline void
  2235. unpack_ubyte_a8b8g8r8_unorm(const void *void_src, GLubyte dst[4])
  2236. {
  2237.    uint32_t *src = (uint32_t *)void_src;
  2238.             uint8_t a = UNPACK(*src, 0, 8);
  2239.             uint8_t b = UNPACK(*src, 8, 8);
  2240.             uint8_t g = UNPACK(*src, 16, 8);
  2241.             uint8_t r = UNPACK(*src, 24, 8);
  2242.  
  2243.      
  2244.          
  2245.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2246.      
  2247.          
  2248.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2249.      
  2250.          
  2251.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2252.      
  2253.          
  2254.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2255. }
  2256.  
  2257. static inline void
  2258. unpack_ubyte_x8b8g8r8_unorm(const void *void_src, GLubyte dst[4])
  2259. {
  2260.    uint32_t *src = (uint32_t *)void_src;
  2261.             uint8_t b = UNPACK(*src, 8, 8);
  2262.             uint8_t g = UNPACK(*src, 16, 8);
  2263.             uint8_t r = UNPACK(*src, 24, 8);
  2264.  
  2265.      
  2266.          
  2267.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2268.      
  2269.          
  2270.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2271.      
  2272.          
  2273.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2274.      
  2275.          dst[3] = 255;
  2276. }
  2277.  
  2278. static inline void
  2279. unpack_ubyte_r8g8b8a8_unorm(const void *void_src, GLubyte dst[4])
  2280. {
  2281.    uint32_t *src = (uint32_t *)void_src;
  2282.             uint8_t r = UNPACK(*src, 0, 8);
  2283.             uint8_t g = UNPACK(*src, 8, 8);
  2284.             uint8_t b = UNPACK(*src, 16, 8);
  2285.             uint8_t a = UNPACK(*src, 24, 8);
  2286.  
  2287.      
  2288.          
  2289.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2290.      
  2291.          
  2292.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2293.      
  2294.          
  2295.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2296.      
  2297.          
  2298.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2299. }
  2300.  
  2301. static inline void
  2302. unpack_ubyte_r8g8b8x8_unorm(const void *void_src, GLubyte dst[4])
  2303. {
  2304.    uint32_t *src = (uint32_t *)void_src;
  2305.             uint8_t r = UNPACK(*src, 0, 8);
  2306.             uint8_t g = UNPACK(*src, 8, 8);
  2307.             uint8_t b = UNPACK(*src, 16, 8);
  2308.  
  2309.      
  2310.          
  2311.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2312.      
  2313.          
  2314.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2315.      
  2316.          
  2317.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2318.      
  2319.          dst[3] = 255;
  2320. }
  2321.  
  2322. static inline void
  2323. unpack_ubyte_b8g8r8a8_unorm(const void *void_src, GLubyte dst[4])
  2324. {
  2325.    uint32_t *src = (uint32_t *)void_src;
  2326.             uint8_t b = UNPACK(*src, 0, 8);
  2327.             uint8_t g = UNPACK(*src, 8, 8);
  2328.             uint8_t r = UNPACK(*src, 16, 8);
  2329.             uint8_t a = UNPACK(*src, 24, 8);
  2330.  
  2331.      
  2332.          
  2333.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2334.      
  2335.          
  2336.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2337.      
  2338.          
  2339.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2340.      
  2341.          
  2342.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2343. }
  2344.  
  2345. static inline void
  2346. unpack_ubyte_b8g8r8x8_unorm(const void *void_src, GLubyte dst[4])
  2347. {
  2348.    uint32_t *src = (uint32_t *)void_src;
  2349.             uint8_t b = UNPACK(*src, 0, 8);
  2350.             uint8_t g = UNPACK(*src, 8, 8);
  2351.             uint8_t r = UNPACK(*src, 16, 8);
  2352.  
  2353.      
  2354.          
  2355.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2356.      
  2357.          
  2358.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2359.      
  2360.          
  2361.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2362.      
  2363.          dst[3] = 255;
  2364. }
  2365.  
  2366. static inline void
  2367. unpack_ubyte_a8r8g8b8_unorm(const void *void_src, GLubyte dst[4])
  2368. {
  2369.    uint32_t *src = (uint32_t *)void_src;
  2370.             uint8_t a = UNPACK(*src, 0, 8);
  2371.             uint8_t r = UNPACK(*src, 8, 8);
  2372.             uint8_t g = UNPACK(*src, 16, 8);
  2373.             uint8_t b = UNPACK(*src, 24, 8);
  2374.  
  2375.      
  2376.          
  2377.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2378.      
  2379.          
  2380.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2381.      
  2382.          
  2383.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2384.      
  2385.          
  2386.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2387. }
  2388.  
  2389. static inline void
  2390. unpack_ubyte_x8r8g8b8_unorm(const void *void_src, GLubyte dst[4])
  2391. {
  2392.    uint32_t *src = (uint32_t *)void_src;
  2393.             uint8_t r = UNPACK(*src, 8, 8);
  2394.             uint8_t g = UNPACK(*src, 16, 8);
  2395.             uint8_t b = UNPACK(*src, 24, 8);
  2396.  
  2397.      
  2398.          
  2399.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2400.      
  2401.          
  2402.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2403.      
  2404.          
  2405.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  2406.      
  2407.          dst[3] = 255;
  2408. }
  2409.  
  2410. static inline void
  2411. unpack_ubyte_l16a16_unorm(const void *void_src, GLubyte dst[4])
  2412. {
  2413.    uint32_t *src = (uint32_t *)void_src;
  2414.             uint16_t l = UNPACK(*src, 0, 16);
  2415.             uint16_t a = UNPACK(*src, 16, 16);
  2416.  
  2417.      
  2418.          
  2419.                dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
  2420.      
  2421.          
  2422.                dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
  2423.      
  2424.          
  2425.                dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
  2426.      
  2427.          
  2428.                dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
  2429. }
  2430.  
  2431. static inline void
  2432. unpack_ubyte_a16l16_unorm(const void *void_src, GLubyte dst[4])
  2433. {
  2434.    uint32_t *src = (uint32_t *)void_src;
  2435.             uint16_t a = UNPACK(*src, 0, 16);
  2436.             uint16_t l = UNPACK(*src, 16, 16);
  2437.  
  2438.      
  2439.          
  2440.                dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
  2441.      
  2442.          
  2443.                dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
  2444.      
  2445.          
  2446.                dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
  2447.      
  2448.          
  2449.                dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
  2450. }
  2451.  
  2452. static inline void
  2453. unpack_ubyte_b5g6r5_unorm(const void *void_src, GLubyte dst[4])
  2454. {
  2455.    uint16_t *src = (uint16_t *)void_src;
  2456.             uint8_t b = UNPACK(*src, 0, 5);
  2457.             uint8_t g = UNPACK(*src, 5, 6);
  2458.             uint8_t r = UNPACK(*src, 11, 5);
  2459.  
  2460.      
  2461.          
  2462.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2463.      
  2464.          
  2465.                dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
  2466.      
  2467.          
  2468.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2469.      
  2470.          dst[3] = 255;
  2471. }
  2472.  
  2473. static inline void
  2474. unpack_ubyte_r5g6b5_unorm(const void *void_src, GLubyte dst[4])
  2475. {
  2476.    uint16_t *src = (uint16_t *)void_src;
  2477.             uint8_t r = UNPACK(*src, 0, 5);
  2478.             uint8_t g = UNPACK(*src, 5, 6);
  2479.             uint8_t b = UNPACK(*src, 11, 5);
  2480.  
  2481.      
  2482.          
  2483.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2484.      
  2485.          
  2486.                dst[1] = _mesa_unorm_to_unorm(g, 6, 8);
  2487.      
  2488.          
  2489.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2490.      
  2491.          dst[3] = 255;
  2492. }
  2493.  
  2494. static inline void
  2495. unpack_ubyte_b4g4r4a4_unorm(const void *void_src, GLubyte dst[4])
  2496. {
  2497.    uint16_t *src = (uint16_t *)void_src;
  2498.             uint8_t b = UNPACK(*src, 0, 4);
  2499.             uint8_t g = UNPACK(*src, 4, 4);
  2500.             uint8_t r = UNPACK(*src, 8, 4);
  2501.             uint8_t a = UNPACK(*src, 12, 4);
  2502.  
  2503.      
  2504.          
  2505.                dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
  2506.      
  2507.          
  2508.                dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
  2509.      
  2510.          
  2511.                dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
  2512.      
  2513.          
  2514.                dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
  2515. }
  2516.  
  2517. static inline void
  2518. unpack_ubyte_b4g4r4x4_unorm(const void *void_src, GLubyte dst[4])
  2519. {
  2520.    uint16_t *src = (uint16_t *)void_src;
  2521.             uint8_t b = UNPACK(*src, 0, 4);
  2522.             uint8_t g = UNPACK(*src, 4, 4);
  2523.             uint8_t r = UNPACK(*src, 8, 4);
  2524.  
  2525.      
  2526.          
  2527.                dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
  2528.      
  2529.          
  2530.                dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
  2531.      
  2532.          
  2533.                dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
  2534.      
  2535.          dst[3] = 255;
  2536. }
  2537.  
  2538. static inline void
  2539. unpack_ubyte_a4r4g4b4_unorm(const void *void_src, GLubyte dst[4])
  2540. {
  2541.    uint16_t *src = (uint16_t *)void_src;
  2542.             uint8_t a = UNPACK(*src, 0, 4);
  2543.             uint8_t r = UNPACK(*src, 4, 4);
  2544.             uint8_t g = UNPACK(*src, 8, 4);
  2545.             uint8_t b = UNPACK(*src, 12, 4);
  2546.  
  2547.      
  2548.          
  2549.                dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
  2550.      
  2551.          
  2552.                dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
  2553.      
  2554.          
  2555.                dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
  2556.      
  2557.          
  2558.                dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
  2559. }
  2560.  
  2561. static inline void
  2562. unpack_ubyte_a1b5g5r5_unorm(const void *void_src, GLubyte dst[4])
  2563. {
  2564.    uint16_t *src = (uint16_t *)void_src;
  2565.             uint8_t a = UNPACK(*src, 0, 1);
  2566.             uint8_t b = UNPACK(*src, 1, 5);
  2567.             uint8_t g = UNPACK(*src, 6, 5);
  2568.             uint8_t r = UNPACK(*src, 11, 5);
  2569.  
  2570.      
  2571.          
  2572.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2573.      
  2574.          
  2575.                dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
  2576.      
  2577.          
  2578.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2579.      
  2580.          
  2581.                dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
  2582. }
  2583.  
  2584. static inline void
  2585. unpack_ubyte_b5g5r5a1_unorm(const void *void_src, GLubyte dst[4])
  2586. {
  2587.    uint16_t *src = (uint16_t *)void_src;
  2588.             uint8_t b = UNPACK(*src, 0, 5);
  2589.             uint8_t g = UNPACK(*src, 5, 5);
  2590.             uint8_t r = UNPACK(*src, 10, 5);
  2591.             uint8_t a = UNPACK(*src, 15, 1);
  2592.  
  2593.      
  2594.          
  2595.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2596.      
  2597.          
  2598.                dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
  2599.      
  2600.          
  2601.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2602.      
  2603.          
  2604.                dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
  2605. }
  2606.  
  2607. static inline void
  2608. unpack_ubyte_b5g5r5x1_unorm(const void *void_src, GLubyte dst[4])
  2609. {
  2610.    uint16_t *src = (uint16_t *)void_src;
  2611.             uint8_t b = UNPACK(*src, 0, 5);
  2612.             uint8_t g = UNPACK(*src, 5, 5);
  2613.             uint8_t r = UNPACK(*src, 10, 5);
  2614.  
  2615.      
  2616.          
  2617.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2618.      
  2619.          
  2620.                dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
  2621.      
  2622.          
  2623.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2624.      
  2625.          dst[3] = 255;
  2626. }
  2627.  
  2628. static inline void
  2629. unpack_ubyte_a1r5g5b5_unorm(const void *void_src, GLubyte dst[4])
  2630. {
  2631.    uint16_t *src = (uint16_t *)void_src;
  2632.             uint8_t a = UNPACK(*src, 0, 1);
  2633.             uint8_t r = UNPACK(*src, 1, 5);
  2634.             uint8_t g = UNPACK(*src, 6, 5);
  2635.             uint8_t b = UNPACK(*src, 11, 5);
  2636.  
  2637.      
  2638.          
  2639.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2640.      
  2641.          
  2642.                dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
  2643.      
  2644.          
  2645.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2646.      
  2647.          
  2648.                dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
  2649. }
  2650.  
  2651. static inline void
  2652. unpack_ubyte_l8a8_unorm(const void *void_src, GLubyte dst[4])
  2653. {
  2654.    uint16_t *src = (uint16_t *)void_src;
  2655.             uint8_t l = UNPACK(*src, 0, 8);
  2656.             uint8_t a = UNPACK(*src, 8, 8);
  2657.  
  2658.      
  2659.          
  2660.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  2661.      
  2662.          
  2663.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  2664.      
  2665.          
  2666.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  2667.      
  2668.          
  2669.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2670. }
  2671.  
  2672. static inline void
  2673. unpack_ubyte_a8l8_unorm(const void *void_src, GLubyte dst[4])
  2674. {
  2675.    uint16_t *src = (uint16_t *)void_src;
  2676.             uint8_t a = UNPACK(*src, 0, 8);
  2677.             uint8_t l = UNPACK(*src, 8, 8);
  2678.  
  2679.      
  2680.          
  2681.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  2682.      
  2683.          
  2684.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  2685.      
  2686.          
  2687.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  2688.      
  2689.          
  2690.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  2691. }
  2692.  
  2693. static inline void
  2694. unpack_ubyte_r8g8_unorm(const void *void_src, GLubyte dst[4])
  2695. {
  2696.    uint16_t *src = (uint16_t *)void_src;
  2697.             uint8_t r = UNPACK(*src, 0, 8);
  2698.             uint8_t g = UNPACK(*src, 8, 8);
  2699.  
  2700.      
  2701.          
  2702.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2703.      
  2704.          
  2705.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2706.      
  2707.          dst[2] = 0;
  2708.      
  2709.          dst[3] = 255;
  2710. }
  2711.  
  2712. static inline void
  2713. unpack_ubyte_g8r8_unorm(const void *void_src, GLubyte dst[4])
  2714. {
  2715.    uint16_t *src = (uint16_t *)void_src;
  2716.             uint8_t g = UNPACK(*src, 0, 8);
  2717.             uint8_t r = UNPACK(*src, 8, 8);
  2718.  
  2719.      
  2720.          
  2721.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  2722.      
  2723.          
  2724.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  2725.      
  2726.          dst[2] = 0;
  2727.      
  2728.          dst[3] = 255;
  2729. }
  2730.  
  2731. static inline void
  2732. unpack_ubyte_l4a4_unorm(const void *void_src, GLubyte dst[4])
  2733. {
  2734.    uint8_t *src = (uint8_t *)void_src;
  2735.             uint8_t l = UNPACK(*src, 0, 4);
  2736.             uint8_t a = UNPACK(*src, 4, 4);
  2737.  
  2738.      
  2739.          
  2740.                dst[0] = _mesa_unorm_to_unorm(l, 4, 8);
  2741.      
  2742.          
  2743.                dst[1] = _mesa_unorm_to_unorm(l, 4, 8);
  2744.      
  2745.          
  2746.                dst[2] = _mesa_unorm_to_unorm(l, 4, 8);
  2747.      
  2748.          
  2749.                dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
  2750. }
  2751.  
  2752. static inline void
  2753. unpack_ubyte_b2g3r3_unorm(const void *void_src, GLubyte dst[4])
  2754. {
  2755.    uint8_t *src = (uint8_t *)void_src;
  2756.             uint8_t b = UNPACK(*src, 0, 2);
  2757.             uint8_t g = UNPACK(*src, 2, 3);
  2758.             uint8_t r = UNPACK(*src, 5, 3);
  2759.  
  2760.      
  2761.          
  2762.                dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
  2763.      
  2764.          
  2765.                dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
  2766.      
  2767.          
  2768.                dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
  2769.      
  2770.          dst[3] = 255;
  2771. }
  2772.  
  2773. static inline void
  2774. unpack_ubyte_r16g16_unorm(const void *void_src, GLubyte dst[4])
  2775. {
  2776.    uint32_t *src = (uint32_t *)void_src;
  2777.             uint16_t r = UNPACK(*src, 0, 16);
  2778.             uint16_t g = UNPACK(*src, 16, 16);
  2779.  
  2780.      
  2781.          
  2782.                dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
  2783.      
  2784.          
  2785.                dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
  2786.      
  2787.          dst[2] = 0;
  2788.      
  2789.          dst[3] = 255;
  2790. }
  2791.  
  2792. static inline void
  2793. unpack_ubyte_g16r16_unorm(const void *void_src, GLubyte dst[4])
  2794. {
  2795.    uint32_t *src = (uint32_t *)void_src;
  2796.             uint16_t g = UNPACK(*src, 0, 16);
  2797.             uint16_t r = UNPACK(*src, 16, 16);
  2798.  
  2799.      
  2800.          
  2801.                dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
  2802.      
  2803.          
  2804.                dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
  2805.      
  2806.          dst[2] = 0;
  2807.      
  2808.          dst[3] = 255;
  2809. }
  2810.  
  2811. static inline void
  2812. unpack_ubyte_b10g10r10a2_unorm(const void *void_src, GLubyte dst[4])
  2813. {
  2814.    uint32_t *src = (uint32_t *)void_src;
  2815.             uint16_t b = UNPACK(*src, 0, 10);
  2816.             uint16_t g = UNPACK(*src, 10, 10);
  2817.             uint16_t r = UNPACK(*src, 20, 10);
  2818.             uint8_t a = UNPACK(*src, 30, 2);
  2819.  
  2820.      
  2821.          
  2822.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  2823.      
  2824.          
  2825.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  2826.      
  2827.          
  2828.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  2829.      
  2830.          
  2831.                dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
  2832. }
  2833.  
  2834. static inline void
  2835. unpack_ubyte_b10g10r10x2_unorm(const void *void_src, GLubyte dst[4])
  2836. {
  2837.    uint32_t *src = (uint32_t *)void_src;
  2838.             uint16_t b = UNPACK(*src, 0, 10);
  2839.             uint16_t g = UNPACK(*src, 10, 10);
  2840.             uint16_t r = UNPACK(*src, 20, 10);
  2841.  
  2842.      
  2843.          
  2844.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  2845.      
  2846.          
  2847.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  2848.      
  2849.          
  2850.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  2851.      
  2852.          dst[3] = 255;
  2853. }
  2854.  
  2855. static inline void
  2856. unpack_ubyte_r10g10b10a2_unorm(const void *void_src, GLubyte dst[4])
  2857. {
  2858.    uint32_t *src = (uint32_t *)void_src;
  2859.             uint16_t r = UNPACK(*src, 0, 10);
  2860.             uint16_t g = UNPACK(*src, 10, 10);
  2861.             uint16_t b = UNPACK(*src, 20, 10);
  2862.             uint8_t a = UNPACK(*src, 30, 2);
  2863.  
  2864.      
  2865.          
  2866.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  2867.      
  2868.          
  2869.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  2870.      
  2871.          
  2872.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  2873.      
  2874.          
  2875.                dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
  2876. }
  2877.  
  2878. static inline void
  2879. unpack_ubyte_r10g10b10x2_unorm(const void *void_src, GLubyte dst[4])
  2880. {
  2881.    uint32_t *src = (uint32_t *)void_src;
  2882.             uint16_t r = UNPACK(*src, 0, 10);
  2883.             uint16_t g = UNPACK(*src, 10, 10);
  2884.             uint16_t b = UNPACK(*src, 20, 10);
  2885.  
  2886.      
  2887.          
  2888.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  2889.      
  2890.          
  2891.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  2892.      
  2893.          
  2894.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  2895.      
  2896.          dst[3] = 255;
  2897. }
  2898.  
  2899. static inline void
  2900. unpack_ubyte_r3g3b2_unorm(const void *void_src, GLubyte dst[4])
  2901. {
  2902.    uint8_t *src = (uint8_t *)void_src;
  2903.             uint8_t r = UNPACK(*src, 0, 3);
  2904.             uint8_t g = UNPACK(*src, 3, 3);
  2905.             uint8_t b = UNPACK(*src, 6, 2);
  2906.  
  2907.      
  2908.          
  2909.                dst[0] = _mesa_unorm_to_unorm(r, 3, 8);
  2910.      
  2911.          
  2912.                dst[1] = _mesa_unorm_to_unorm(g, 3, 8);
  2913.      
  2914.          
  2915.                dst[2] = _mesa_unorm_to_unorm(b, 2, 8);
  2916.      
  2917.          dst[3] = 255;
  2918. }
  2919.  
  2920. static inline void
  2921. unpack_ubyte_a4b4g4r4_unorm(const void *void_src, GLubyte dst[4])
  2922. {
  2923.    uint16_t *src = (uint16_t *)void_src;
  2924.             uint8_t a = UNPACK(*src, 0, 4);
  2925.             uint8_t b = UNPACK(*src, 4, 4);
  2926.             uint8_t g = UNPACK(*src, 8, 4);
  2927.             uint8_t r = UNPACK(*src, 12, 4);
  2928.  
  2929.      
  2930.          
  2931.                dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
  2932.      
  2933.          
  2934.                dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
  2935.      
  2936.          
  2937.                dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
  2938.      
  2939.          
  2940.                dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
  2941. }
  2942.  
  2943. static inline void
  2944. unpack_ubyte_r4g4b4a4_unorm(const void *void_src, GLubyte dst[4])
  2945. {
  2946.    uint16_t *src = (uint16_t *)void_src;
  2947.             uint8_t r = UNPACK(*src, 0, 4);
  2948.             uint8_t g = UNPACK(*src, 4, 4);
  2949.             uint8_t b = UNPACK(*src, 8, 4);
  2950.             uint8_t a = UNPACK(*src, 12, 4);
  2951.  
  2952.      
  2953.          
  2954.                dst[0] = _mesa_unorm_to_unorm(r, 4, 8);
  2955.      
  2956.          
  2957.                dst[1] = _mesa_unorm_to_unorm(g, 4, 8);
  2958.      
  2959.          
  2960.                dst[2] = _mesa_unorm_to_unorm(b, 4, 8);
  2961.      
  2962.          
  2963.                dst[3] = _mesa_unorm_to_unorm(a, 4, 8);
  2964. }
  2965.  
  2966. static inline void
  2967. unpack_ubyte_r5g5b5a1_unorm(const void *void_src, GLubyte dst[4])
  2968. {
  2969.    uint16_t *src = (uint16_t *)void_src;
  2970.             uint8_t r = UNPACK(*src, 0, 5);
  2971.             uint8_t g = UNPACK(*src, 5, 5);
  2972.             uint8_t b = UNPACK(*src, 10, 5);
  2973.             uint8_t a = UNPACK(*src, 15, 1);
  2974.  
  2975.      
  2976.          
  2977.                dst[0] = _mesa_unorm_to_unorm(r, 5, 8);
  2978.      
  2979.          
  2980.                dst[1] = _mesa_unorm_to_unorm(g, 5, 8);
  2981.      
  2982.          
  2983.                dst[2] = _mesa_unorm_to_unorm(b, 5, 8);
  2984.      
  2985.          
  2986.                dst[3] = _mesa_unorm_to_unorm(a, 1, 8);
  2987. }
  2988.  
  2989. static inline void
  2990. unpack_ubyte_a2b10g10r10_unorm(const void *void_src, GLubyte dst[4])
  2991. {
  2992.    uint32_t *src = (uint32_t *)void_src;
  2993.             uint8_t a = UNPACK(*src, 0, 2);
  2994.             uint16_t b = UNPACK(*src, 2, 10);
  2995.             uint16_t g = UNPACK(*src, 12, 10);
  2996.             uint16_t r = UNPACK(*src, 22, 10);
  2997.  
  2998.      
  2999.          
  3000.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  3001.      
  3002.          
  3003.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  3004.      
  3005.          
  3006.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  3007.      
  3008.          
  3009.                dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
  3010. }
  3011.  
  3012. static inline void
  3013. unpack_ubyte_a2r10g10b10_unorm(const void *void_src, GLubyte dst[4])
  3014. {
  3015.    uint32_t *src = (uint32_t *)void_src;
  3016.             uint8_t a = UNPACK(*src, 0, 2);
  3017.             uint16_t r = UNPACK(*src, 2, 10);
  3018.             uint16_t g = UNPACK(*src, 12, 10);
  3019.             uint16_t b = UNPACK(*src, 22, 10);
  3020.  
  3021.      
  3022.          
  3023.                dst[0] = _mesa_unorm_to_unorm(r, 10, 8);
  3024.      
  3025.          
  3026.                dst[1] = _mesa_unorm_to_unorm(g, 10, 8);
  3027.      
  3028.          
  3029.                dst[2] = _mesa_unorm_to_unorm(b, 10, 8);
  3030.      
  3031.          
  3032.                dst[3] = _mesa_unorm_to_unorm(a, 2, 8);
  3033. }
  3034.  
  3035. static inline void
  3036. unpack_ubyte_a_unorm8(const void *void_src, GLubyte dst[4])
  3037. {
  3038.    uint8_t *src = (uint8_t *)void_src;
  3039.             uint8_t a = src[0];
  3040.  
  3041.      
  3042.          dst[0] = 0;
  3043.      
  3044.          dst[1] = 0;
  3045.      
  3046.          dst[2] = 0;
  3047.      
  3048.          
  3049.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3050. }
  3051.  
  3052. static inline void
  3053. unpack_ubyte_a_unorm16(const void *void_src, GLubyte dst[4])
  3054. {
  3055.    uint16_t *src = (uint16_t *)void_src;
  3056.             uint16_t a = src[0];
  3057.  
  3058.      
  3059.          dst[0] = 0;
  3060.      
  3061.          dst[1] = 0;
  3062.      
  3063.          dst[2] = 0;
  3064.      
  3065.          
  3066.                dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
  3067. }
  3068.  
  3069. static inline void
  3070. unpack_ubyte_l_unorm8(const void *void_src, GLubyte dst[4])
  3071. {
  3072.    uint8_t *src = (uint8_t *)void_src;
  3073.             uint8_t l = src[0];
  3074.  
  3075.      
  3076.          
  3077.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  3078.      
  3079.          
  3080.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  3081.      
  3082.          
  3083.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  3084.      
  3085.          dst[3] = 255;
  3086. }
  3087.  
  3088. static inline void
  3089. unpack_ubyte_l_unorm16(const void *void_src, GLubyte dst[4])
  3090. {
  3091.    uint16_t *src = (uint16_t *)void_src;
  3092.             uint16_t l = src[0];
  3093.  
  3094.      
  3095.          
  3096.                dst[0] = _mesa_unorm_to_unorm(l, 16, 8);
  3097.      
  3098.          
  3099.                dst[1] = _mesa_unorm_to_unorm(l, 16, 8);
  3100.      
  3101.          
  3102.                dst[2] = _mesa_unorm_to_unorm(l, 16, 8);
  3103.      
  3104.          dst[3] = 255;
  3105. }
  3106.  
  3107. static inline void
  3108. unpack_ubyte_i_unorm8(const void *void_src, GLubyte dst[4])
  3109. {
  3110.    uint8_t *src = (uint8_t *)void_src;
  3111.             uint8_t i = src[0];
  3112.  
  3113.      
  3114.          
  3115.                dst[0] = _mesa_unorm_to_unorm(i, 8, 8);
  3116.      
  3117.          
  3118.                dst[1] = _mesa_unorm_to_unorm(i, 8, 8);
  3119.      
  3120.          
  3121.                dst[2] = _mesa_unorm_to_unorm(i, 8, 8);
  3122.      
  3123.          
  3124.                dst[3] = _mesa_unorm_to_unorm(i, 8, 8);
  3125. }
  3126.  
  3127. static inline void
  3128. unpack_ubyte_i_unorm16(const void *void_src, GLubyte dst[4])
  3129. {
  3130.    uint16_t *src = (uint16_t *)void_src;
  3131.             uint16_t i = src[0];
  3132.  
  3133.      
  3134.          
  3135.                dst[0] = _mesa_unorm_to_unorm(i, 16, 8);
  3136.      
  3137.          
  3138.                dst[1] = _mesa_unorm_to_unorm(i, 16, 8);
  3139.      
  3140.          
  3141.                dst[2] = _mesa_unorm_to_unorm(i, 16, 8);
  3142.      
  3143.          
  3144.                dst[3] = _mesa_unorm_to_unorm(i, 16, 8);
  3145. }
  3146.  
  3147. static inline void
  3148. unpack_ubyte_r_unorm8(const void *void_src, GLubyte dst[4])
  3149. {
  3150.    uint8_t *src = (uint8_t *)void_src;
  3151.             uint8_t r = src[0];
  3152.  
  3153.      
  3154.          
  3155.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  3156.      
  3157.          dst[1] = 0;
  3158.      
  3159.          dst[2] = 0;
  3160.      
  3161.          dst[3] = 255;
  3162. }
  3163.  
  3164. static inline void
  3165. unpack_ubyte_r_unorm16(const void *void_src, GLubyte dst[4])
  3166. {
  3167.    uint16_t *src = (uint16_t *)void_src;
  3168.             uint16_t r = src[0];
  3169.  
  3170.      
  3171.          
  3172.                dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
  3173.      
  3174.          dst[1] = 0;
  3175.      
  3176.          dst[2] = 0;
  3177.      
  3178.          dst[3] = 255;
  3179. }
  3180.  
  3181. static inline void
  3182. unpack_ubyte_bgr_unorm8(const void *void_src, GLubyte dst[4])
  3183. {
  3184.    uint8_t *src = (uint8_t *)void_src;
  3185.             uint8_t b = src[0];
  3186.             uint8_t g = src[1];
  3187.             uint8_t r = src[2];
  3188.  
  3189.      
  3190.          
  3191.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  3192.      
  3193.          
  3194.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  3195.      
  3196.          
  3197.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  3198.      
  3199.          dst[3] = 255;
  3200. }
  3201.  
  3202. static inline void
  3203. unpack_ubyte_rgb_unorm8(const void *void_src, GLubyte dst[4])
  3204. {
  3205.    uint8_t *src = (uint8_t *)void_src;
  3206.             uint8_t r = src[0];
  3207.             uint8_t g = src[1];
  3208.             uint8_t b = src[2];
  3209.  
  3210.      
  3211.          
  3212.                dst[0] = _mesa_unorm_to_unorm(r, 8, 8);
  3213.      
  3214.          
  3215.                dst[1] = _mesa_unorm_to_unorm(g, 8, 8);
  3216.      
  3217.          
  3218.                dst[2] = _mesa_unorm_to_unorm(b, 8, 8);
  3219.      
  3220.          dst[3] = 255;
  3221. }
  3222.  
  3223. static inline void
  3224. unpack_ubyte_rgba_unorm16(const void *void_src, GLubyte dst[4])
  3225. {
  3226.    uint16_t *src = (uint16_t *)void_src;
  3227.             uint16_t r = src[0];
  3228.             uint16_t g = src[1];
  3229.             uint16_t b = src[2];
  3230.             uint16_t a = src[3];
  3231.  
  3232.      
  3233.          
  3234.                dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
  3235.      
  3236.          
  3237.                dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
  3238.      
  3239.          
  3240.                dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
  3241.      
  3242.          
  3243.                dst[3] = _mesa_unorm_to_unorm(a, 16, 8);
  3244. }
  3245.  
  3246. static inline void
  3247. unpack_ubyte_rgbx_unorm16(const void *void_src, GLubyte dst[4])
  3248. {
  3249.    uint16_t *src = (uint16_t *)void_src;
  3250.             uint16_t r = src[0];
  3251.             uint16_t g = src[1];
  3252.             uint16_t b = src[2];
  3253.  
  3254.      
  3255.          
  3256.                dst[0] = _mesa_unorm_to_unorm(r, 16, 8);
  3257.      
  3258.          
  3259.                dst[1] = _mesa_unorm_to_unorm(g, 16, 8);
  3260.      
  3261.          
  3262.                dst[2] = _mesa_unorm_to_unorm(b, 16, 8);
  3263.      
  3264.          dst[3] = 255;
  3265. }
  3266.  
  3267. static inline void
  3268. unpack_ubyte_a8b8g8r8_snorm(const void *void_src, GLubyte dst[4])
  3269. {
  3270.    uint32_t *src = (uint32_t *)void_src;
  3271.             int8_t a = UNPACK(*src, 0, 8);
  3272.             int8_t b = UNPACK(*src, 8, 8);
  3273.             int8_t g = UNPACK(*src, 16, 8);
  3274.             int8_t r = UNPACK(*src, 24, 8);
  3275.  
  3276.      
  3277.          
  3278.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3279.      
  3280.          
  3281.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3282.      
  3283.          
  3284.             dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
  3285.      
  3286.          
  3287.             dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
  3288. }
  3289.  
  3290. static inline void
  3291. unpack_ubyte_x8b8g8r8_snorm(const void *void_src, GLubyte dst[4])
  3292. {
  3293.    uint32_t *src = (uint32_t *)void_src;
  3294.             int8_t b = UNPACK(*src, 8, 8);
  3295.             int8_t g = UNPACK(*src, 16, 8);
  3296.             int8_t r = UNPACK(*src, 24, 8);
  3297.  
  3298.      
  3299.          
  3300.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3301.      
  3302.          
  3303.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3304.      
  3305.          
  3306.             dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
  3307.      
  3308.          dst[3] = 255;
  3309. }
  3310.  
  3311. static inline void
  3312. unpack_ubyte_r8g8b8a8_snorm(const void *void_src, GLubyte dst[4])
  3313. {
  3314.    uint32_t *src = (uint32_t *)void_src;
  3315.             int8_t r = UNPACK(*src, 0, 8);
  3316.             int8_t g = UNPACK(*src, 8, 8);
  3317.             int8_t b = UNPACK(*src, 16, 8);
  3318.             int8_t a = UNPACK(*src, 24, 8);
  3319.  
  3320.      
  3321.          
  3322.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3323.      
  3324.          
  3325.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3326.      
  3327.          
  3328.             dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
  3329.      
  3330.          
  3331.             dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
  3332. }
  3333.  
  3334. static inline void
  3335. unpack_ubyte_r8g8b8x8_snorm(const void *void_src, GLubyte dst[4])
  3336. {
  3337.    uint32_t *src = (uint32_t *)void_src;
  3338.             int8_t r = UNPACK(*src, 0, 8);
  3339.             int8_t g = UNPACK(*src, 8, 8);
  3340.             int8_t b = UNPACK(*src, 16, 8);
  3341.  
  3342.      
  3343.          
  3344.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3345.      
  3346.          
  3347.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3348.      
  3349.          
  3350.             dst[2] = _mesa_snorm_to_unorm(b, 8, 8);
  3351.      
  3352.          dst[3] = 255;
  3353. }
  3354.  
  3355. static inline void
  3356. unpack_ubyte_r16g16_snorm(const void *void_src, GLubyte dst[4])
  3357. {
  3358.    uint32_t *src = (uint32_t *)void_src;
  3359.             int16_t r = UNPACK(*src, 0, 16);
  3360.             int16_t g = UNPACK(*src, 16, 16);
  3361.  
  3362.      
  3363.          
  3364.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3365.      
  3366.          
  3367.             dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
  3368.      
  3369.          dst[2] = 0;
  3370.      
  3371.          dst[3] = 255;
  3372. }
  3373.  
  3374. static inline void
  3375. unpack_ubyte_g16r16_snorm(const void *void_src, GLubyte dst[4])
  3376. {
  3377.    uint32_t *src = (uint32_t *)void_src;
  3378.             int16_t g = UNPACK(*src, 0, 16);
  3379.             int16_t r = UNPACK(*src, 16, 16);
  3380.  
  3381.      
  3382.          
  3383.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3384.      
  3385.          
  3386.             dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
  3387.      
  3388.          dst[2] = 0;
  3389.      
  3390.          dst[3] = 255;
  3391. }
  3392.  
  3393. static inline void
  3394. unpack_ubyte_r8g8_snorm(const void *void_src, GLubyte dst[4])
  3395. {
  3396.    uint16_t *src = (uint16_t *)void_src;
  3397.             int8_t r = UNPACK(*src, 0, 8);
  3398.             int8_t g = UNPACK(*src, 8, 8);
  3399.  
  3400.      
  3401.          
  3402.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3403.      
  3404.          
  3405.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3406.      
  3407.          dst[2] = 0;
  3408.      
  3409.          dst[3] = 255;
  3410. }
  3411.  
  3412. static inline void
  3413. unpack_ubyte_g8r8_snorm(const void *void_src, GLubyte dst[4])
  3414. {
  3415.    uint16_t *src = (uint16_t *)void_src;
  3416.             int8_t g = UNPACK(*src, 0, 8);
  3417.             int8_t r = UNPACK(*src, 8, 8);
  3418.  
  3419.      
  3420.          
  3421.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3422.      
  3423.          
  3424.             dst[1] = _mesa_snorm_to_unorm(g, 8, 8);
  3425.      
  3426.          dst[2] = 0;
  3427.      
  3428.          dst[3] = 255;
  3429. }
  3430.  
  3431. static inline void
  3432. unpack_ubyte_l8a8_snorm(const void *void_src, GLubyte dst[4])
  3433. {
  3434.    uint16_t *src = (uint16_t *)void_src;
  3435.             int8_t l = UNPACK(*src, 0, 8);
  3436.             int8_t a = UNPACK(*src, 8, 8);
  3437.  
  3438.      
  3439.          
  3440.             dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
  3441.      
  3442.          
  3443.             dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
  3444.      
  3445.          
  3446.             dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
  3447.      
  3448.          
  3449.             dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
  3450. }
  3451.  
  3452. static inline void
  3453. unpack_ubyte_a8l8_snorm(const void *void_src, GLubyte dst[4])
  3454. {
  3455.    uint16_t *src = (uint16_t *)void_src;
  3456.             int8_t a = UNPACK(*src, 0, 8);
  3457.             int8_t l = UNPACK(*src, 8, 8);
  3458.  
  3459.      
  3460.          
  3461.             dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
  3462.      
  3463.          
  3464.             dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
  3465.      
  3466.          
  3467.             dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
  3468.      
  3469.          
  3470.             dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
  3471. }
  3472.  
  3473. static inline void
  3474. unpack_ubyte_a_snorm8(const void *void_src, GLubyte dst[4])
  3475. {
  3476.    int8_t *src = (int8_t *)void_src;
  3477.             int8_t a = src[0];
  3478.  
  3479.      
  3480.          dst[0] = 0;
  3481.      
  3482.          dst[1] = 0;
  3483.      
  3484.          dst[2] = 0;
  3485.      
  3486.          
  3487.             dst[3] = _mesa_snorm_to_unorm(a, 8, 8);
  3488. }
  3489.  
  3490. static inline void
  3491. unpack_ubyte_a_snorm16(const void *void_src, GLubyte dst[4])
  3492. {
  3493.    int16_t *src = (int16_t *)void_src;
  3494.             int16_t a = src[0];
  3495.  
  3496.      
  3497.          dst[0] = 0;
  3498.      
  3499.          dst[1] = 0;
  3500.      
  3501.          dst[2] = 0;
  3502.      
  3503.          
  3504.             dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
  3505. }
  3506.  
  3507. static inline void
  3508. unpack_ubyte_l_snorm8(const void *void_src, GLubyte dst[4])
  3509. {
  3510.    int8_t *src = (int8_t *)void_src;
  3511.             int8_t l = src[0];
  3512.  
  3513.      
  3514.          
  3515.             dst[0] = _mesa_snorm_to_unorm(l, 8, 8);
  3516.      
  3517.          
  3518.             dst[1] = _mesa_snorm_to_unorm(l, 8, 8);
  3519.      
  3520.          
  3521.             dst[2] = _mesa_snorm_to_unorm(l, 8, 8);
  3522.      
  3523.          dst[3] = 255;
  3524. }
  3525.  
  3526. static inline void
  3527. unpack_ubyte_l_snorm16(const void *void_src, GLubyte dst[4])
  3528. {
  3529.    int16_t *src = (int16_t *)void_src;
  3530.             int16_t l = src[0];
  3531.  
  3532.      
  3533.          
  3534.             dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
  3535.      
  3536.          
  3537.             dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
  3538.      
  3539.          
  3540.             dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
  3541.      
  3542.          dst[3] = 255;
  3543. }
  3544.  
  3545. static inline void
  3546. unpack_ubyte_i_snorm8(const void *void_src, GLubyte dst[4])
  3547. {
  3548.    int8_t *src = (int8_t *)void_src;
  3549.             int8_t i = src[0];
  3550.  
  3551.      
  3552.          
  3553.             dst[0] = _mesa_snorm_to_unorm(i, 8, 8);
  3554.      
  3555.          
  3556.             dst[1] = _mesa_snorm_to_unorm(i, 8, 8);
  3557.      
  3558.          
  3559.             dst[2] = _mesa_snorm_to_unorm(i, 8, 8);
  3560.      
  3561.          
  3562.             dst[3] = _mesa_snorm_to_unorm(i, 8, 8);
  3563. }
  3564.  
  3565. static inline void
  3566. unpack_ubyte_i_snorm16(const void *void_src, GLubyte dst[4])
  3567. {
  3568.    int16_t *src = (int16_t *)void_src;
  3569.             int16_t i = src[0];
  3570.  
  3571.      
  3572.          
  3573.             dst[0] = _mesa_snorm_to_unorm(i, 16, 8);
  3574.      
  3575.          
  3576.             dst[1] = _mesa_snorm_to_unorm(i, 16, 8);
  3577.      
  3578.          
  3579.             dst[2] = _mesa_snorm_to_unorm(i, 16, 8);
  3580.      
  3581.          
  3582.             dst[3] = _mesa_snorm_to_unorm(i, 16, 8);
  3583. }
  3584.  
  3585. static inline void
  3586. unpack_ubyte_r_snorm8(const void *void_src, GLubyte dst[4])
  3587. {
  3588.    int8_t *src = (int8_t *)void_src;
  3589.             int8_t r = src[0];
  3590.  
  3591.      
  3592.          
  3593.             dst[0] = _mesa_snorm_to_unorm(r, 8, 8);
  3594.      
  3595.          dst[1] = 0;
  3596.      
  3597.          dst[2] = 0;
  3598.      
  3599.          dst[3] = 255;
  3600. }
  3601.  
  3602. static inline void
  3603. unpack_ubyte_r_snorm16(const void *void_src, GLubyte dst[4])
  3604. {
  3605.    int16_t *src = (int16_t *)void_src;
  3606.             int16_t r = src[0];
  3607.  
  3608.      
  3609.          
  3610.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3611.      
  3612.          dst[1] = 0;
  3613.      
  3614.          dst[2] = 0;
  3615.      
  3616.          dst[3] = 255;
  3617. }
  3618.  
  3619. static inline void
  3620. unpack_ubyte_la_snorm16(const void *void_src, GLubyte dst[4])
  3621. {
  3622.    int16_t *src = (int16_t *)void_src;
  3623.             int16_t l = src[0];
  3624.             int16_t a = src[1];
  3625.  
  3626.      
  3627.          
  3628.             dst[0] = _mesa_snorm_to_unorm(l, 16, 8);
  3629.      
  3630.          
  3631.             dst[1] = _mesa_snorm_to_unorm(l, 16, 8);
  3632.      
  3633.          
  3634.             dst[2] = _mesa_snorm_to_unorm(l, 16, 8);
  3635.      
  3636.          
  3637.             dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
  3638. }
  3639.  
  3640. static inline void
  3641. unpack_ubyte_rgb_snorm16(const void *void_src, GLubyte dst[4])
  3642. {
  3643.    int16_t *src = (int16_t *)void_src;
  3644.             int16_t r = src[0];
  3645.             int16_t g = src[1];
  3646.             int16_t b = src[2];
  3647.  
  3648.      
  3649.          
  3650.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3651.      
  3652.          
  3653.             dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
  3654.      
  3655.          
  3656.             dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
  3657.      
  3658.          dst[3] = 255;
  3659. }
  3660.  
  3661. static inline void
  3662. unpack_ubyte_rgba_snorm16(const void *void_src, GLubyte dst[4])
  3663. {
  3664.    int16_t *src = (int16_t *)void_src;
  3665.             int16_t r = src[0];
  3666.             int16_t g = src[1];
  3667.             int16_t b = src[2];
  3668.             int16_t a = src[3];
  3669.  
  3670.      
  3671.          
  3672.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3673.      
  3674.          
  3675.             dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
  3676.      
  3677.          
  3678.             dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
  3679.      
  3680.          
  3681.             dst[3] = _mesa_snorm_to_unorm(a, 16, 8);
  3682. }
  3683.  
  3684. static inline void
  3685. unpack_ubyte_rgbx_snorm16(const void *void_src, GLubyte dst[4])
  3686. {
  3687.    int16_t *src = (int16_t *)void_src;
  3688.             int16_t r = src[0];
  3689.             int16_t g = src[1];
  3690.             int16_t b = src[2];
  3691.  
  3692.      
  3693.          
  3694.             dst[0] = _mesa_snorm_to_unorm(r, 16, 8);
  3695.      
  3696.          
  3697.             dst[1] = _mesa_snorm_to_unorm(g, 16, 8);
  3698.      
  3699.          
  3700.             dst[2] = _mesa_snorm_to_unorm(b, 16, 8);
  3701.      
  3702.          dst[3] = 255;
  3703. }
  3704.  
  3705. static inline void
  3706. unpack_ubyte_a8b8g8r8_srgb(const void *void_src, GLubyte dst[4])
  3707. {
  3708.    uint32_t *src = (uint32_t *)void_src;
  3709.             uint8_t a = UNPACK(*src, 0, 8);
  3710.             uint8_t b = UNPACK(*src, 8, 8);
  3711.             uint8_t g = UNPACK(*src, 16, 8);
  3712.             uint8_t r = UNPACK(*src, 24, 8);
  3713.  
  3714.      
  3715.          
  3716.                
  3717.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3718.      
  3719.          
  3720.                
  3721.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3722.      
  3723.          
  3724.                
  3725.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3726.      
  3727.          
  3728.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3729. }
  3730.  
  3731. static inline void
  3732. unpack_ubyte_b8g8r8a8_srgb(const void *void_src, GLubyte dst[4])
  3733. {
  3734.    uint32_t *src = (uint32_t *)void_src;
  3735.             uint8_t b = UNPACK(*src, 0, 8);
  3736.             uint8_t g = UNPACK(*src, 8, 8);
  3737.             uint8_t r = UNPACK(*src, 16, 8);
  3738.             uint8_t a = UNPACK(*src, 24, 8);
  3739.  
  3740.      
  3741.          
  3742.                
  3743.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3744.      
  3745.          
  3746.                
  3747.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3748.      
  3749.          
  3750.                
  3751.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3752.      
  3753.          
  3754.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3755. }
  3756.  
  3757. static inline void
  3758. unpack_ubyte_a8r8g8b8_srgb(const void *void_src, GLubyte dst[4])
  3759. {
  3760.    uint32_t *src = (uint32_t *)void_src;
  3761.             uint8_t a = UNPACK(*src, 0, 8);
  3762.             uint8_t r = UNPACK(*src, 8, 8);
  3763.             uint8_t g = UNPACK(*src, 16, 8);
  3764.             uint8_t b = UNPACK(*src, 24, 8);
  3765.  
  3766.      
  3767.          
  3768.                
  3769.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3770.      
  3771.          
  3772.                
  3773.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3774.      
  3775.          
  3776.                
  3777.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3778.      
  3779.          
  3780.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3781. }
  3782.  
  3783. static inline void
  3784. unpack_ubyte_b8g8r8x8_srgb(const void *void_src, GLubyte dst[4])
  3785. {
  3786.    uint32_t *src = (uint32_t *)void_src;
  3787.             uint8_t b = UNPACK(*src, 0, 8);
  3788.             uint8_t g = UNPACK(*src, 8, 8);
  3789.             uint8_t r = UNPACK(*src, 16, 8);
  3790.  
  3791.      
  3792.          
  3793.                
  3794.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3795.      
  3796.          
  3797.                
  3798.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3799.      
  3800.          
  3801.                
  3802.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3803.      
  3804.          dst[3] = 255;
  3805. }
  3806.  
  3807. static inline void
  3808. unpack_ubyte_x8r8g8b8_srgb(const void *void_src, GLubyte dst[4])
  3809. {
  3810.    uint32_t *src = (uint32_t *)void_src;
  3811.             uint8_t r = UNPACK(*src, 8, 8);
  3812.             uint8_t g = UNPACK(*src, 16, 8);
  3813.             uint8_t b = UNPACK(*src, 24, 8);
  3814.  
  3815.      
  3816.          
  3817.                
  3818.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3819.      
  3820.          
  3821.                
  3822.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3823.      
  3824.          
  3825.                
  3826.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3827.      
  3828.          dst[3] = 255;
  3829. }
  3830.  
  3831. static inline void
  3832. unpack_ubyte_r8g8b8a8_srgb(const void *void_src, GLubyte dst[4])
  3833. {
  3834.    uint32_t *src = (uint32_t *)void_src;
  3835.             uint8_t r = UNPACK(*src, 0, 8);
  3836.             uint8_t g = UNPACK(*src, 8, 8);
  3837.             uint8_t b = UNPACK(*src, 16, 8);
  3838.             uint8_t a = UNPACK(*src, 24, 8);
  3839.  
  3840.      
  3841.          
  3842.                
  3843.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3844.      
  3845.          
  3846.                
  3847.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3848.      
  3849.          
  3850.                
  3851.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3852.      
  3853.          
  3854.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3855. }
  3856.  
  3857. static inline void
  3858. unpack_ubyte_r8g8b8x8_srgb(const void *void_src, GLubyte dst[4])
  3859. {
  3860.    uint32_t *src = (uint32_t *)void_src;
  3861.             uint8_t r = UNPACK(*src, 0, 8);
  3862.             uint8_t g = UNPACK(*src, 8, 8);
  3863.             uint8_t b = UNPACK(*src, 16, 8);
  3864.  
  3865.      
  3866.          
  3867.                
  3868.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3869.      
  3870.          
  3871.                
  3872.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3873.      
  3874.          
  3875.                
  3876.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3877.      
  3878.          dst[3] = 255;
  3879. }
  3880.  
  3881. static inline void
  3882. unpack_ubyte_x8b8g8r8_srgb(const void *void_src, GLubyte dst[4])
  3883. {
  3884.    uint32_t *src = (uint32_t *)void_src;
  3885.             uint8_t b = UNPACK(*src, 8, 8);
  3886.             uint8_t g = UNPACK(*src, 16, 8);
  3887.             uint8_t r = UNPACK(*src, 24, 8);
  3888.  
  3889.      
  3890.          
  3891.                
  3892.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3893.      
  3894.          
  3895.                
  3896.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3897.      
  3898.          
  3899.                
  3900.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3901.      
  3902.          dst[3] = 255;
  3903. }
  3904.  
  3905. static inline void
  3906. unpack_ubyte_l8a8_srgb(const void *void_src, GLubyte dst[4])
  3907. {
  3908.    uint16_t *src = (uint16_t *)void_src;
  3909.             uint8_t l = UNPACK(*src, 0, 8);
  3910.             uint8_t a = UNPACK(*src, 8, 8);
  3911.  
  3912.      
  3913.          
  3914.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  3915.      
  3916.          
  3917.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  3918.      
  3919.          
  3920.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  3921.      
  3922.          
  3923.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3924. }
  3925.  
  3926. static inline void
  3927. unpack_ubyte_a8l8_srgb(const void *void_src, GLubyte dst[4])
  3928. {
  3929.    uint16_t *src = (uint16_t *)void_src;
  3930.             uint8_t a = UNPACK(*src, 0, 8);
  3931.             uint8_t l = UNPACK(*src, 8, 8);
  3932.  
  3933.      
  3934.          
  3935.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  3936.      
  3937.          
  3938.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  3939.      
  3940.          
  3941.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  3942.      
  3943.          
  3944.                dst[3] = _mesa_unorm_to_unorm(a, 8, 8);
  3945. }
  3946.  
  3947. static inline void
  3948. unpack_ubyte_l_srgb8(const void *void_src, GLubyte dst[4])
  3949. {
  3950.    uint8_t *src = (uint8_t *)void_src;
  3951.             uint8_t l = src[0];
  3952.  
  3953.      
  3954.          
  3955.                dst[0] = _mesa_unorm_to_unorm(l, 8, 8);
  3956.      
  3957.          
  3958.                dst[1] = _mesa_unorm_to_unorm(l, 8, 8);
  3959.      
  3960.          
  3961.                dst[2] = _mesa_unorm_to_unorm(l, 8, 8);
  3962.      
  3963.          dst[3] = 255;
  3964. }
  3965.  
  3966. static inline void
  3967. unpack_ubyte_bgr_srgb8(const void *void_src, GLubyte dst[4])
  3968. {
  3969.    uint8_t *src = (uint8_t *)void_src;
  3970.             uint8_t b = src[0];
  3971.             uint8_t g = src[1];
  3972.             uint8_t r = src[2];
  3973.  
  3974.      
  3975.          
  3976.                
  3977.                dst[0] = util_format_srgb_to_linear_8unorm(r);
  3978.      
  3979.          
  3980.                
  3981.                dst[1] = util_format_srgb_to_linear_8unorm(g);
  3982.      
  3983.          
  3984.                
  3985.                dst[2] = util_format_srgb_to_linear_8unorm(b);
  3986.      
  3987.          dst[3] = 255;
  3988. }
  3989.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  3990. /* integer packing functions */
  3991.  
  3992.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  3993. static inline void
  3994. unpack_int_b10g10r10a2_uint(const void *void_src, GLuint dst[4])
  3995. {
  3996.    uint32_t *src = (uint32_t *)void_src;
  3997.             uint16_t b = UNPACK(*src, 0, 10);
  3998.             uint16_t g = UNPACK(*src, 10, 10);
  3999.             uint16_t r = UNPACK(*src, 20, 10);
  4000.             uint8_t a = UNPACK(*src, 30, 2);
  4001.  
  4002.      
  4003.          dst[0] = r;
  4004.      
  4005.          dst[1] = g;
  4006.      
  4007.          dst[2] = b;
  4008.      
  4009.          dst[3] = a;
  4010. }
  4011.  
  4012. static inline void
  4013. unpack_int_r10g10b10a2_uint(const void *void_src, GLuint dst[4])
  4014. {
  4015.    uint32_t *src = (uint32_t *)void_src;
  4016.             uint16_t r = UNPACK(*src, 0, 10);
  4017.             uint16_t g = UNPACK(*src, 10, 10);
  4018.             uint16_t b = UNPACK(*src, 20, 10);
  4019.             uint8_t a = UNPACK(*src, 30, 2);
  4020.  
  4021.      
  4022.          dst[0] = r;
  4023.      
  4024.          dst[1] = g;
  4025.      
  4026.          dst[2] = b;
  4027.      
  4028.          dst[3] = a;
  4029. }
  4030.  
  4031. static inline void
  4032. unpack_int_a2b10g10r10_uint(const void *void_src, GLuint dst[4])
  4033. {
  4034.    uint32_t *src = (uint32_t *)void_src;
  4035.             uint8_t a = UNPACK(*src, 0, 2);
  4036.             uint16_t b = UNPACK(*src, 2, 10);
  4037.             uint16_t g = UNPACK(*src, 12, 10);
  4038.             uint16_t r = UNPACK(*src, 22, 10);
  4039.  
  4040.      
  4041.          dst[0] = r;
  4042.      
  4043.          dst[1] = g;
  4044.      
  4045.          dst[2] = b;
  4046.      
  4047.          dst[3] = a;
  4048. }
  4049.  
  4050. static inline void
  4051. unpack_int_a2r10g10b10_uint(const void *void_src, GLuint dst[4])
  4052. {
  4053.    uint32_t *src = (uint32_t *)void_src;
  4054.             uint8_t a = UNPACK(*src, 0, 2);
  4055.             uint16_t r = UNPACK(*src, 2, 10);
  4056.             uint16_t g = UNPACK(*src, 12, 10);
  4057.             uint16_t b = UNPACK(*src, 22, 10);
  4058.  
  4059.      
  4060.          dst[0] = r;
  4061.      
  4062.          dst[1] = g;
  4063.      
  4064.          dst[2] = b;
  4065.      
  4066.          dst[3] = a;
  4067. }
  4068.  
  4069. static inline void
  4070. unpack_int_a_uint8(const void *void_src, GLuint dst[4])
  4071. {
  4072.    uint8_t *src = (uint8_t *)void_src;
  4073.             uint8_t a = src[0];
  4074.  
  4075.      
  4076.          dst[0] = 0;
  4077.      
  4078.          dst[1] = 0;
  4079.      
  4080.          dst[2] = 0;
  4081.      
  4082.          dst[3] = a;
  4083. }
  4084.  
  4085. static inline void
  4086. unpack_int_a_uint16(const void *void_src, GLuint dst[4])
  4087. {
  4088.    uint16_t *src = (uint16_t *)void_src;
  4089.             uint16_t a = src[0];
  4090.  
  4091.      
  4092.          dst[0] = 0;
  4093.      
  4094.          dst[1] = 0;
  4095.      
  4096.          dst[2] = 0;
  4097.      
  4098.          dst[3] = a;
  4099. }
  4100.  
  4101. static inline void
  4102. unpack_int_a_uint32(const void *void_src, GLuint dst[4])
  4103. {
  4104.    uint32_t *src = (uint32_t *)void_src;
  4105.             uint32_t a = src[0];
  4106.  
  4107.      
  4108.          dst[0] = 0;
  4109.      
  4110.          dst[1] = 0;
  4111.      
  4112.          dst[2] = 0;
  4113.      
  4114.          dst[3] = a;
  4115. }
  4116.  
  4117. static inline void
  4118. unpack_int_a_sint8(const void *void_src, GLuint dst[4])
  4119. {
  4120.    int8_t *src = (int8_t *)void_src;
  4121.             int8_t a = src[0];
  4122.  
  4123.      
  4124.          dst[0] = 0;
  4125.      
  4126.          dst[1] = 0;
  4127.      
  4128.          dst[2] = 0;
  4129.      
  4130.          dst[3] = a;
  4131. }
  4132.  
  4133. static inline void
  4134. unpack_int_a_sint16(const void *void_src, GLuint dst[4])
  4135. {
  4136.    int16_t *src = (int16_t *)void_src;
  4137.             int16_t a = src[0];
  4138.  
  4139.      
  4140.          dst[0] = 0;
  4141.      
  4142.          dst[1] = 0;
  4143.      
  4144.          dst[2] = 0;
  4145.      
  4146.          dst[3] = a;
  4147. }
  4148.  
  4149. static inline void
  4150. unpack_int_a_sint32(const void *void_src, GLuint dst[4])
  4151. {
  4152.    int32_t *src = (int32_t *)void_src;
  4153.             int32_t a = src[0];
  4154.  
  4155.      
  4156.          dst[0] = 0;
  4157.      
  4158.          dst[1] = 0;
  4159.      
  4160.          dst[2] = 0;
  4161.      
  4162.          dst[3] = a;
  4163. }
  4164.  
  4165. static inline void
  4166. unpack_int_i_uint8(const void *void_src, GLuint dst[4])
  4167. {
  4168.    uint8_t *src = (uint8_t *)void_src;
  4169.             uint8_t i = src[0];
  4170.  
  4171.      
  4172.          dst[0] = i;
  4173.      
  4174.          dst[1] = i;
  4175.      
  4176.          dst[2] = i;
  4177.      
  4178.          dst[3] = i;
  4179. }
  4180.  
  4181. static inline void
  4182. unpack_int_i_uint16(const void *void_src, GLuint dst[4])
  4183. {
  4184.    uint16_t *src = (uint16_t *)void_src;
  4185.             uint16_t i = src[0];
  4186.  
  4187.      
  4188.          dst[0] = i;
  4189.      
  4190.          dst[1] = i;
  4191.      
  4192.          dst[2] = i;
  4193.      
  4194.          dst[3] = i;
  4195. }
  4196.  
  4197. static inline void
  4198. unpack_int_i_uint32(const void *void_src, GLuint dst[4])
  4199. {
  4200.    uint32_t *src = (uint32_t *)void_src;
  4201.             uint32_t i = src[0];
  4202.  
  4203.      
  4204.          dst[0] = i;
  4205.      
  4206.          dst[1] = i;
  4207.      
  4208.          dst[2] = i;
  4209.      
  4210.          dst[3] = i;
  4211. }
  4212.  
  4213. static inline void
  4214. unpack_int_i_sint8(const void *void_src, GLuint dst[4])
  4215. {
  4216.    int8_t *src = (int8_t *)void_src;
  4217.             int8_t i = src[0];
  4218.  
  4219.      
  4220.          dst[0] = i;
  4221.      
  4222.          dst[1] = i;
  4223.      
  4224.          dst[2] = i;
  4225.      
  4226.          dst[3] = i;
  4227. }
  4228.  
  4229. static inline void
  4230. unpack_int_i_sint16(const void *void_src, GLuint dst[4])
  4231. {
  4232.    int16_t *src = (int16_t *)void_src;
  4233.             int16_t i = src[0];
  4234.  
  4235.      
  4236.          dst[0] = i;
  4237.      
  4238.          dst[1] = i;
  4239.      
  4240.          dst[2] = i;
  4241.      
  4242.          dst[3] = i;
  4243. }
  4244.  
  4245. static inline void
  4246. unpack_int_i_sint32(const void *void_src, GLuint dst[4])
  4247. {
  4248.    int32_t *src = (int32_t *)void_src;
  4249.             int32_t i = src[0];
  4250.  
  4251.      
  4252.          dst[0] = i;
  4253.      
  4254.          dst[1] = i;
  4255.      
  4256.          dst[2] = i;
  4257.      
  4258.          dst[3] = i;
  4259. }
  4260.  
  4261. static inline void
  4262. unpack_int_l_uint8(const void *void_src, GLuint dst[4])
  4263. {
  4264.    uint8_t *src = (uint8_t *)void_src;
  4265.             uint8_t l = src[0];
  4266.  
  4267.      
  4268.          dst[0] = l;
  4269.      
  4270.          dst[1] = l;
  4271.      
  4272.          dst[2] = l;
  4273.      
  4274.          dst[3] = 1;
  4275. }
  4276.  
  4277. static inline void
  4278. unpack_int_l_uint16(const void *void_src, GLuint dst[4])
  4279. {
  4280.    uint16_t *src = (uint16_t *)void_src;
  4281.             uint16_t l = src[0];
  4282.  
  4283.      
  4284.          dst[0] = l;
  4285.      
  4286.          dst[1] = l;
  4287.      
  4288.          dst[2] = l;
  4289.      
  4290.          dst[3] = 1;
  4291. }
  4292.  
  4293. static inline void
  4294. unpack_int_l_uint32(const void *void_src, GLuint dst[4])
  4295. {
  4296.    uint32_t *src = (uint32_t *)void_src;
  4297.             uint32_t l = src[0];
  4298.  
  4299.      
  4300.          dst[0] = l;
  4301.      
  4302.          dst[1] = l;
  4303.      
  4304.          dst[2] = l;
  4305.      
  4306.          dst[3] = 1;
  4307. }
  4308.  
  4309. static inline void
  4310. unpack_int_l_sint8(const void *void_src, GLuint dst[4])
  4311. {
  4312.    int8_t *src = (int8_t *)void_src;
  4313.             int8_t l = src[0];
  4314.  
  4315.      
  4316.          dst[0] = l;
  4317.      
  4318.          dst[1] = l;
  4319.      
  4320.          dst[2] = l;
  4321.      
  4322.          dst[3] = 1;
  4323. }
  4324.  
  4325. static inline void
  4326. unpack_int_l_sint16(const void *void_src, GLuint dst[4])
  4327. {
  4328.    int16_t *src = (int16_t *)void_src;
  4329.             int16_t l = src[0];
  4330.  
  4331.      
  4332.          dst[0] = l;
  4333.      
  4334.          dst[1] = l;
  4335.      
  4336.          dst[2] = l;
  4337.      
  4338.          dst[3] = 1;
  4339. }
  4340.  
  4341. static inline void
  4342. unpack_int_l_sint32(const void *void_src, GLuint dst[4])
  4343. {
  4344.    int32_t *src = (int32_t *)void_src;
  4345.             int32_t l = src[0];
  4346.  
  4347.      
  4348.          dst[0] = l;
  4349.      
  4350.          dst[1] = l;
  4351.      
  4352.          dst[2] = l;
  4353.      
  4354.          dst[3] = 1;
  4355. }
  4356.  
  4357. static inline void
  4358. unpack_int_la_uint8(const void *void_src, GLuint dst[4])
  4359. {
  4360.    uint8_t *src = (uint8_t *)void_src;
  4361.             uint8_t l = src[0];
  4362.             uint8_t a = src[1];
  4363.  
  4364.      
  4365.          dst[0] = l;
  4366.      
  4367.          dst[1] = l;
  4368.      
  4369.          dst[2] = l;
  4370.      
  4371.          dst[3] = a;
  4372. }
  4373.  
  4374. static inline void
  4375. unpack_int_la_uint16(const void *void_src, GLuint dst[4])
  4376. {
  4377.    uint16_t *src = (uint16_t *)void_src;
  4378.             uint16_t l = src[0];
  4379.             uint16_t a = src[1];
  4380.  
  4381.      
  4382.          dst[0] = l;
  4383.      
  4384.          dst[1] = l;
  4385.      
  4386.          dst[2] = l;
  4387.      
  4388.          dst[3] = a;
  4389. }
  4390.  
  4391. static inline void
  4392. unpack_int_la_uint32(const void *void_src, GLuint dst[4])
  4393. {
  4394.    uint32_t *src = (uint32_t *)void_src;
  4395.             uint32_t l = src[0];
  4396.             uint32_t a = src[1];
  4397.  
  4398.      
  4399.          dst[0] = l;
  4400.      
  4401.          dst[1] = l;
  4402.      
  4403.          dst[2] = l;
  4404.      
  4405.          dst[3] = a;
  4406. }
  4407.  
  4408. static inline void
  4409. unpack_int_la_sint8(const void *void_src, GLuint dst[4])
  4410. {
  4411.    int8_t *src = (int8_t *)void_src;
  4412.             int8_t l = src[0];
  4413.             int8_t a = src[1];
  4414.  
  4415.      
  4416.          dst[0] = l;
  4417.      
  4418.          dst[1] = l;
  4419.      
  4420.          dst[2] = l;
  4421.      
  4422.          dst[3] = a;
  4423. }
  4424.  
  4425. static inline void
  4426. unpack_int_la_sint16(const void *void_src, GLuint dst[4])
  4427. {
  4428.    int16_t *src = (int16_t *)void_src;
  4429.             int16_t l = src[0];
  4430.             int16_t a = src[1];
  4431.  
  4432.      
  4433.          dst[0] = l;
  4434.      
  4435.          dst[1] = l;
  4436.      
  4437.          dst[2] = l;
  4438.      
  4439.          dst[3] = a;
  4440. }
  4441.  
  4442. static inline void
  4443. unpack_int_la_sint32(const void *void_src, GLuint dst[4])
  4444. {
  4445.    int32_t *src = (int32_t *)void_src;
  4446.             int32_t l = src[0];
  4447.             int32_t a = src[1];
  4448.  
  4449.      
  4450.          dst[0] = l;
  4451.      
  4452.          dst[1] = l;
  4453.      
  4454.          dst[2] = l;
  4455.      
  4456.          dst[3] = a;
  4457. }
  4458.  
  4459. static inline void
  4460. unpack_int_r_uint8(const void *void_src, GLuint dst[4])
  4461. {
  4462.    uint8_t *src = (uint8_t *)void_src;
  4463.             uint8_t r = src[0];
  4464.  
  4465.      
  4466.          dst[0] = r;
  4467.      
  4468.          dst[1] = 0;
  4469.      
  4470.          dst[2] = 0;
  4471.      
  4472.          dst[3] = 1;
  4473. }
  4474.  
  4475. static inline void
  4476. unpack_int_r_uint16(const void *void_src, GLuint dst[4])
  4477. {
  4478.    uint16_t *src = (uint16_t *)void_src;
  4479.             uint16_t r = src[0];
  4480.  
  4481.      
  4482.          dst[0] = r;
  4483.      
  4484.          dst[1] = 0;
  4485.      
  4486.          dst[2] = 0;
  4487.      
  4488.          dst[3] = 1;
  4489. }
  4490.  
  4491. static inline void
  4492. unpack_int_r_uint32(const void *void_src, GLuint dst[4])
  4493. {
  4494.    uint32_t *src = (uint32_t *)void_src;
  4495.             uint32_t r = src[0];
  4496.  
  4497.      
  4498.          dst[0] = r;
  4499.      
  4500.          dst[1] = 0;
  4501.      
  4502.          dst[2] = 0;
  4503.      
  4504.          dst[3] = 1;
  4505. }
  4506.  
  4507. static inline void
  4508. unpack_int_r_sint8(const void *void_src, GLuint dst[4])
  4509. {
  4510.    int8_t *src = (int8_t *)void_src;
  4511.             int8_t r = src[0];
  4512.  
  4513.      
  4514.          dst[0] = r;
  4515.      
  4516.          dst[1] = 0;
  4517.      
  4518.          dst[2] = 0;
  4519.      
  4520.          dst[3] = 1;
  4521. }
  4522.  
  4523. static inline void
  4524. unpack_int_r_sint16(const void *void_src, GLuint dst[4])
  4525. {
  4526.    int16_t *src = (int16_t *)void_src;
  4527.             int16_t r = src[0];
  4528.  
  4529.      
  4530.          dst[0] = r;
  4531.      
  4532.          dst[1] = 0;
  4533.      
  4534.          dst[2] = 0;
  4535.      
  4536.          dst[3] = 1;
  4537. }
  4538.  
  4539. static inline void
  4540. unpack_int_r_sint32(const void *void_src, GLuint dst[4])
  4541. {
  4542.    int32_t *src = (int32_t *)void_src;
  4543.             int32_t r = src[0];
  4544.  
  4545.      
  4546.          dst[0] = r;
  4547.      
  4548.          dst[1] = 0;
  4549.      
  4550.          dst[2] = 0;
  4551.      
  4552.          dst[3] = 1;
  4553. }
  4554.  
  4555. static inline void
  4556. unpack_int_rg_uint8(const void *void_src, GLuint dst[4])
  4557. {
  4558.    uint8_t *src = (uint8_t *)void_src;
  4559.             uint8_t r = src[0];
  4560.             uint8_t g = src[1];
  4561.  
  4562.      
  4563.          dst[0] = r;
  4564.      
  4565.          dst[1] = g;
  4566.      
  4567.          dst[2] = 0;
  4568.      
  4569.          dst[3] = 1;
  4570. }
  4571.  
  4572. static inline void
  4573. unpack_int_rg_uint16(const void *void_src, GLuint dst[4])
  4574. {
  4575.    uint16_t *src = (uint16_t *)void_src;
  4576.             uint16_t r = src[0];
  4577.             uint16_t g = src[1];
  4578.  
  4579.      
  4580.          dst[0] = r;
  4581.      
  4582.          dst[1] = g;
  4583.      
  4584.          dst[2] = 0;
  4585.      
  4586.          dst[3] = 1;
  4587. }
  4588.  
  4589. static inline void
  4590. unpack_int_rg_uint32(const void *void_src, GLuint dst[4])
  4591. {
  4592.    uint32_t *src = (uint32_t *)void_src;
  4593.             uint32_t r = src[0];
  4594.             uint32_t g = src[1];
  4595.  
  4596.      
  4597.          dst[0] = r;
  4598.      
  4599.          dst[1] = g;
  4600.      
  4601.          dst[2] = 0;
  4602.      
  4603.          dst[3] = 1;
  4604. }
  4605.  
  4606. static inline void
  4607. unpack_int_rg_sint8(const void *void_src, GLuint dst[4])
  4608. {
  4609.    int8_t *src = (int8_t *)void_src;
  4610.             int8_t r = src[0];
  4611.             int8_t g = src[1];
  4612.  
  4613.      
  4614.          dst[0] = r;
  4615.      
  4616.          dst[1] = g;
  4617.      
  4618.          dst[2] = 0;
  4619.      
  4620.          dst[3] = 1;
  4621. }
  4622.  
  4623. static inline void
  4624. unpack_int_rg_sint16(const void *void_src, GLuint dst[4])
  4625. {
  4626.    int16_t *src = (int16_t *)void_src;
  4627.             int16_t r = src[0];
  4628.             int16_t g = src[1];
  4629.  
  4630.      
  4631.          dst[0] = r;
  4632.      
  4633.          dst[1] = g;
  4634.      
  4635.          dst[2] = 0;
  4636.      
  4637.          dst[3] = 1;
  4638. }
  4639.  
  4640. static inline void
  4641. unpack_int_rg_sint32(const void *void_src, GLuint dst[4])
  4642. {
  4643.    int32_t *src = (int32_t *)void_src;
  4644.             int32_t r = src[0];
  4645.             int32_t g = src[1];
  4646.  
  4647.      
  4648.          dst[0] = r;
  4649.      
  4650.          dst[1] = g;
  4651.      
  4652.          dst[2] = 0;
  4653.      
  4654.          dst[3] = 1;
  4655. }
  4656.  
  4657. static inline void
  4658. unpack_int_rgb_uint8(const void *void_src, GLuint dst[4])
  4659. {
  4660.    uint8_t *src = (uint8_t *)void_src;
  4661.             uint8_t r = src[0];
  4662.             uint8_t g = src[1];
  4663.             uint8_t b = src[2];
  4664.  
  4665.      
  4666.          dst[0] = r;
  4667.      
  4668.          dst[1] = g;
  4669.      
  4670.          dst[2] = b;
  4671.      
  4672.          dst[3] = 1;
  4673. }
  4674.  
  4675. static inline void
  4676. unpack_int_rgb_uint16(const void *void_src, GLuint dst[4])
  4677. {
  4678.    uint16_t *src = (uint16_t *)void_src;
  4679.             uint16_t r = src[0];
  4680.             uint16_t g = src[1];
  4681.             uint16_t b = src[2];
  4682.  
  4683.      
  4684.          dst[0] = r;
  4685.      
  4686.          dst[1] = g;
  4687.      
  4688.          dst[2] = b;
  4689.      
  4690.          dst[3] = 1;
  4691. }
  4692.  
  4693. static inline void
  4694. unpack_int_rgb_uint32(const void *void_src, GLuint dst[4])
  4695. {
  4696.    uint32_t *src = (uint32_t *)void_src;
  4697.             uint32_t r = src[0];
  4698.             uint32_t g = src[1];
  4699.             uint32_t b = src[2];
  4700.  
  4701.      
  4702.          dst[0] = r;
  4703.      
  4704.          dst[1] = g;
  4705.      
  4706.          dst[2] = b;
  4707.      
  4708.          dst[3] = 1;
  4709. }
  4710.  
  4711. static inline void
  4712. unpack_int_rgb_sint8(const void *void_src, GLuint dst[4])
  4713. {
  4714.    int8_t *src = (int8_t *)void_src;
  4715.             int8_t r = src[0];
  4716.             int8_t g = src[1];
  4717.             int8_t b = src[2];
  4718.  
  4719.      
  4720.          dst[0] = r;
  4721.      
  4722.          dst[1] = g;
  4723.      
  4724.          dst[2] = b;
  4725.      
  4726.          dst[3] = 1;
  4727. }
  4728.  
  4729. static inline void
  4730. unpack_int_rgb_sint16(const void *void_src, GLuint dst[4])
  4731. {
  4732.    int16_t *src = (int16_t *)void_src;
  4733.             int16_t r = src[0];
  4734.             int16_t g = src[1];
  4735.             int16_t b = src[2];
  4736.  
  4737.      
  4738.          dst[0] = r;
  4739.      
  4740.          dst[1] = g;
  4741.      
  4742.          dst[2] = b;
  4743.      
  4744.          dst[3] = 1;
  4745. }
  4746.  
  4747. static inline void
  4748. unpack_int_rgb_sint32(const void *void_src, GLuint dst[4])
  4749. {
  4750.    int32_t *src = (int32_t *)void_src;
  4751.             int32_t r = src[0];
  4752.             int32_t g = src[1];
  4753.             int32_t b = src[2];
  4754.  
  4755.      
  4756.          dst[0] = r;
  4757.      
  4758.          dst[1] = g;
  4759.      
  4760.          dst[2] = b;
  4761.      
  4762.          dst[3] = 1;
  4763. }
  4764.  
  4765. static inline void
  4766. unpack_int_rgba_uint8(const void *void_src, GLuint dst[4])
  4767. {
  4768.    uint8_t *src = (uint8_t *)void_src;
  4769.             uint8_t r = src[0];
  4770.             uint8_t g = src[1];
  4771.             uint8_t b = src[2];
  4772.             uint8_t a = src[3];
  4773.  
  4774.      
  4775.          dst[0] = r;
  4776.      
  4777.          dst[1] = g;
  4778.      
  4779.          dst[2] = b;
  4780.      
  4781.          dst[3] = a;
  4782. }
  4783.  
  4784. static inline void
  4785. unpack_int_rgba_uint16(const void *void_src, GLuint dst[4])
  4786. {
  4787.    uint16_t *src = (uint16_t *)void_src;
  4788.             uint16_t r = src[0];
  4789.             uint16_t g = src[1];
  4790.             uint16_t b = src[2];
  4791.             uint16_t a = src[3];
  4792.  
  4793.      
  4794.          dst[0] = r;
  4795.      
  4796.          dst[1] = g;
  4797.      
  4798.          dst[2] = b;
  4799.      
  4800.          dst[3] = a;
  4801. }
  4802.  
  4803. static inline void
  4804. unpack_int_rgba_uint32(const void *void_src, GLuint dst[4])
  4805. {
  4806.    uint32_t *src = (uint32_t *)void_src;
  4807.             uint32_t r = src[0];
  4808.             uint32_t g = src[1];
  4809.             uint32_t b = src[2];
  4810.             uint32_t a = src[3];
  4811.  
  4812.      
  4813.          dst[0] = r;
  4814.      
  4815.          dst[1] = g;
  4816.      
  4817.          dst[2] = b;
  4818.      
  4819.          dst[3] = a;
  4820. }
  4821.  
  4822. static inline void
  4823. unpack_int_rgba_sint8(const void *void_src, GLuint dst[4])
  4824. {
  4825.    int8_t *src = (int8_t *)void_src;
  4826.             int8_t r = src[0];
  4827.             int8_t g = src[1];
  4828.             int8_t b = src[2];
  4829.             int8_t a = src[3];
  4830.  
  4831.      
  4832.          dst[0] = r;
  4833.      
  4834.          dst[1] = g;
  4835.      
  4836.          dst[2] = b;
  4837.      
  4838.          dst[3] = a;
  4839. }
  4840.  
  4841. static inline void
  4842. unpack_int_rgba_sint16(const void *void_src, GLuint dst[4])
  4843. {
  4844.    int16_t *src = (int16_t *)void_src;
  4845.             int16_t r = src[0];
  4846.             int16_t g = src[1];
  4847.             int16_t b = src[2];
  4848.             int16_t a = src[3];
  4849.  
  4850.      
  4851.          dst[0] = r;
  4852.      
  4853.          dst[1] = g;
  4854.      
  4855.          dst[2] = b;
  4856.      
  4857.          dst[3] = a;
  4858. }
  4859.  
  4860. static inline void
  4861. unpack_int_rgba_sint32(const void *void_src, GLuint dst[4])
  4862. {
  4863.    int32_t *src = (int32_t *)void_src;
  4864.             int32_t r = src[0];
  4865.             int32_t g = src[1];
  4866.             int32_t b = src[2];
  4867.             int32_t a = src[3];
  4868.  
  4869.      
  4870.          dst[0] = r;
  4871.      
  4872.          dst[1] = g;
  4873.      
  4874.          dst[2] = b;
  4875.      
  4876.          dst[3] = a;
  4877. }
  4878.  
  4879. static inline void
  4880. unpack_int_rgbx_uint8(const void *void_src, GLuint dst[4])
  4881. {
  4882.    uint8_t *src = (uint8_t *)void_src;
  4883.             uint8_t r = src[0];
  4884.             uint8_t g = src[1];
  4885.             uint8_t b = src[2];
  4886.  
  4887.      
  4888.          dst[0] = r;
  4889.      
  4890.          dst[1] = g;
  4891.      
  4892.          dst[2] = b;
  4893.      
  4894.          dst[3] = 1;
  4895. }
  4896.  
  4897. static inline void
  4898. unpack_int_rgbx_uint16(const void *void_src, GLuint dst[4])
  4899. {
  4900.    uint16_t *src = (uint16_t *)void_src;
  4901.             uint16_t r = src[0];
  4902.             uint16_t g = src[1];
  4903.             uint16_t b = src[2];
  4904.  
  4905.      
  4906.          dst[0] = r;
  4907.      
  4908.          dst[1] = g;
  4909.      
  4910.          dst[2] = b;
  4911.      
  4912.          dst[3] = 1;
  4913. }
  4914.  
  4915. static inline void
  4916. unpack_int_rgbx_uint32(const void *void_src, GLuint dst[4])
  4917. {
  4918.    uint32_t *src = (uint32_t *)void_src;
  4919.             uint32_t r = src[0];
  4920.             uint32_t g = src[1];
  4921.             uint32_t b = src[2];
  4922.  
  4923.      
  4924.          dst[0] = r;
  4925.      
  4926.          dst[1] = g;
  4927.      
  4928.          dst[2] = b;
  4929.      
  4930.          dst[3] = 1;
  4931. }
  4932.  
  4933. static inline void
  4934. unpack_int_rgbx_sint8(const void *void_src, GLuint dst[4])
  4935. {
  4936.    int8_t *src = (int8_t *)void_src;
  4937.             int8_t r = src[0];
  4938.             int8_t g = src[1];
  4939.             int8_t b = src[2];
  4940.  
  4941.      
  4942.          dst[0] = r;
  4943.      
  4944.          dst[1] = g;
  4945.      
  4946.          dst[2] = b;
  4947.      
  4948.          dst[3] = 1;
  4949. }
  4950.  
  4951. static inline void
  4952. unpack_int_rgbx_sint16(const void *void_src, GLuint dst[4])
  4953. {
  4954.    int16_t *src = (int16_t *)void_src;
  4955.             int16_t r = src[0];
  4956.             int16_t g = src[1];
  4957.             int16_t b = src[2];
  4958.  
  4959.      
  4960.          dst[0] = r;
  4961.      
  4962.          dst[1] = g;
  4963.      
  4964.          dst[2] = b;
  4965.      
  4966.          dst[3] = 1;
  4967. }
  4968.  
  4969. static inline void
  4970. unpack_int_rgbx_sint32(const void *void_src, GLuint dst[4])
  4971. {
  4972.    int32_t *src = (int32_t *)void_src;
  4973.             int32_t r = src[0];
  4974.             int32_t g = src[1];
  4975.             int32_t b = src[2];
  4976.  
  4977.      
  4978.          dst[0] = r;
  4979.      
  4980.          dst[1] = g;
  4981.      
  4982.          dst[2] = b;
  4983.      
  4984.          dst[3] = 1;
  4985. }
  4986.                                                                                                                                                                                                      
  4987.  
  4988. void
  4989. _mesa_unpack_rgba_row(mesa_format format, GLuint n,
  4990.                       const void *src, GLfloat dst[][4])
  4991. {
  4992.    GLubyte *s = (GLubyte *)src;
  4993.    GLuint i;
  4994.  
  4995.    switch (format) {
  4996.    case MESA_FORMAT_A8B8G8R8_UNORM:
  4997.       for (i = 0; i < n; ++i) {
  4998.          unpack_float_a8b8g8r8_unorm(s, dst[i]);
  4999.          s += 4;
  5000.       }
  5001.       break;
  5002.    case MESA_FORMAT_X8B8G8R8_UNORM:
  5003.       for (i = 0; i < n; ++i) {
  5004.          unpack_float_x8b8g8r8_unorm(s, dst[i]);
  5005.          s += 4;
  5006.       }
  5007.       break;
  5008.    case MESA_FORMAT_R8G8B8A8_UNORM:
  5009.       for (i = 0; i < n; ++i) {
  5010.          unpack_float_r8g8b8a8_unorm(s, dst[i]);
  5011.          s += 4;
  5012.       }
  5013.       break;
  5014.    case MESA_FORMAT_R8G8B8X8_UNORM:
  5015.       for (i = 0; i < n; ++i) {
  5016.          unpack_float_r8g8b8x8_unorm(s, dst[i]);
  5017.          s += 4;
  5018.       }
  5019.       break;
  5020.    case MESA_FORMAT_B8G8R8A8_UNORM:
  5021.       for (i = 0; i < n; ++i) {
  5022.          unpack_float_b8g8r8a8_unorm(s, dst[i]);
  5023.          s += 4;
  5024.       }
  5025.       break;
  5026.    case MESA_FORMAT_B8G8R8X8_UNORM:
  5027.       for (i = 0; i < n; ++i) {
  5028.          unpack_float_b8g8r8x8_unorm(s, dst[i]);
  5029.          s += 4;
  5030.       }
  5031.       break;
  5032.    case MESA_FORMAT_A8R8G8B8_UNORM:
  5033.       for (i = 0; i < n; ++i) {
  5034.          unpack_float_a8r8g8b8_unorm(s, dst[i]);
  5035.          s += 4;
  5036.       }
  5037.       break;
  5038.    case MESA_FORMAT_X8R8G8B8_UNORM:
  5039.       for (i = 0; i < n; ++i) {
  5040.          unpack_float_x8r8g8b8_unorm(s, dst[i]);
  5041.          s += 4;
  5042.       }
  5043.       break;
  5044.    case MESA_FORMAT_L16A16_UNORM:
  5045.       for (i = 0; i < n; ++i) {
  5046.          unpack_float_l16a16_unorm(s, dst[i]);
  5047.          s += 4;
  5048.       }
  5049.       break;
  5050.    case MESA_FORMAT_A16L16_UNORM:
  5051.       for (i = 0; i < n; ++i) {
  5052.          unpack_float_a16l16_unorm(s, dst[i]);
  5053.          s += 4;
  5054.       }
  5055.       break;
  5056.    case MESA_FORMAT_B5G6R5_UNORM:
  5057.       for (i = 0; i < n; ++i) {
  5058.          unpack_float_b5g6r5_unorm(s, dst[i]);
  5059.          s += 2;
  5060.       }
  5061.       break;
  5062.    case MESA_FORMAT_R5G6B5_UNORM:
  5063.       for (i = 0; i < n; ++i) {
  5064.          unpack_float_r5g6b5_unorm(s, dst[i]);
  5065.          s += 2;
  5066.       }
  5067.       break;
  5068.    case MESA_FORMAT_B4G4R4A4_UNORM:
  5069.       for (i = 0; i < n; ++i) {
  5070.          unpack_float_b4g4r4a4_unorm(s, dst[i]);
  5071.          s += 2;
  5072.       }
  5073.       break;
  5074.    case MESA_FORMAT_B4G4R4X4_UNORM:
  5075.       for (i = 0; i < n; ++i) {
  5076.          unpack_float_b4g4r4x4_unorm(s, dst[i]);
  5077.          s += 2;
  5078.       }
  5079.       break;
  5080.    case MESA_FORMAT_A4R4G4B4_UNORM:
  5081.       for (i = 0; i < n; ++i) {
  5082.          unpack_float_a4r4g4b4_unorm(s, dst[i]);
  5083.          s += 2;
  5084.       }
  5085.       break;
  5086.    case MESA_FORMAT_A1B5G5R5_UNORM:
  5087.       for (i = 0; i < n; ++i) {
  5088.          unpack_float_a1b5g5r5_unorm(s, dst[i]);
  5089.          s += 2;
  5090.       }
  5091.       break;
  5092.    case MESA_FORMAT_B5G5R5A1_UNORM:
  5093.       for (i = 0; i < n; ++i) {
  5094.          unpack_float_b5g5r5a1_unorm(s, dst[i]);
  5095.          s += 2;
  5096.       }
  5097.       break;
  5098.    case MESA_FORMAT_B5G5R5X1_UNORM:
  5099.       for (i = 0; i < n; ++i) {
  5100.          unpack_float_b5g5r5x1_unorm(s, dst[i]);
  5101.          s += 2;
  5102.       }
  5103.       break;
  5104.    case MESA_FORMAT_A1R5G5B5_UNORM:
  5105.       for (i = 0; i < n; ++i) {
  5106.          unpack_float_a1r5g5b5_unorm(s, dst[i]);
  5107.          s += 2;
  5108.       }
  5109.       break;
  5110.    case MESA_FORMAT_L8A8_UNORM:
  5111.       for (i = 0; i < n; ++i) {
  5112.          unpack_float_l8a8_unorm(s, dst[i]);
  5113.          s += 2;
  5114.       }
  5115.       break;
  5116.    case MESA_FORMAT_A8L8_UNORM:
  5117.       for (i = 0; i < n; ++i) {
  5118.          unpack_float_a8l8_unorm(s, dst[i]);
  5119.          s += 2;
  5120.       }
  5121.       break;
  5122.    case MESA_FORMAT_R8G8_UNORM:
  5123.       for (i = 0; i < n; ++i) {
  5124.          unpack_float_r8g8_unorm(s, dst[i]);
  5125.          s += 2;
  5126.       }
  5127.       break;
  5128.    case MESA_FORMAT_G8R8_UNORM:
  5129.       for (i = 0; i < n; ++i) {
  5130.          unpack_float_g8r8_unorm(s, dst[i]);
  5131.          s += 2;
  5132.       }
  5133.       break;
  5134.    case MESA_FORMAT_L4A4_UNORM:
  5135.       for (i = 0; i < n; ++i) {
  5136.          unpack_float_l4a4_unorm(s, dst[i]);
  5137.          s += 1;
  5138.       }
  5139.       break;
  5140.    case MESA_FORMAT_B2G3R3_UNORM:
  5141.       for (i = 0; i < n; ++i) {
  5142.          unpack_float_b2g3r3_unorm(s, dst[i]);
  5143.          s += 1;
  5144.       }
  5145.       break;
  5146.    case MESA_FORMAT_R16G16_UNORM:
  5147.       for (i = 0; i < n; ++i) {
  5148.          unpack_float_r16g16_unorm(s, dst[i]);
  5149.          s += 4;
  5150.       }
  5151.       break;
  5152.    case MESA_FORMAT_G16R16_UNORM:
  5153.       for (i = 0; i < n; ++i) {
  5154.          unpack_float_g16r16_unorm(s, dst[i]);
  5155.          s += 4;
  5156.       }
  5157.       break;
  5158.    case MESA_FORMAT_B10G10R10A2_UNORM:
  5159.       for (i = 0; i < n; ++i) {
  5160.          unpack_float_b10g10r10a2_unorm(s, dst[i]);
  5161.          s += 4;
  5162.       }
  5163.       break;
  5164.    case MESA_FORMAT_B10G10R10X2_UNORM:
  5165.       for (i = 0; i < n; ++i) {
  5166.          unpack_float_b10g10r10x2_unorm(s, dst[i]);
  5167.          s += 4;
  5168.       }
  5169.       break;
  5170.    case MESA_FORMAT_R10G10B10A2_UNORM:
  5171.       for (i = 0; i < n; ++i) {
  5172.          unpack_float_r10g10b10a2_unorm(s, dst[i]);
  5173.          s += 4;
  5174.       }
  5175.       break;
  5176.    case MESA_FORMAT_R10G10B10X2_UNORM:
  5177.       for (i = 0; i < n; ++i) {
  5178.          unpack_float_r10g10b10x2_unorm(s, dst[i]);
  5179.          s += 4;
  5180.       }
  5181.       break;
  5182.    case MESA_FORMAT_R3G3B2_UNORM:
  5183.       for (i = 0; i < n; ++i) {
  5184.          unpack_float_r3g3b2_unorm(s, dst[i]);
  5185.          s += 1;
  5186.       }
  5187.       break;
  5188.    case MESA_FORMAT_A4B4G4R4_UNORM:
  5189.       for (i = 0; i < n; ++i) {
  5190.          unpack_float_a4b4g4r4_unorm(s, dst[i]);
  5191.          s += 2;
  5192.       }
  5193.       break;
  5194.    case MESA_FORMAT_R4G4B4A4_UNORM:
  5195.       for (i = 0; i < n; ++i) {
  5196.          unpack_float_r4g4b4a4_unorm(s, dst[i]);
  5197.          s += 2;
  5198.       }
  5199.       break;
  5200.    case MESA_FORMAT_R5G5B5A1_UNORM:
  5201.       for (i = 0; i < n; ++i) {
  5202.          unpack_float_r5g5b5a1_unorm(s, dst[i]);
  5203.          s += 2;
  5204.       }
  5205.       break;
  5206.    case MESA_FORMAT_A2B10G10R10_UNORM:
  5207.       for (i = 0; i < n; ++i) {
  5208.          unpack_float_a2b10g10r10_unorm(s, dst[i]);
  5209.          s += 4;
  5210.       }
  5211.       break;
  5212.    case MESA_FORMAT_A2R10G10B10_UNORM:
  5213.       for (i = 0; i < n; ++i) {
  5214.          unpack_float_a2r10g10b10_unorm(s, dst[i]);
  5215.          s += 4;
  5216.       }
  5217.       break;
  5218.    case MESA_FORMAT_A_UNORM8:
  5219.       for (i = 0; i < n; ++i) {
  5220.          unpack_float_a_unorm8(s, dst[i]);
  5221.          s += 1;
  5222.       }
  5223.       break;
  5224.    case MESA_FORMAT_A_UNORM16:
  5225.       for (i = 0; i < n; ++i) {
  5226.          unpack_float_a_unorm16(s, dst[i]);
  5227.          s += 2;
  5228.       }
  5229.       break;
  5230.    case MESA_FORMAT_L_UNORM8:
  5231.       for (i = 0; i < n; ++i) {
  5232.          unpack_float_l_unorm8(s, dst[i]);
  5233.          s += 1;
  5234.       }
  5235.       break;
  5236.    case MESA_FORMAT_L_UNORM16:
  5237.       for (i = 0; i < n; ++i) {
  5238.          unpack_float_l_unorm16(s, dst[i]);
  5239.          s += 2;
  5240.       }
  5241.       break;
  5242.    case MESA_FORMAT_I_UNORM8:
  5243.       for (i = 0; i < n; ++i) {
  5244.          unpack_float_i_unorm8(s, dst[i]);
  5245.          s += 1;
  5246.       }
  5247.       break;
  5248.    case MESA_FORMAT_I_UNORM16:
  5249.       for (i = 0; i < n; ++i) {
  5250.          unpack_float_i_unorm16(s, dst[i]);
  5251.          s += 2;
  5252.       }
  5253.       break;
  5254.    case MESA_FORMAT_R_UNORM8:
  5255.       for (i = 0; i < n; ++i) {
  5256.          unpack_float_r_unorm8(s, dst[i]);
  5257.          s += 1;
  5258.       }
  5259.       break;
  5260.    case MESA_FORMAT_R_UNORM16:
  5261.       for (i = 0; i < n; ++i) {
  5262.          unpack_float_r_unorm16(s, dst[i]);
  5263.          s += 2;
  5264.       }
  5265.       break;
  5266.    case MESA_FORMAT_BGR_UNORM8:
  5267.       for (i = 0; i < n; ++i) {
  5268.          unpack_float_bgr_unorm8(s, dst[i]);
  5269.          s += 3;
  5270.       }
  5271.       break;
  5272.    case MESA_FORMAT_RGB_UNORM8:
  5273.       for (i = 0; i < n; ++i) {
  5274.          unpack_float_rgb_unorm8(s, dst[i]);
  5275.          s += 3;
  5276.       }
  5277.       break;
  5278.    case MESA_FORMAT_RGBA_UNORM16:
  5279.       for (i = 0; i < n; ++i) {
  5280.          unpack_float_rgba_unorm16(s, dst[i]);
  5281.          s += 8;
  5282.       }
  5283.       break;
  5284.    case MESA_FORMAT_RGBX_UNORM16:
  5285.       for (i = 0; i < n; ++i) {
  5286.          unpack_float_rgbx_unorm16(s, dst[i]);
  5287.          s += 8;
  5288.       }
  5289.       break;
  5290.    case MESA_FORMAT_A8B8G8R8_SNORM:
  5291.       for (i = 0; i < n; ++i) {
  5292.          unpack_float_a8b8g8r8_snorm(s, dst[i]);
  5293.          s += 4;
  5294.       }
  5295.       break;
  5296.    case MESA_FORMAT_X8B8G8R8_SNORM:
  5297.       for (i = 0; i < n; ++i) {
  5298.          unpack_float_x8b8g8r8_snorm(s, dst[i]);
  5299.          s += 4;
  5300.       }
  5301.       break;
  5302.    case MESA_FORMAT_R8G8B8A8_SNORM:
  5303.       for (i = 0; i < n; ++i) {
  5304.          unpack_float_r8g8b8a8_snorm(s, dst[i]);
  5305.          s += 4;
  5306.       }
  5307.       break;
  5308.    case MESA_FORMAT_R8G8B8X8_SNORM:
  5309.       for (i = 0; i < n; ++i) {
  5310.          unpack_float_r8g8b8x8_snorm(s, dst[i]);
  5311.          s += 4;
  5312.       }
  5313.       break;
  5314.    case MESA_FORMAT_R16G16_SNORM:
  5315.       for (i = 0; i < n; ++i) {
  5316.          unpack_float_r16g16_snorm(s, dst[i]);
  5317.          s += 4;
  5318.       }
  5319.       break;
  5320.    case MESA_FORMAT_G16R16_SNORM:
  5321.       for (i = 0; i < n; ++i) {
  5322.          unpack_float_g16r16_snorm(s, dst[i]);
  5323.          s += 4;
  5324.       }
  5325.       break;
  5326.    case MESA_FORMAT_R8G8_SNORM:
  5327.       for (i = 0; i < n; ++i) {
  5328.          unpack_float_r8g8_snorm(s, dst[i]);
  5329.          s += 2;
  5330.       }
  5331.       break;
  5332.    case MESA_FORMAT_G8R8_SNORM:
  5333.       for (i = 0; i < n; ++i) {
  5334.          unpack_float_g8r8_snorm(s, dst[i]);
  5335.          s += 2;
  5336.       }
  5337.       break;
  5338.    case MESA_FORMAT_L8A8_SNORM:
  5339.       for (i = 0; i < n; ++i) {
  5340.          unpack_float_l8a8_snorm(s, dst[i]);
  5341.          s += 2;
  5342.       }
  5343.       break;
  5344.    case MESA_FORMAT_A8L8_SNORM:
  5345.       for (i = 0; i < n; ++i) {
  5346.          unpack_float_a8l8_snorm(s, dst[i]);
  5347.          s += 2;
  5348.       }
  5349.       break;
  5350.    case MESA_FORMAT_A_SNORM8:
  5351.       for (i = 0; i < n; ++i) {
  5352.          unpack_float_a_snorm8(s, dst[i]);
  5353.          s += 1;
  5354.       }
  5355.       break;
  5356.    case MESA_FORMAT_A_SNORM16:
  5357.       for (i = 0; i < n; ++i) {
  5358.          unpack_float_a_snorm16(s, dst[i]);
  5359.          s += 2;
  5360.       }
  5361.       break;
  5362.    case MESA_FORMAT_L_SNORM8:
  5363.       for (i = 0; i < n; ++i) {
  5364.          unpack_float_l_snorm8(s, dst[i]);
  5365.          s += 1;
  5366.       }
  5367.       break;
  5368.    case MESA_FORMAT_L_SNORM16:
  5369.       for (i = 0; i < n; ++i) {
  5370.          unpack_float_l_snorm16(s, dst[i]);
  5371.          s += 2;
  5372.       }
  5373.       break;
  5374.    case MESA_FORMAT_I_SNORM8:
  5375.       for (i = 0; i < n; ++i) {
  5376.          unpack_float_i_snorm8(s, dst[i]);
  5377.          s += 1;
  5378.       }
  5379.       break;
  5380.    case MESA_FORMAT_I_SNORM16:
  5381.       for (i = 0; i < n; ++i) {
  5382.          unpack_float_i_snorm16(s, dst[i]);
  5383.          s += 2;
  5384.       }
  5385.       break;
  5386.    case MESA_FORMAT_R_SNORM8:
  5387.       for (i = 0; i < n; ++i) {
  5388.          unpack_float_r_snorm8(s, dst[i]);
  5389.          s += 1;
  5390.       }
  5391.       break;
  5392.    case MESA_FORMAT_R_SNORM16:
  5393.       for (i = 0; i < n; ++i) {
  5394.          unpack_float_r_snorm16(s, dst[i]);
  5395.          s += 2;
  5396.       }
  5397.       break;
  5398.    case MESA_FORMAT_LA_SNORM16:
  5399.       for (i = 0; i < n; ++i) {
  5400.          unpack_float_la_snorm16(s, dst[i]);
  5401.          s += 4;
  5402.       }
  5403.       break;
  5404.    case MESA_FORMAT_RGB_SNORM16:
  5405.       for (i = 0; i < n; ++i) {
  5406.          unpack_float_rgb_snorm16(s, dst[i]);
  5407.          s += 6;
  5408.       }
  5409.       break;
  5410.    case MESA_FORMAT_RGBA_SNORM16:
  5411.       for (i = 0; i < n; ++i) {
  5412.          unpack_float_rgba_snorm16(s, dst[i]);
  5413.          s += 8;
  5414.       }
  5415.       break;
  5416.    case MESA_FORMAT_RGBX_SNORM16:
  5417.       for (i = 0; i < n; ++i) {
  5418.          unpack_float_rgbx_snorm16(s, dst[i]);
  5419.          s += 8;
  5420.       }
  5421.       break;
  5422.    case MESA_FORMAT_A8B8G8R8_SRGB:
  5423.       for (i = 0; i < n; ++i) {
  5424.          unpack_float_a8b8g8r8_srgb(s, dst[i]);
  5425.          s += 4;
  5426.       }
  5427.       break;
  5428.    case MESA_FORMAT_B8G8R8A8_SRGB:
  5429.       for (i = 0; i < n; ++i) {
  5430.          unpack_float_b8g8r8a8_srgb(s, dst[i]);
  5431.          s += 4;
  5432.       }
  5433.       break;
  5434.    case MESA_FORMAT_A8R8G8B8_SRGB:
  5435.       for (i = 0; i < n; ++i) {
  5436.          unpack_float_a8r8g8b8_srgb(s, dst[i]);
  5437.          s += 4;
  5438.       }
  5439.       break;
  5440.    case MESA_FORMAT_B8G8R8X8_SRGB:
  5441.       for (i = 0; i < n; ++i) {
  5442.          unpack_float_b8g8r8x8_srgb(s, dst[i]);
  5443.          s += 4;
  5444.       }
  5445.       break;
  5446.    case MESA_FORMAT_X8R8G8B8_SRGB:
  5447.       for (i = 0; i < n; ++i) {
  5448.          unpack_float_x8r8g8b8_srgb(s, dst[i]);
  5449.          s += 4;
  5450.       }
  5451.       break;
  5452.    case MESA_FORMAT_R8G8B8A8_SRGB:
  5453.       for (i = 0; i < n; ++i) {
  5454.          unpack_float_r8g8b8a8_srgb(s, dst[i]);
  5455.          s += 4;
  5456.       }
  5457.       break;
  5458.    case MESA_FORMAT_R8G8B8X8_SRGB:
  5459.       for (i = 0; i < n; ++i) {
  5460.          unpack_float_r8g8b8x8_srgb(s, dst[i]);
  5461.          s += 4;
  5462.       }
  5463.       break;
  5464.    case MESA_FORMAT_X8B8G8R8_SRGB:
  5465.       for (i = 0; i < n; ++i) {
  5466.          unpack_float_x8b8g8r8_srgb(s, dst[i]);
  5467.          s += 4;
  5468.       }
  5469.       break;
  5470.    case MESA_FORMAT_L8A8_SRGB:
  5471.       for (i = 0; i < n; ++i) {
  5472.          unpack_float_l8a8_srgb(s, dst[i]);
  5473.          s += 2;
  5474.       }
  5475.       break;
  5476.    case MESA_FORMAT_A8L8_SRGB:
  5477.       for (i = 0; i < n; ++i) {
  5478.          unpack_float_a8l8_srgb(s, dst[i]);
  5479.          s += 2;
  5480.       }
  5481.       break;
  5482.    case MESA_FORMAT_L_SRGB8:
  5483.       for (i = 0; i < n; ++i) {
  5484.          unpack_float_l_srgb8(s, dst[i]);
  5485.          s += 1;
  5486.       }
  5487.       break;
  5488.    case MESA_FORMAT_BGR_SRGB8:
  5489.       for (i = 0; i < n; ++i) {
  5490.          unpack_float_bgr_srgb8(s, dst[i]);
  5491.          s += 3;
  5492.       }
  5493.       break;
  5494.    case MESA_FORMAT_R9G9B9E5_FLOAT:
  5495.       for (i = 0; i < n; ++i) {
  5496.          unpack_float_r9g9b9e5_float(s, dst[i]);
  5497.          s += 4;
  5498.       }
  5499.       break;
  5500.    case MESA_FORMAT_R11G11B10_FLOAT:
  5501.       for (i = 0; i < n; ++i) {
  5502.          unpack_float_r11g11b10_float(s, dst[i]);
  5503.          s += 4;
  5504.       }
  5505.       break;
  5506.    case MESA_FORMAT_A_FLOAT16:
  5507.       for (i = 0; i < n; ++i) {
  5508.          unpack_float_a_float16(s, dst[i]);
  5509.          s += 2;
  5510.       }
  5511.       break;
  5512.    case MESA_FORMAT_A_FLOAT32:
  5513.       for (i = 0; i < n; ++i) {
  5514.          unpack_float_a_float32(s, dst[i]);
  5515.          s += 4;
  5516.       }
  5517.       break;
  5518.    case MESA_FORMAT_L_FLOAT16:
  5519.       for (i = 0; i < n; ++i) {
  5520.          unpack_float_l_float16(s, dst[i]);
  5521.          s += 2;
  5522.       }
  5523.       break;
  5524.    case MESA_FORMAT_L_FLOAT32:
  5525.       for (i = 0; i < n; ++i) {
  5526.          unpack_float_l_float32(s, dst[i]);
  5527.          s += 4;
  5528.       }
  5529.       break;
  5530.    case MESA_FORMAT_LA_FLOAT16:
  5531.       for (i = 0; i < n; ++i) {
  5532.          unpack_float_la_float16(s, dst[i]);
  5533.          s += 4;
  5534.       }
  5535.       break;
  5536.    case MESA_FORMAT_LA_FLOAT32:
  5537.       for (i = 0; i < n; ++i) {
  5538.          unpack_float_la_float32(s, dst[i]);
  5539.          s += 8;
  5540.       }
  5541.       break;
  5542.    case MESA_FORMAT_I_FLOAT16:
  5543.       for (i = 0; i < n; ++i) {
  5544.          unpack_float_i_float16(s, dst[i]);
  5545.          s += 2;
  5546.       }
  5547.       break;
  5548.    case MESA_FORMAT_I_FLOAT32:
  5549.       for (i = 0; i < n; ++i) {
  5550.          unpack_float_i_float32(s, dst[i]);
  5551.          s += 4;
  5552.       }
  5553.       break;
  5554.    case MESA_FORMAT_R_FLOAT16:
  5555.       for (i = 0; i < n; ++i) {
  5556.          unpack_float_r_float16(s, dst[i]);
  5557.          s += 2;
  5558.       }
  5559.       break;
  5560.    case MESA_FORMAT_R_FLOAT32:
  5561.       for (i = 0; i < n; ++i) {
  5562.          unpack_float_r_float32(s, dst[i]);
  5563.          s += 4;
  5564.       }
  5565.       break;
  5566.    case MESA_FORMAT_RG_FLOAT16:
  5567.       for (i = 0; i < n; ++i) {
  5568.          unpack_float_rg_float16(s, dst[i]);
  5569.          s += 4;
  5570.       }
  5571.       break;
  5572.    case MESA_FORMAT_RG_FLOAT32:
  5573.       for (i = 0; i < n; ++i) {
  5574.          unpack_float_rg_float32(s, dst[i]);
  5575.          s += 8;
  5576.       }
  5577.       break;
  5578.    case MESA_FORMAT_RGB_FLOAT16:
  5579.       for (i = 0; i < n; ++i) {
  5580.          unpack_float_rgb_float16(s, dst[i]);
  5581.          s += 6;
  5582.       }
  5583.       break;
  5584.    case MESA_FORMAT_RGB_FLOAT32:
  5585.       for (i = 0; i < n; ++i) {
  5586.          unpack_float_rgb_float32(s, dst[i]);
  5587.          s += 12;
  5588.       }
  5589.       break;
  5590.    case MESA_FORMAT_RGBA_FLOAT16:
  5591.       for (i = 0; i < n; ++i) {
  5592.          unpack_float_rgba_float16(s, dst[i]);
  5593.          s += 8;
  5594.       }
  5595.       break;
  5596.    case MESA_FORMAT_RGBA_FLOAT32:
  5597.       for (i = 0; i < n; ++i) {
  5598.          unpack_float_rgba_float32(s, dst[i]);
  5599.          s += 16;
  5600.       }
  5601.       break;
  5602.    case MESA_FORMAT_RGBX_FLOAT16:
  5603.       for (i = 0; i < n; ++i) {
  5604.          unpack_float_rgbx_float16(s, dst[i]);
  5605.          s += 8;
  5606.       }
  5607.       break;
  5608.    case MESA_FORMAT_RGBX_FLOAT32:
  5609.       for (i = 0; i < n; ++i) {
  5610.          unpack_float_rgbx_float32(s, dst[i]);
  5611.          s += 16;
  5612.       }
  5613.       break;
  5614.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      case MESA_FORMAT_YCBCR:
  5615.       unpack_float_ycbcr(src, dst, n);
  5616.       break;
  5617.    case MESA_FORMAT_YCBCR_REV:
  5618.       unpack_float_ycbcr_rev(src, dst, n);
  5619.       break;
  5620.    default:
  5621.       _mesa_problem(NULL, "%s: bad format %s", __func__,
  5622.                     _mesa_get_format_name(format));
  5623.       return;
  5624.    }
  5625. }
  5626.  
  5627. void
  5628. _mesa_unpack_ubyte_rgba_row(mesa_format format, GLuint n,
  5629.                             const void *src, GLubyte dst[][4])
  5630. {
  5631.    GLubyte *s = (GLubyte *)src;
  5632.    GLuint i;
  5633.  
  5634.    switch (format) {
  5635.  
  5636.    case MESA_FORMAT_A8B8G8R8_UNORM:
  5637.       for (i = 0; i < n; ++i) {
  5638.          unpack_ubyte_a8b8g8r8_unorm(s, dst[i]);
  5639.          s += 4;
  5640.       }
  5641.       break;
  5642.  
  5643.    case MESA_FORMAT_X8B8G8R8_UNORM:
  5644.       for (i = 0; i < n; ++i) {
  5645.          unpack_ubyte_x8b8g8r8_unorm(s, dst[i]);
  5646.          s += 4;
  5647.       }
  5648.       break;
  5649.  
  5650.    case MESA_FORMAT_R8G8B8A8_UNORM:
  5651.       for (i = 0; i < n; ++i) {
  5652.          unpack_ubyte_r8g8b8a8_unorm(s, dst[i]);
  5653.          s += 4;
  5654.       }
  5655.       break;
  5656.  
  5657.    case MESA_FORMAT_R8G8B8X8_UNORM:
  5658.       for (i = 0; i < n; ++i) {
  5659.          unpack_ubyte_r8g8b8x8_unorm(s, dst[i]);
  5660.          s += 4;
  5661.       }
  5662.       break;
  5663.  
  5664.    case MESA_FORMAT_B8G8R8A8_UNORM:
  5665.       for (i = 0; i < n; ++i) {
  5666.          unpack_ubyte_b8g8r8a8_unorm(s, dst[i]);
  5667.          s += 4;
  5668.       }
  5669.       break;
  5670.  
  5671.    case MESA_FORMAT_B8G8R8X8_UNORM:
  5672.       for (i = 0; i < n; ++i) {
  5673.          unpack_ubyte_b8g8r8x8_unorm(s, dst[i]);
  5674.          s += 4;
  5675.       }
  5676.       break;
  5677.  
  5678.    case MESA_FORMAT_A8R8G8B8_UNORM:
  5679.       for (i = 0; i < n; ++i) {
  5680.          unpack_ubyte_a8r8g8b8_unorm(s, dst[i]);
  5681.          s += 4;
  5682.       }
  5683.       break;
  5684.  
  5685.    case MESA_FORMAT_X8R8G8B8_UNORM:
  5686.       for (i = 0; i < n; ++i) {
  5687.          unpack_ubyte_x8r8g8b8_unorm(s, dst[i]);
  5688.          s += 4;
  5689.       }
  5690.       break;
  5691.  
  5692.    case MESA_FORMAT_L16A16_UNORM:
  5693.       for (i = 0; i < n; ++i) {
  5694.          unpack_ubyte_l16a16_unorm(s, dst[i]);
  5695.          s += 4;
  5696.       }
  5697.       break;
  5698.  
  5699.    case MESA_FORMAT_A16L16_UNORM:
  5700.       for (i = 0; i < n; ++i) {
  5701.          unpack_ubyte_a16l16_unorm(s, dst[i]);
  5702.          s += 4;
  5703.       }
  5704.       break;
  5705.  
  5706.    case MESA_FORMAT_B5G6R5_UNORM:
  5707.       for (i = 0; i < n; ++i) {
  5708.          unpack_ubyte_b5g6r5_unorm(s, dst[i]);
  5709.          s += 2;
  5710.       }
  5711.       break;
  5712.  
  5713.    case MESA_FORMAT_R5G6B5_UNORM:
  5714.       for (i = 0; i < n; ++i) {
  5715.          unpack_ubyte_r5g6b5_unorm(s, dst[i]);
  5716.          s += 2;
  5717.       }
  5718.       break;
  5719.  
  5720.    case MESA_FORMAT_B4G4R4A4_UNORM:
  5721.       for (i = 0; i < n; ++i) {
  5722.          unpack_ubyte_b4g4r4a4_unorm(s, dst[i]);
  5723.          s += 2;
  5724.       }
  5725.       break;
  5726.  
  5727.    case MESA_FORMAT_B4G4R4X4_UNORM:
  5728.       for (i = 0; i < n; ++i) {
  5729.          unpack_ubyte_b4g4r4x4_unorm(s, dst[i]);
  5730.          s += 2;
  5731.       }
  5732.       break;
  5733.  
  5734.    case MESA_FORMAT_A4R4G4B4_UNORM:
  5735.       for (i = 0; i < n; ++i) {
  5736.          unpack_ubyte_a4r4g4b4_unorm(s, dst[i]);
  5737.          s += 2;
  5738.       }
  5739.       break;
  5740.  
  5741.    case MESA_FORMAT_A1B5G5R5_UNORM:
  5742.       for (i = 0; i < n; ++i) {
  5743.          unpack_ubyte_a1b5g5r5_unorm(s, dst[i]);
  5744.          s += 2;
  5745.       }
  5746.       break;
  5747.  
  5748.    case MESA_FORMAT_B5G5R5A1_UNORM:
  5749.       for (i = 0; i < n; ++i) {
  5750.          unpack_ubyte_b5g5r5a1_unorm(s, dst[i]);
  5751.          s += 2;
  5752.       }
  5753.       break;
  5754.  
  5755.    case MESA_FORMAT_B5G5R5X1_UNORM:
  5756.       for (i = 0; i < n; ++i) {
  5757.          unpack_ubyte_b5g5r5x1_unorm(s, dst[i]);
  5758.          s += 2;
  5759.       }
  5760.       break;
  5761.  
  5762.    case MESA_FORMAT_A1R5G5B5_UNORM:
  5763.       for (i = 0; i < n; ++i) {
  5764.          unpack_ubyte_a1r5g5b5_unorm(s, dst[i]);
  5765.          s += 2;
  5766.       }
  5767.       break;
  5768.  
  5769.    case MESA_FORMAT_L8A8_UNORM:
  5770.       for (i = 0; i < n; ++i) {
  5771.          unpack_ubyte_l8a8_unorm(s, dst[i]);
  5772.          s += 2;
  5773.       }
  5774.       break;
  5775.  
  5776.    case MESA_FORMAT_A8L8_UNORM:
  5777.       for (i = 0; i < n; ++i) {
  5778.          unpack_ubyte_a8l8_unorm(s, dst[i]);
  5779.          s += 2;
  5780.       }
  5781.       break;
  5782.  
  5783.    case MESA_FORMAT_R8G8_UNORM:
  5784.       for (i = 0; i < n; ++i) {
  5785.          unpack_ubyte_r8g8_unorm(s, dst[i]);
  5786.          s += 2;
  5787.       }
  5788.       break;
  5789.  
  5790.    case MESA_FORMAT_G8R8_UNORM:
  5791.       for (i = 0; i < n; ++i) {
  5792.          unpack_ubyte_g8r8_unorm(s, dst[i]);
  5793.          s += 2;
  5794.       }
  5795.       break;
  5796.  
  5797.    case MESA_FORMAT_L4A4_UNORM:
  5798.       for (i = 0; i < n; ++i) {
  5799.          unpack_ubyte_l4a4_unorm(s, dst[i]);
  5800.          s += 1;
  5801.       }
  5802.       break;
  5803.  
  5804.    case MESA_FORMAT_B2G3R3_UNORM:
  5805.       for (i = 0; i < n; ++i) {
  5806.          unpack_ubyte_b2g3r3_unorm(s, dst[i]);
  5807.          s += 1;
  5808.       }
  5809.       break;
  5810.  
  5811.    case MESA_FORMAT_R16G16_UNORM:
  5812.       for (i = 0; i < n; ++i) {
  5813.          unpack_ubyte_r16g16_unorm(s, dst[i]);
  5814.          s += 4;
  5815.       }
  5816.       break;
  5817.  
  5818.    case MESA_FORMAT_G16R16_UNORM:
  5819.       for (i = 0; i < n; ++i) {
  5820.          unpack_ubyte_g16r16_unorm(s, dst[i]);
  5821.          s += 4;
  5822.       }
  5823.       break;
  5824.  
  5825.    case MESA_FORMAT_B10G10R10A2_UNORM:
  5826.       for (i = 0; i < n; ++i) {
  5827.          unpack_ubyte_b10g10r10a2_unorm(s, dst[i]);
  5828.          s += 4;
  5829.       }
  5830.       break;
  5831.  
  5832.    case MESA_FORMAT_B10G10R10X2_UNORM:
  5833.       for (i = 0; i < n; ++i) {
  5834.          unpack_ubyte_b10g10r10x2_unorm(s, dst[i]);
  5835.          s += 4;
  5836.       }
  5837.       break;
  5838.  
  5839.    case MESA_FORMAT_R10G10B10A2_UNORM:
  5840.       for (i = 0; i < n; ++i) {
  5841.          unpack_ubyte_r10g10b10a2_unorm(s, dst[i]);
  5842.          s += 4;
  5843.       }
  5844.       break;
  5845.  
  5846.    case MESA_FORMAT_R10G10B10X2_UNORM:
  5847.       for (i = 0; i < n; ++i) {
  5848.          unpack_ubyte_r10g10b10x2_unorm(s, dst[i]);
  5849.          s += 4;
  5850.       }
  5851.       break;
  5852.  
  5853.    case MESA_FORMAT_R3G3B2_UNORM:
  5854.       for (i = 0; i < n; ++i) {
  5855.          unpack_ubyte_r3g3b2_unorm(s, dst[i]);
  5856.          s += 1;
  5857.       }
  5858.       break;
  5859.  
  5860.    case MESA_FORMAT_A4B4G4R4_UNORM:
  5861.       for (i = 0; i < n; ++i) {
  5862.          unpack_ubyte_a4b4g4r4_unorm(s, dst[i]);
  5863.          s += 2;
  5864.       }
  5865.       break;
  5866.  
  5867.    case MESA_FORMAT_R4G4B4A4_UNORM:
  5868.       for (i = 0; i < n; ++i) {
  5869.          unpack_ubyte_r4g4b4a4_unorm(s, dst[i]);
  5870.          s += 2;
  5871.       }
  5872.       break;
  5873.  
  5874.    case MESA_FORMAT_R5G5B5A1_UNORM:
  5875.       for (i = 0; i < n; ++i) {
  5876.          unpack_ubyte_r5g5b5a1_unorm(s, dst[i]);
  5877.          s += 2;
  5878.       }
  5879.       break;
  5880.  
  5881.    case MESA_FORMAT_A2B10G10R10_UNORM:
  5882.       for (i = 0; i < n; ++i) {
  5883.          unpack_ubyte_a2b10g10r10_unorm(s, dst[i]);
  5884.          s += 4;
  5885.       }
  5886.       break;
  5887.  
  5888.    case MESA_FORMAT_A2R10G10B10_UNORM:
  5889.       for (i = 0; i < n; ++i) {
  5890.          unpack_ubyte_a2r10g10b10_unorm(s, dst[i]);
  5891.          s += 4;
  5892.       }
  5893.       break;
  5894.  
  5895.    case MESA_FORMAT_A_UNORM8:
  5896.       for (i = 0; i < n; ++i) {
  5897.          unpack_ubyte_a_unorm8(s, dst[i]);
  5898.          s += 1;
  5899.       }
  5900.       break;
  5901.  
  5902.    case MESA_FORMAT_A_UNORM16:
  5903.       for (i = 0; i < n; ++i) {
  5904.          unpack_ubyte_a_unorm16(s, dst[i]);
  5905.          s += 2;
  5906.       }
  5907.       break;
  5908.  
  5909.    case MESA_FORMAT_L_UNORM8:
  5910.       for (i = 0; i < n; ++i) {
  5911.          unpack_ubyte_l_unorm8(s, dst[i]);
  5912.          s += 1;
  5913.       }
  5914.       break;
  5915.  
  5916.    case MESA_FORMAT_L_UNORM16:
  5917.       for (i = 0; i < n; ++i) {
  5918.          unpack_ubyte_l_unorm16(s, dst[i]);
  5919.          s += 2;
  5920.       }
  5921.       break;
  5922.  
  5923.    case MESA_FORMAT_I_UNORM8:
  5924.       for (i = 0; i < n; ++i) {
  5925.          unpack_ubyte_i_unorm8(s, dst[i]);
  5926.          s += 1;
  5927.       }
  5928.       break;
  5929.  
  5930.    case MESA_FORMAT_I_UNORM16:
  5931.       for (i = 0; i < n; ++i) {
  5932.          unpack_ubyte_i_unorm16(s, dst[i]);
  5933.          s += 2;
  5934.       }
  5935.       break;
  5936.  
  5937.    case MESA_FORMAT_R_UNORM8:
  5938.       for (i = 0; i < n; ++i) {
  5939.          unpack_ubyte_r_unorm8(s, dst[i]);
  5940.          s += 1;
  5941.       }
  5942.       break;
  5943.  
  5944.    case MESA_FORMAT_R_UNORM16:
  5945.       for (i = 0; i < n; ++i) {
  5946.          unpack_ubyte_r_unorm16(s, dst[i]);
  5947.          s += 2;
  5948.       }
  5949.       break;
  5950.  
  5951.    case MESA_FORMAT_BGR_UNORM8:
  5952.       for (i = 0; i < n; ++i) {
  5953.          unpack_ubyte_bgr_unorm8(s, dst[i]);
  5954.          s += 3;
  5955.       }
  5956.       break;
  5957.  
  5958.    case MESA_FORMAT_RGB_UNORM8:
  5959.       for (i = 0; i < n; ++i) {
  5960.          unpack_ubyte_rgb_unorm8(s, dst[i]);
  5961.          s += 3;
  5962.       }
  5963.       break;
  5964.  
  5965.    case MESA_FORMAT_RGBA_UNORM16:
  5966.       for (i = 0; i < n; ++i) {
  5967.          unpack_ubyte_rgba_unorm16(s, dst[i]);
  5968.          s += 8;
  5969.       }
  5970.       break;
  5971.  
  5972.    case MESA_FORMAT_RGBX_UNORM16:
  5973.       for (i = 0; i < n; ++i) {
  5974.          unpack_ubyte_rgbx_unorm16(s, dst[i]);
  5975.          s += 8;
  5976.       }
  5977.       break;
  5978.  
  5979.    case MESA_FORMAT_A8B8G8R8_SNORM:
  5980.       for (i = 0; i < n; ++i) {
  5981.          unpack_ubyte_a8b8g8r8_snorm(s, dst[i]);
  5982.          s += 4;
  5983.       }
  5984.       break;
  5985.  
  5986.    case MESA_FORMAT_X8B8G8R8_SNORM:
  5987.       for (i = 0; i < n; ++i) {
  5988.          unpack_ubyte_x8b8g8r8_snorm(s, dst[i]);
  5989.          s += 4;
  5990.       }
  5991.       break;
  5992.  
  5993.    case MESA_FORMAT_R8G8B8A8_SNORM:
  5994.       for (i = 0; i < n; ++i) {
  5995.          unpack_ubyte_r8g8b8a8_snorm(s, dst[i]);
  5996.          s += 4;
  5997.       }
  5998.       break;
  5999.  
  6000.    case MESA_FORMAT_R8G8B8X8_SNORM:
  6001.       for (i = 0; i < n; ++i) {
  6002.          unpack_ubyte_r8g8b8x8_snorm(s, dst[i]);
  6003.          s += 4;
  6004.       }
  6005.       break;
  6006.  
  6007.    case MESA_FORMAT_R16G16_SNORM:
  6008.       for (i = 0; i < n; ++i) {
  6009.          unpack_ubyte_r16g16_snorm(s, dst[i]);
  6010.          s += 4;
  6011.       }
  6012.       break;
  6013.  
  6014.    case MESA_FORMAT_G16R16_SNORM:
  6015.       for (i = 0; i < n; ++i) {
  6016.          unpack_ubyte_g16r16_snorm(s, dst[i]);
  6017.          s += 4;
  6018.       }
  6019.       break;
  6020.  
  6021.    case MESA_FORMAT_R8G8_SNORM:
  6022.       for (i = 0; i < n; ++i) {
  6023.          unpack_ubyte_r8g8_snorm(s, dst[i]);
  6024.          s += 2;
  6025.       }
  6026.       break;
  6027.  
  6028.    case MESA_FORMAT_G8R8_SNORM:
  6029.       for (i = 0; i < n; ++i) {
  6030.          unpack_ubyte_g8r8_snorm(s, dst[i]);
  6031.          s += 2;
  6032.       }
  6033.       break;
  6034.  
  6035.    case MESA_FORMAT_L8A8_SNORM:
  6036.       for (i = 0; i < n; ++i) {
  6037.          unpack_ubyte_l8a8_snorm(s, dst[i]);
  6038.          s += 2;
  6039.       }
  6040.       break;
  6041.  
  6042.    case MESA_FORMAT_A8L8_SNORM:
  6043.       for (i = 0; i < n; ++i) {
  6044.          unpack_ubyte_a8l8_snorm(s, dst[i]);
  6045.          s += 2;
  6046.       }
  6047.       break;
  6048.  
  6049.    case MESA_FORMAT_A_SNORM8:
  6050.       for (i = 0; i < n; ++i) {
  6051.          unpack_ubyte_a_snorm8(s, dst[i]);
  6052.          s += 1;
  6053.       }
  6054.       break;
  6055.  
  6056.    case MESA_FORMAT_A_SNORM16:
  6057.       for (i = 0; i < n; ++i) {
  6058.          unpack_ubyte_a_snorm16(s, dst[i]);
  6059.          s += 2;
  6060.       }
  6061.       break;
  6062.  
  6063.    case MESA_FORMAT_L_SNORM8:
  6064.       for (i = 0; i < n; ++i) {
  6065.          unpack_ubyte_l_snorm8(s, dst[i]);
  6066.          s += 1;
  6067.       }
  6068.       break;
  6069.  
  6070.    case MESA_FORMAT_L_SNORM16:
  6071.       for (i = 0; i < n; ++i) {
  6072.          unpack_ubyte_l_snorm16(s, dst[i]);
  6073.          s += 2;
  6074.       }
  6075.       break;
  6076.  
  6077.    case MESA_FORMAT_I_SNORM8:
  6078.       for (i = 0; i < n; ++i) {
  6079.          unpack_ubyte_i_snorm8(s, dst[i]);
  6080.          s += 1;
  6081.       }
  6082.       break;
  6083.  
  6084.    case MESA_FORMAT_I_SNORM16:
  6085.       for (i = 0; i < n; ++i) {
  6086.          unpack_ubyte_i_snorm16(s, dst[i]);
  6087.          s += 2;
  6088.       }
  6089.       break;
  6090.  
  6091.    case MESA_FORMAT_R_SNORM8:
  6092.       for (i = 0; i < n; ++i) {
  6093.          unpack_ubyte_r_snorm8(s, dst[i]);
  6094.          s += 1;
  6095.       }
  6096.       break;
  6097.  
  6098.    case MESA_FORMAT_R_SNORM16:
  6099.       for (i = 0; i < n; ++i) {
  6100.          unpack_ubyte_r_snorm16(s, dst[i]);
  6101.          s += 2;
  6102.       }
  6103.       break;
  6104.  
  6105.    case MESA_FORMAT_LA_SNORM16:
  6106.       for (i = 0; i < n; ++i) {
  6107.          unpack_ubyte_la_snorm16(s, dst[i]);
  6108.          s += 4;
  6109.       }
  6110.       break;
  6111.  
  6112.    case MESA_FORMAT_RGB_SNORM16:
  6113.       for (i = 0; i < n; ++i) {
  6114.          unpack_ubyte_rgb_snorm16(s, dst[i]);
  6115.          s += 6;
  6116.       }
  6117.       break;
  6118.  
  6119.    case MESA_FORMAT_RGBA_SNORM16:
  6120.       for (i = 0; i < n; ++i) {
  6121.          unpack_ubyte_rgba_snorm16(s, dst[i]);
  6122.          s += 8;
  6123.       }
  6124.       break;
  6125.  
  6126.    case MESA_FORMAT_RGBX_SNORM16:
  6127.       for (i = 0; i < n; ++i) {
  6128.          unpack_ubyte_rgbx_snorm16(s, dst[i]);
  6129.          s += 8;
  6130.       }
  6131.       break;
  6132.  
  6133.    case MESA_FORMAT_A8B8G8R8_SRGB:
  6134.       for (i = 0; i < n; ++i) {
  6135.          unpack_ubyte_a8b8g8r8_srgb(s, dst[i]);
  6136.          s += 4;
  6137.       }
  6138.       break;
  6139.  
  6140.    case MESA_FORMAT_B8G8R8A8_SRGB:
  6141.       for (i = 0; i < n; ++i) {
  6142.          unpack_ubyte_b8g8r8a8_srgb(s, dst[i]);
  6143.          s += 4;
  6144.       }
  6145.       break;
  6146.  
  6147.    case MESA_FORMAT_A8R8G8B8_SRGB:
  6148.       for (i = 0; i < n; ++i) {
  6149.          unpack_ubyte_a8r8g8b8_srgb(s, dst[i]);
  6150.          s += 4;
  6151.       }
  6152.       break;
  6153.  
  6154.    case MESA_FORMAT_B8G8R8X8_SRGB:
  6155.       for (i = 0; i < n; ++i) {
  6156.          unpack_ubyte_b8g8r8x8_srgb(s, dst[i]);
  6157.          s += 4;
  6158.       }
  6159.       break;
  6160.  
  6161.    case MESA_FORMAT_X8R8G8B8_SRGB:
  6162.       for (i = 0; i < n; ++i) {
  6163.          unpack_ubyte_x8r8g8b8_srgb(s, dst[i]);
  6164.          s += 4;
  6165.       }
  6166.       break;
  6167.  
  6168.    case MESA_FORMAT_R8G8B8A8_SRGB:
  6169.       for (i = 0; i < n; ++i) {
  6170.          unpack_ubyte_r8g8b8a8_srgb(s, dst[i]);
  6171.          s += 4;
  6172.       }
  6173.       break;
  6174.  
  6175.    case MESA_FORMAT_R8G8B8X8_SRGB:
  6176.       for (i = 0; i < n; ++i) {
  6177.          unpack_ubyte_r8g8b8x8_srgb(s, dst[i]);
  6178.          s += 4;
  6179.       }
  6180.       break;
  6181.  
  6182.    case MESA_FORMAT_X8B8G8R8_SRGB:
  6183.       for (i = 0; i < n; ++i) {
  6184.          unpack_ubyte_x8b8g8r8_srgb(s, dst[i]);
  6185.          s += 4;
  6186.       }
  6187.       break;
  6188.  
  6189.    case MESA_FORMAT_L8A8_SRGB:
  6190.       for (i = 0; i < n; ++i) {
  6191.          unpack_ubyte_l8a8_srgb(s, dst[i]);
  6192.          s += 2;
  6193.       }
  6194.       break;
  6195.  
  6196.    case MESA_FORMAT_A8L8_SRGB:
  6197.       for (i = 0; i < n; ++i) {
  6198.          unpack_ubyte_a8l8_srgb(s, dst[i]);
  6199.          s += 2;
  6200.       }
  6201.       break;
  6202.  
  6203.    case MESA_FORMAT_L_SRGB8:
  6204.       for (i = 0; i < n; ++i) {
  6205.          unpack_ubyte_l_srgb8(s, dst[i]);
  6206.          s += 1;
  6207.       }
  6208.       break;
  6209.  
  6210.    case MESA_FORMAT_BGR_SRGB8:
  6211.       for (i = 0; i < n; ++i) {
  6212.          unpack_ubyte_bgr_srgb8(s, dst[i]);
  6213.          s += 3;
  6214.       }
  6215.       break;
  6216.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              default:
  6217.       /* get float values, convert to ubyte */
  6218.       {
  6219.          GLfloat *tmp = malloc(n * 4 * sizeof(GLfloat));
  6220.          if (tmp) {
  6221.             GLuint i;
  6222.             _mesa_unpack_rgba_row(format, n, src, (GLfloat (*)[4]) tmp);
  6223.             for (i = 0; i < n; i++) {
  6224.                dst[i][0] = _mesa_float_to_unorm(tmp[i*4+0], 8);
  6225.                dst[i][1] = _mesa_float_to_unorm(tmp[i*4+1], 8);
  6226.                dst[i][2] = _mesa_float_to_unorm(tmp[i*4+2], 8);
  6227.                dst[i][3] = _mesa_float_to_unorm(tmp[i*4+3], 8);
  6228.             }
  6229.             free(tmp);
  6230.          }
  6231.       }
  6232.       break;
  6233.    }
  6234. }
  6235.  
  6236. void
  6237. _mesa_unpack_uint_rgba_row(mesa_format format, GLuint n,
  6238.                            const void *src, GLuint dst[][4])
  6239. {
  6240.    GLubyte *s = (GLubyte *)src;
  6241.    GLuint i;
  6242.  
  6243.    switch (format) {
  6244.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  6245.    case MESA_FORMAT_B10G10R10A2_UINT:
  6246.       for (i = 0; i < n; ++i) {
  6247.          unpack_int_b10g10r10a2_uint(s, dst[i]);
  6248.          s += 4;
  6249.       }
  6250.       break;
  6251.  
  6252.    case MESA_FORMAT_R10G10B10A2_UINT:
  6253.       for (i = 0; i < n; ++i) {
  6254.          unpack_int_r10g10b10a2_uint(s, dst[i]);
  6255.          s += 4;
  6256.       }
  6257.       break;
  6258.  
  6259.    case MESA_FORMAT_A2B10G10R10_UINT:
  6260.       for (i = 0; i < n; ++i) {
  6261.          unpack_int_a2b10g10r10_uint(s, dst[i]);
  6262.          s += 4;
  6263.       }
  6264.       break;
  6265.  
  6266.    case MESA_FORMAT_A2R10G10B10_UINT:
  6267.       for (i = 0; i < n; ++i) {
  6268.          unpack_int_a2r10g10b10_uint(s, dst[i]);
  6269.          s += 4;
  6270.       }
  6271.       break;
  6272.  
  6273.    case MESA_FORMAT_A_UINT8:
  6274.       for (i = 0; i < n; ++i) {
  6275.          unpack_int_a_uint8(s, dst[i]);
  6276.          s += 1;
  6277.       }
  6278.       break;
  6279.  
  6280.    case MESA_FORMAT_A_UINT16:
  6281.       for (i = 0; i < n; ++i) {
  6282.          unpack_int_a_uint16(s, dst[i]);
  6283.          s += 2;
  6284.       }
  6285.       break;
  6286.  
  6287.    case MESA_FORMAT_A_UINT32:
  6288.       for (i = 0; i < n; ++i) {
  6289.          unpack_int_a_uint32(s, dst[i]);
  6290.          s += 4;
  6291.       }
  6292.       break;
  6293.  
  6294.    case MESA_FORMAT_A_SINT8:
  6295.       for (i = 0; i < n; ++i) {
  6296.          unpack_int_a_sint8(s, dst[i]);
  6297.          s += 1;
  6298.       }
  6299.       break;
  6300.  
  6301.    case MESA_FORMAT_A_SINT16:
  6302.       for (i = 0; i < n; ++i) {
  6303.          unpack_int_a_sint16(s, dst[i]);
  6304.          s += 2;
  6305.       }
  6306.       break;
  6307.  
  6308.    case MESA_FORMAT_A_SINT32:
  6309.       for (i = 0; i < n; ++i) {
  6310.          unpack_int_a_sint32(s, dst[i]);
  6311.          s += 4;
  6312.       }
  6313.       break;
  6314.  
  6315.    case MESA_FORMAT_I_UINT8:
  6316.       for (i = 0; i < n; ++i) {
  6317.          unpack_int_i_uint8(s, dst[i]);
  6318.          s += 1;
  6319.       }
  6320.       break;
  6321.  
  6322.    case MESA_FORMAT_I_UINT16:
  6323.       for (i = 0; i < n; ++i) {
  6324.          unpack_int_i_uint16(s, dst[i]);
  6325.          s += 2;
  6326.       }
  6327.       break;
  6328.  
  6329.    case MESA_FORMAT_I_UINT32:
  6330.       for (i = 0; i < n; ++i) {
  6331.          unpack_int_i_uint32(s, dst[i]);
  6332.          s += 4;
  6333.       }
  6334.       break;
  6335.  
  6336.    case MESA_FORMAT_I_SINT8:
  6337.       for (i = 0; i < n; ++i) {
  6338.          unpack_int_i_sint8(s, dst[i]);
  6339.          s += 1;
  6340.       }
  6341.       break;
  6342.  
  6343.    case MESA_FORMAT_I_SINT16:
  6344.       for (i = 0; i < n; ++i) {
  6345.          unpack_int_i_sint16(s, dst[i]);
  6346.          s += 2;
  6347.       }
  6348.       break;
  6349.  
  6350.    case MESA_FORMAT_I_SINT32:
  6351.       for (i = 0; i < n; ++i) {
  6352.          unpack_int_i_sint32(s, dst[i]);
  6353.          s += 4;
  6354.       }
  6355.       break;
  6356.  
  6357.    case MESA_FORMAT_L_UINT8:
  6358.       for (i = 0; i < n; ++i) {
  6359.          unpack_int_l_uint8(s, dst[i]);
  6360.          s += 1;
  6361.       }
  6362.       break;
  6363.  
  6364.    case MESA_FORMAT_L_UINT16:
  6365.       for (i = 0; i < n; ++i) {
  6366.          unpack_int_l_uint16(s, dst[i]);
  6367.          s += 2;
  6368.       }
  6369.       break;
  6370.  
  6371.    case MESA_FORMAT_L_UINT32:
  6372.       for (i = 0; i < n; ++i) {
  6373.          unpack_int_l_uint32(s, dst[i]);
  6374.          s += 4;
  6375.       }
  6376.       break;
  6377.  
  6378.    case MESA_FORMAT_L_SINT8:
  6379.       for (i = 0; i < n; ++i) {
  6380.          unpack_int_l_sint8(s, dst[i]);
  6381.          s += 1;
  6382.       }
  6383.       break;
  6384.  
  6385.    case MESA_FORMAT_L_SINT16:
  6386.       for (i = 0; i < n; ++i) {
  6387.          unpack_int_l_sint16(s, dst[i]);
  6388.          s += 2;
  6389.       }
  6390.       break;
  6391.  
  6392.    case MESA_FORMAT_L_SINT32:
  6393.       for (i = 0; i < n; ++i) {
  6394.          unpack_int_l_sint32(s, dst[i]);
  6395.          s += 4;
  6396.       }
  6397.       break;
  6398.  
  6399.    case MESA_FORMAT_LA_UINT8:
  6400.       for (i = 0; i < n; ++i) {
  6401.          unpack_int_la_uint8(s, dst[i]);
  6402.          s += 2;
  6403.       }
  6404.       break;
  6405.  
  6406.    case MESA_FORMAT_LA_UINT16:
  6407.       for (i = 0; i < n; ++i) {
  6408.          unpack_int_la_uint16(s, dst[i]);
  6409.          s += 4;
  6410.       }
  6411.       break;
  6412.  
  6413.    case MESA_FORMAT_LA_UINT32:
  6414.       for (i = 0; i < n; ++i) {
  6415.          unpack_int_la_uint32(s, dst[i]);
  6416.          s += 8;
  6417.       }
  6418.       break;
  6419.  
  6420.    case MESA_FORMAT_LA_SINT8:
  6421.       for (i = 0; i < n; ++i) {
  6422.          unpack_int_la_sint8(s, dst[i]);
  6423.          s += 2;
  6424.       }
  6425.       break;
  6426.  
  6427.    case MESA_FORMAT_LA_SINT16:
  6428.       for (i = 0; i < n; ++i) {
  6429.          unpack_int_la_sint16(s, dst[i]);
  6430.          s += 4;
  6431.       }
  6432.       break;
  6433.  
  6434.    case MESA_FORMAT_LA_SINT32:
  6435.       for (i = 0; i < n; ++i) {
  6436.          unpack_int_la_sint32(s, dst[i]);
  6437.          s += 8;
  6438.       }
  6439.       break;
  6440.  
  6441.    case MESA_FORMAT_R_UINT8:
  6442.       for (i = 0; i < n; ++i) {
  6443.          unpack_int_r_uint8(s, dst[i]);
  6444.          s += 1;
  6445.       }
  6446.       break;
  6447.  
  6448.    case MESA_FORMAT_R_UINT16:
  6449.       for (i = 0; i < n; ++i) {
  6450.          unpack_int_r_uint16(s, dst[i]);
  6451.          s += 2;
  6452.       }
  6453.       break;
  6454.  
  6455.    case MESA_FORMAT_R_UINT32:
  6456.       for (i = 0; i < n; ++i) {
  6457.          unpack_int_r_uint32(s, dst[i]);
  6458.          s += 4;
  6459.       }
  6460.       break;
  6461.  
  6462.    case MESA_FORMAT_R_SINT8:
  6463.       for (i = 0; i < n; ++i) {
  6464.          unpack_int_r_sint8(s, dst[i]);
  6465.          s += 1;
  6466.       }
  6467.       break;
  6468.  
  6469.    case MESA_FORMAT_R_SINT16:
  6470.       for (i = 0; i < n; ++i) {
  6471.          unpack_int_r_sint16(s, dst[i]);
  6472.          s += 2;
  6473.       }
  6474.       break;
  6475.  
  6476.    case MESA_FORMAT_R_SINT32:
  6477.       for (i = 0; i < n; ++i) {
  6478.          unpack_int_r_sint32(s, dst[i]);
  6479.          s += 4;
  6480.       }
  6481.       break;
  6482.  
  6483.    case MESA_FORMAT_RG_UINT8:
  6484.       for (i = 0; i < n; ++i) {
  6485.          unpack_int_rg_uint8(s, dst[i]);
  6486.          s += 2;
  6487.       }
  6488.       break;
  6489.  
  6490.    case MESA_FORMAT_RG_UINT16:
  6491.       for (i = 0; i < n; ++i) {
  6492.          unpack_int_rg_uint16(s, dst[i]);
  6493.          s += 4;
  6494.       }
  6495.       break;
  6496.  
  6497.    case MESA_FORMAT_RG_UINT32:
  6498.       for (i = 0; i < n; ++i) {
  6499.          unpack_int_rg_uint32(s, dst[i]);
  6500.          s += 8;
  6501.       }
  6502.       break;
  6503.  
  6504.    case MESA_FORMAT_RG_SINT8:
  6505.       for (i = 0; i < n; ++i) {
  6506.          unpack_int_rg_sint8(s, dst[i]);
  6507.          s += 2;
  6508.       }
  6509.       break;
  6510.  
  6511.    case MESA_FORMAT_RG_SINT16:
  6512.       for (i = 0; i < n; ++i) {
  6513.          unpack_int_rg_sint16(s, dst[i]);
  6514.          s += 4;
  6515.       }
  6516.       break;
  6517.  
  6518.    case MESA_FORMAT_RG_SINT32:
  6519.       for (i = 0; i < n; ++i) {
  6520.          unpack_int_rg_sint32(s, dst[i]);
  6521.          s += 8;
  6522.       }
  6523.       break;
  6524.  
  6525.    case MESA_FORMAT_RGB_UINT8:
  6526.       for (i = 0; i < n; ++i) {
  6527.          unpack_int_rgb_uint8(s, dst[i]);
  6528.          s += 3;
  6529.       }
  6530.       break;
  6531.  
  6532.    case MESA_FORMAT_RGB_UINT16:
  6533.       for (i = 0; i < n; ++i) {
  6534.          unpack_int_rgb_uint16(s, dst[i]);
  6535.          s += 6;
  6536.       }
  6537.       break;
  6538.  
  6539.    case MESA_FORMAT_RGB_UINT32:
  6540.       for (i = 0; i < n; ++i) {
  6541.          unpack_int_rgb_uint32(s, dst[i]);
  6542.          s += 12;
  6543.       }
  6544.       break;
  6545.  
  6546.    case MESA_FORMAT_RGB_SINT8:
  6547.       for (i = 0; i < n; ++i) {
  6548.          unpack_int_rgb_sint8(s, dst[i]);
  6549.          s += 3;
  6550.       }
  6551.       break;
  6552.  
  6553.    case MESA_FORMAT_RGB_SINT16:
  6554.       for (i = 0; i < n; ++i) {
  6555.          unpack_int_rgb_sint16(s, dst[i]);
  6556.          s += 6;
  6557.       }
  6558.       break;
  6559.  
  6560.    case MESA_FORMAT_RGB_SINT32:
  6561.       for (i = 0; i < n; ++i) {
  6562.          unpack_int_rgb_sint32(s, dst[i]);
  6563.          s += 12;
  6564.       }
  6565.       break;
  6566.  
  6567.    case MESA_FORMAT_RGBA_UINT8:
  6568.       for (i = 0; i < n; ++i) {
  6569.          unpack_int_rgba_uint8(s, dst[i]);
  6570.          s += 4;
  6571.       }
  6572.       break;
  6573.  
  6574.    case MESA_FORMAT_RGBA_UINT16:
  6575.       for (i = 0; i < n; ++i) {
  6576.          unpack_int_rgba_uint16(s, dst[i]);
  6577.          s += 8;
  6578.       }
  6579.       break;
  6580.  
  6581.    case MESA_FORMAT_RGBA_UINT32:
  6582.       for (i = 0; i < n; ++i) {
  6583.          unpack_int_rgba_uint32(s, dst[i]);
  6584.          s += 16;
  6585.       }
  6586.       break;
  6587.  
  6588.    case MESA_FORMAT_RGBA_SINT8:
  6589.       for (i = 0; i < n; ++i) {
  6590.          unpack_int_rgba_sint8(s, dst[i]);
  6591.          s += 4;
  6592.       }
  6593.       break;
  6594.  
  6595.    case MESA_FORMAT_RGBA_SINT16:
  6596.       for (i = 0; i < n; ++i) {
  6597.          unpack_int_rgba_sint16(s, dst[i]);
  6598.          s += 8;
  6599.       }
  6600.       break;
  6601.  
  6602.    case MESA_FORMAT_RGBA_SINT32:
  6603.       for (i = 0; i < n; ++i) {
  6604.          unpack_int_rgba_sint32(s, dst[i]);
  6605.          s += 16;
  6606.       }
  6607.       break;
  6608.  
  6609.    case MESA_FORMAT_RGBX_UINT8:
  6610.       for (i = 0; i < n; ++i) {
  6611.          unpack_int_rgbx_uint8(s, dst[i]);
  6612.          s += 4;
  6613.       }
  6614.       break;
  6615.  
  6616.    case MESA_FORMAT_RGBX_UINT16:
  6617.       for (i = 0; i < n; ++i) {
  6618.          unpack_int_rgbx_uint16(s, dst[i]);
  6619.          s += 8;
  6620.       }
  6621.       break;
  6622.  
  6623.    case MESA_FORMAT_RGBX_UINT32:
  6624.       for (i = 0; i < n; ++i) {
  6625.          unpack_int_rgbx_uint32(s, dst[i]);
  6626.          s += 16;
  6627.       }
  6628.       break;
  6629.  
  6630.    case MESA_FORMAT_RGBX_SINT8:
  6631.       for (i = 0; i < n; ++i) {
  6632.          unpack_int_rgbx_sint8(s, dst[i]);
  6633.          s += 4;
  6634.       }
  6635.       break;
  6636.  
  6637.    case MESA_FORMAT_RGBX_SINT16:
  6638.       for (i = 0; i < n; ++i) {
  6639.          unpack_int_rgbx_sint16(s, dst[i]);
  6640.          s += 8;
  6641.       }
  6642.       break;
  6643.  
  6644.    case MESA_FORMAT_RGBX_SINT32:
  6645.       for (i = 0; i < n; ++i) {
  6646.          unpack_int_rgbx_sint32(s, dst[i]);
  6647.          s += 16;
  6648.       }
  6649.       break;
  6650.                                                                                                                                                                                                          default:
  6651.       _mesa_problem(NULL, "%s: bad format %s", __func__,
  6652.                     _mesa_get_format_name(format));
  6653.       return;
  6654.    }
  6655. }
  6656.  
  6657. /**
  6658.  * Unpack a 2D rect of pixels returning float RGBA colors.
  6659.  * \param format  the source image format
  6660.  * \param src  start address of the source image
  6661.  * \param srcRowStride  source image row stride in bytes
  6662.  * \param dst  start address of the dest image
  6663.  * \param dstRowStride  dest image row stride in bytes
  6664.  * \param x  source image start X pos
  6665.  * \param y  source image start Y pos
  6666.  * \param width  width of rect region to convert
  6667.  * \param height  height of rect region to convert
  6668.  */
  6669. void
  6670. _mesa_unpack_rgba_block(mesa_format format,
  6671.                         const void *src, GLint srcRowStride,
  6672.                         GLfloat dst[][4], GLint dstRowStride,
  6673.                         GLuint x, GLuint y, GLuint width, GLuint height)
  6674. {
  6675.    const GLuint srcPixStride = _mesa_get_format_bytes(format);
  6676.    const GLuint dstPixStride = 4 * sizeof(GLfloat);
  6677.    const GLubyte *srcRow;
  6678.    GLubyte *dstRow;
  6679.    GLuint i;
  6680.  
  6681.    /* XXX needs to be fixed for compressed formats */
  6682.  
  6683.    srcRow = ((const GLubyte *) src) + srcRowStride * y + srcPixStride * x;
  6684.    dstRow = ((GLubyte *) dst) + dstRowStride * y + dstPixStride * x;
  6685.  
  6686.    for (i = 0; i < height; i++) {
  6687.       _mesa_unpack_rgba_row(format, width, srcRow, (GLfloat (*)[4]) dstRow);
  6688.  
  6689.       dstRow += dstRowStride;
  6690.       srcRow += srcRowStride;
  6691.    }
  6692. }
  6693.  
  6694. /** Helper struct for MESA_FORMAT_Z32_FLOAT_S8X24_UINT */
  6695. struct z32f_x24s8
  6696. {
  6697.    float z;
  6698.    uint32_t x24s8;
  6699. };
  6700.  
  6701. typedef void (*unpack_float_z_func)(GLuint n, const void *src, GLfloat *dst);
  6702.  
  6703. static void
  6704. unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst)
  6705. {
  6706.    /* only return Z, not stencil data */
  6707.    const GLuint *s = ((const GLuint *) src);
  6708.    const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
  6709.    GLuint i;
  6710.    for (i = 0; i < n; i++) {
  6711.       dst[i] = (GLfloat) ((s[i] >> 8) * scale);
  6712.       assert(dst[i] >= 0.0F);
  6713.       assert(dst[i] <= 1.0F);
  6714.    }
  6715. }
  6716.  
  6717. static void
  6718. unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst)
  6719. {
  6720.    /* only return Z, not stencil data */
  6721.    const GLuint *s = ((const GLuint *) src);
  6722.    const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
  6723.    GLuint i;
  6724.    for (i = 0; i < n; i++) {
  6725.       dst[i] = (GLfloat) ((s[i] & 0x00ffffff) * scale);
  6726.       assert(dst[i] >= 0.0F);
  6727.       assert(dst[i] <= 1.0F);
  6728.    }
  6729. }
  6730.  
  6731. static void
  6732. unpack_float_Z_UNORM16(GLuint n, const void *src, GLfloat *dst)
  6733. {
  6734.    const GLushort *s = ((const GLushort *) src);
  6735.    GLuint i;
  6736.    for (i = 0; i < n; i++) {
  6737.       dst[i] = s[i] * (1.0F / 65535.0F);
  6738.    }
  6739. }
  6740.  
  6741. static void
  6742. unpack_float_Z_UNORM32(GLuint n, const void *src, GLfloat *dst)
  6743. {
  6744.    const GLuint *s = ((const GLuint *) src);
  6745.    GLuint i;
  6746.    for (i = 0; i < n; i++) {
  6747.       dst[i] = s[i] * (1.0F / 0xffffffff);
  6748.    }
  6749. }
  6750.  
  6751. static void
  6752. unpack_float_Z_FLOAT32(GLuint n, const void *src, GLfloat *dst)
  6753. {
  6754.    memcpy(dst, src, n * sizeof(float));
  6755. }
  6756.  
  6757. static void
  6758. unpack_float_z_Z32X24S8(GLuint n, const void *src, GLfloat *dst)
  6759. {
  6760.    const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
  6761.    GLuint i;
  6762.    for (i = 0; i < n; i++) {
  6763.       dst[i] = s[i].z;
  6764.    }
  6765. }
  6766.  
  6767.  
  6768.  
  6769. /**
  6770.  * Unpack Z values.
  6771.  * The returned values will always be in the range [0.0, 1.0].
  6772.  */
  6773. void
  6774. _mesa_unpack_float_z_row(mesa_format format, GLuint n,
  6775.                          const void *src, GLfloat *dst)
  6776. {
  6777.    unpack_float_z_func unpack;
  6778.  
  6779.    switch (format) {
  6780.    case MESA_FORMAT_S8_UINT_Z24_UNORM:
  6781.    case MESA_FORMAT_X8_UINT_Z24_UNORM:
  6782.       unpack = unpack_float_z_X8_UINT_Z24_UNORM;
  6783.       break;
  6784.    case MESA_FORMAT_Z24_UNORM_S8_UINT:
  6785.    case MESA_FORMAT_Z24_UNORM_X8_UINT:
  6786.       unpack = unpack_float_z_Z24_UNORM_X8_UINT;
  6787.       break;
  6788.    case MESA_FORMAT_Z_UNORM16:
  6789.       unpack = unpack_float_Z_UNORM16;
  6790.       break;
  6791.    case MESA_FORMAT_Z_UNORM32:
  6792.       unpack = unpack_float_Z_UNORM32;
  6793.       break;
  6794.    case MESA_FORMAT_Z_FLOAT32:
  6795.       unpack = unpack_float_Z_FLOAT32;
  6796.       break;
  6797.    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
  6798.       unpack = unpack_float_z_Z32X24S8;
  6799.       break;
  6800.    default:
  6801.       _mesa_problem(NULL, "bad format %s in _mesa_unpack_float_z_row",
  6802.                     _mesa_get_format_name(format));
  6803.       return;
  6804.    }
  6805.  
  6806.    unpack(n, src, dst);
  6807. }
  6808.  
  6809.  
  6810.  
  6811. typedef void (*unpack_uint_z_func)(const void *src, GLuint *dst, GLuint n);
  6812.  
  6813. static void
  6814. unpack_uint_z_X8_UINT_Z24_UNORM(const void *src, GLuint *dst, GLuint n)
  6815. {
  6816.    /* only return Z, not stencil data */
  6817.    const GLuint *s = ((const GLuint *) src);
  6818.    GLuint i;
  6819.    for (i = 0; i < n; i++) {
  6820.       dst[i] = (s[i] & 0xffffff00) | (s[i] >> 24);
  6821.    }
  6822. }
  6823.  
  6824. static void
  6825. unpack_uint_z_Z24_UNORM_X8_UINT(const void *src, GLuint *dst, GLuint n)
  6826. {
  6827.    /* only return Z, not stencil data */
  6828.    const GLuint *s = ((const GLuint *) src);
  6829.    GLuint i;
  6830.    for (i = 0; i < n; i++) {
  6831.       dst[i] = (s[i] << 8) | ((s[i] >> 16) & 0xff);
  6832.    }
  6833. }
  6834.  
  6835. static void
  6836. unpack_uint_Z_UNORM16(const void *src, GLuint *dst, GLuint n)
  6837. {
  6838.    const GLushort *s = ((const GLushort *)src);
  6839.    GLuint i;
  6840.    for (i = 0; i < n; i++) {
  6841.       dst[i] = (s[i] << 16) | s[i];
  6842.    }
  6843. }
  6844.  
  6845. static void
  6846. unpack_uint_Z_UNORM32(const void *src, GLuint *dst, GLuint n)
  6847. {
  6848.    memcpy(dst, src, n * sizeof(GLuint));
  6849. }
  6850.  
  6851. static void
  6852. unpack_uint_Z_FLOAT32(const void *src, GLuint *dst, GLuint n)
  6853. {
  6854.    const float *s = (const float *)src;
  6855.    GLuint i;
  6856.    for (i = 0; i < n; i++) {
  6857.       dst[i] = FLOAT_TO_UINT(CLAMP(s[i], 0.0F, 1.0F));
  6858.    }
  6859. }
  6860.  
  6861. static void
  6862. unpack_uint_Z_FLOAT32_X24S8(const void *src, GLuint *dst, GLuint n)
  6863. {
  6864.    const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
  6865.    GLuint i;
  6866.  
  6867.    for (i = 0; i < n; i++) {
  6868.       dst[i] = FLOAT_TO_UINT(CLAMP(s[i].z, 0.0F, 1.0F));
  6869.    }
  6870. }
  6871.  
  6872.  
  6873. /**
  6874.  * Unpack Z values.
  6875.  * The returned values will always be in the range [0, 0xffffffff].
  6876.  */
  6877. void
  6878. _mesa_unpack_uint_z_row(mesa_format format, GLuint n,
  6879.                         const void *src, GLuint *dst)
  6880. {
  6881.    unpack_uint_z_func unpack;
  6882.    const GLubyte *srcPtr = (GLubyte *) src;
  6883.  
  6884.    switch (format) {
  6885.    case MESA_FORMAT_S8_UINT_Z24_UNORM:
  6886.    case MESA_FORMAT_X8_UINT_Z24_UNORM:
  6887.       unpack = unpack_uint_z_X8_UINT_Z24_UNORM;
  6888.       break;
  6889.    case MESA_FORMAT_Z24_UNORM_S8_UINT:
  6890.    case MESA_FORMAT_Z24_UNORM_X8_UINT:
  6891.       unpack = unpack_uint_z_Z24_UNORM_X8_UINT;
  6892.       break;
  6893.    case MESA_FORMAT_Z_UNORM16:
  6894.       unpack = unpack_uint_Z_UNORM16;
  6895.       break;
  6896.    case MESA_FORMAT_Z_UNORM32:
  6897.       unpack = unpack_uint_Z_UNORM32;
  6898.       break;
  6899.    case MESA_FORMAT_Z_FLOAT32:
  6900.       unpack = unpack_uint_Z_FLOAT32;
  6901.       break;
  6902.    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
  6903.       unpack = unpack_uint_Z_FLOAT32_X24S8;
  6904.       break;
  6905.    default:
  6906.       _mesa_problem(NULL, "bad format %s in _mesa_unpack_uint_z_row",
  6907.                     _mesa_get_format_name(format));
  6908.       return;
  6909.    }
  6910.  
  6911.    unpack(srcPtr, dst, n);
  6912. }
  6913.  
  6914.  
  6915. static void
  6916. unpack_ubyte_s_S_UINT8(const void *src, GLubyte *dst, GLuint n)
  6917. {
  6918.    memcpy(dst, src, n);
  6919. }
  6920.  
  6921. static void
  6922. unpack_ubyte_s_S8_UINT_Z24_UNORM(const void *src, GLubyte *dst, GLuint n)
  6923. {
  6924.    GLuint i;
  6925.    const GLuint *src32 = src;
  6926.  
  6927.    for (i = 0; i < n; i++)
  6928.       dst[i] = src32[i] & 0xff;
  6929. }
  6930.  
  6931. static void
  6932. unpack_ubyte_s_Z24_UNORM_S8_UINT(const void *src, GLubyte *dst, GLuint n)
  6933. {
  6934.    GLuint i;
  6935.    const GLuint *src32 = src;
  6936.  
  6937.    for (i = 0; i < n; i++)
  6938.       dst[i] = src32[i] >> 24;
  6939. }
  6940.  
  6941. static void
  6942. unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(const void *src, GLubyte *dst, GLuint n)
  6943. {
  6944.    GLuint i;
  6945.    const struct z32f_x24s8 *s = (const struct z32f_x24s8 *) src;
  6946.  
  6947.    for (i = 0; i < n; i++)
  6948.       dst[i] = s[i].x24s8 & 0xff;
  6949. }
  6950.  
  6951. void
  6952. _mesa_unpack_ubyte_stencil_row(mesa_format format, GLuint n,
  6953.                                const void *src, GLubyte *dst)
  6954. {
  6955.    switch (format) {
  6956.    case MESA_FORMAT_S_UINT8:
  6957.       unpack_ubyte_s_S_UINT8(src, dst, n);
  6958.       break;
  6959.    case MESA_FORMAT_S8_UINT_Z24_UNORM:
  6960.       unpack_ubyte_s_S8_UINT_Z24_UNORM(src, dst, n);
  6961.       break;
  6962.    case MESA_FORMAT_Z24_UNORM_S8_UINT:
  6963.       unpack_ubyte_s_Z24_UNORM_S8_UINT(src, dst, n);
  6964.       break;
  6965.    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
  6966.       unpack_ubyte_s_Z32_FLOAT_S8X24_UINT(src, dst, n);
  6967.       break;
  6968.    default:
  6969.       _mesa_problem(NULL, "bad format %s in _mesa_unpack_ubyte_s_row",
  6970.                     _mesa_get_format_name(format));
  6971.       return;
  6972.    }
  6973. }
  6974.  
  6975. static void
  6976. unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(const GLuint *src, GLuint *dst, GLuint n)
  6977. {
  6978.    GLuint i;
  6979.  
  6980.    for (i = 0; i < n; i++) {
  6981.       GLuint val = src[i];
  6982.       dst[i] = val >> 24 | val << 8;
  6983.    }
  6984. }
  6985.  
  6986. static void
  6987. unpack_uint_24_8_depth_stencil_Z32_S8X24(const GLuint *src,
  6988.                                          GLuint *dst, GLuint n)
  6989. {
  6990.    GLuint i;
  6991.  
  6992.    for (i = 0; i < n; i++) {
  6993.       /* 8 bytes per pixel (float + uint32) */
  6994.       GLfloat zf = ((GLfloat *) src)[i * 2 + 0];
  6995.       GLuint z24 = (GLuint) (zf * (GLfloat) 0xffffff);
  6996.       GLuint s = src[i * 2 + 1] & 0xff;
  6997.       dst[i] = (z24 << 8) | s;
  6998.    }
  6999. }
  7000.  
  7001. static void
  7002. unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(const GLuint *src, GLuint *dst, GLuint n)
  7003. {
  7004.    memcpy(dst, src, n * 4);
  7005. }
  7006.  
  7007. /**
  7008.  * Unpack depth/stencil returning as GL_UNSIGNED_INT_24_8.
  7009.  * \param format  the source data format
  7010.  */
  7011. void
  7012. _mesa_unpack_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
  7013.                                          const void *src, GLuint *dst)
  7014. {
  7015.    switch (format) {
  7016.    case MESA_FORMAT_S8_UINT_Z24_UNORM:
  7017.       unpack_uint_24_8_depth_stencil_S8_UINT_Z24_UNORM(src, dst, n);
  7018.       break;
  7019.    case MESA_FORMAT_Z24_UNORM_S8_UINT:
  7020.       unpack_uint_24_8_depth_stencil_Z24_UNORM_S8_UINT(src, dst, n);
  7021.       break;
  7022.    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
  7023.       unpack_uint_24_8_depth_stencil_Z32_S8X24(src, dst, n);
  7024.       break;
  7025.    default:
  7026.       _mesa_problem(NULL,
  7027.                     "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
  7028.                     _mesa_get_format_name(format));
  7029.       return;
  7030.    }
  7031. }
  7032.  
  7033. static void
  7034. unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(const GLuint *src,
  7035.                                             GLuint *dst, GLuint n)
  7036. {
  7037.    GLuint i;
  7038.    struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
  7039.    const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
  7040.  
  7041.    for (i = 0; i < n; i++) {
  7042.       const GLuint z24 = src[i] & 0xffffff;
  7043.       d[i].z = z24 * scale;
  7044.       d[i].x24s8 = src[i] >> 24;
  7045.       assert(d[i].z >= 0.0f);
  7046.       assert(d[i].z <= 1.0f);
  7047.    }
  7048. }
  7049.  
  7050. static void
  7051. unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(const GLuint *src,
  7052.                                                GLuint *dst, GLuint n)
  7053. {
  7054.    memcpy(dst, src, n * sizeof(struct z32f_x24s8));
  7055. }
  7056.  
  7057. static void
  7058. unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(const GLuint *src,
  7059.                                             GLuint *dst, GLuint n)
  7060. {
  7061.    GLuint i;
  7062.    struct z32f_x24s8 *d = (struct z32f_x24s8 *) dst;
  7063.    const GLdouble scale = 1.0 / (GLdouble) 0xffffff;
  7064.  
  7065.    for (i = 0; i < n; i++) {
  7066.       const GLuint z24 = src[i] >> 8;
  7067.       d[i].z = z24 * scale;
  7068.       d[i].x24s8 = src[i] & 0xff;
  7069.       assert(d[i].z >= 0.0f);
  7070.       assert(d[i].z <= 1.0f);
  7071.    }
  7072. }
  7073.  
  7074. /**
  7075.  * Unpack depth/stencil returning as GL_FLOAT_32_UNSIGNED_INT_24_8_REV.
  7076.  * \param format  the source data format
  7077.  *
  7078.  * In GL_FLOAT_32_UNSIGNED_INT_24_8_REV lower 4 bytes contain float
  7079.  * component and higher 4 bytes contain packed 24-bit and 8-bit
  7080.  * components.
  7081.  *
  7082.  *    31 30 29 28 ... 4 3 2 1 0    31 30 29 ... 9 8 7 6 5 ... 2 1 0
  7083.  *    +-------------------------+  +--------------------------------+
  7084.  *    |    Float Component      |  | Unused         | 8 bit stencil |
  7085.  *    +-------------------------+  +--------------------------------+
  7086.  *          lower 4 bytes                  higher 4 bytes
  7087.  */
  7088. void
  7089. _mesa_unpack_float_32_uint_24_8_depth_stencil_row(mesa_format format, GLuint n,
  7090.                                                   const void *src, GLuint *dst)
  7091. {
  7092.    switch (format) {
  7093.    case MESA_FORMAT_S8_UINT_Z24_UNORM:
  7094.       unpack_float_32_uint_24_8_S8_UINT_Z24_UNORM(src, dst, n);
  7095.       break;
  7096.    case MESA_FORMAT_Z24_UNORM_S8_UINT:
  7097.       unpack_float_32_uint_24_8_Z24_UNORM_S8_UINT(src, dst, n);
  7098.       break;
  7099.    case MESA_FORMAT_Z32_FLOAT_S8X24_UINT:
  7100.       unpack_float_32_uint_24_8_Z32_FLOAT_S8X24_UINT(src, dst, n);
  7101.       break;
  7102.    default:
  7103.       _mesa_problem(NULL,
  7104.                     "bad format %s in _mesa_unpack_uint_24_8_depth_stencil_row",
  7105.                     _mesa_get_format_name(format));
  7106.       return;
  7107.    }
  7108. }
  7109.  
  7110. /**
  7111.  * Unpack depth/stencil
  7112.  * \param format  the source data format
  7113.  * \param type the destination data type
  7114.  */
  7115. void
  7116. _mesa_unpack_depth_stencil_row(mesa_format format, GLuint n,
  7117.                                const void *src, GLenum type,
  7118.                                GLuint *dst)
  7119. {
  7120.    assert(type == GL_UNSIGNED_INT_24_8 ||
  7121.           type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
  7122.  
  7123.    switch (type) {
  7124.    case GL_UNSIGNED_INT_24_8:
  7125.       _mesa_unpack_uint_24_8_depth_stencil_row(format, n, src, dst);
  7126.       break;
  7127.    case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
  7128.       _mesa_unpack_float_32_uint_24_8_depth_stencil_row(format, n, src, dst);
  7129.       break;
  7130.    default:
  7131.       _mesa_problem(NULL,
  7132.                     "bad type 0x%x in _mesa_unpack_depth_stencil_row",
  7133.                     type);
  7134.       return;
  7135.    }
  7136. }
  7137.  
  7138.