Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */
  2.  
  3. /**************************************************************************
  4.  *
  5.  * Copyright 2010 VMware, Inc.
  6.  * All Rights Reserved.
  7.  *
  8.  * Permission is hereby granted, free of charge, to any person obtaining a
  9.  * copy of this software and associated documentation files (the
  10.  * "Software"), to deal in the Software without restriction, including
  11.  * without limitation the rights to use, copy, modify, merge, publish,
  12.  * distribute, sub license, and/or sell copies of the Software, and to
  13.  * permit persons to whom the Software is furnished to do so, subject to
  14.  * the following conditions:
  15.  *
  16.  * The above copyright notice and this permission notice (including the
  17.  * next paragraph) shall be included in all copies or substantial portions
  18.  * of the Software.
  19.  *
  20.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  23.  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  24.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  25.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  26.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27.  *
  28.  **************************************************************************/
  29.  
  30. #include "u_format.h"
  31. #include "u_format_s3tc.h"
  32. #include "u_format_rgtc.h"
  33. #include "u_format_latc.h"
  34. #include "u_format_etc.h"
  35.  
  36.  
  37. #include "pipe/p_compiler.h"
  38. #include "u_math.h"
  39. #include "u_half.h"
  40. #include "u_format.h"
  41. #include "u_format_other.h"
  42. #include "u_format_srgb.h"
  43. #include "u_format_yuv.h"
  44. #include "u_format_zs.h"
  45.  
  46. union util_format_none {
  47.    uint8_t value;
  48.    struct {
  49.       uint8_t r;
  50.    } chan;
  51. };
  52.  
  53. static INLINE void
  54. util_format_none_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  55. {
  56.    unsigned x, y;
  57.    for(y = 0; y < height; y += 1) {
  58.       float *dst = dst_row;
  59.       const uint8_t *src = src_row;
  60.       for(x = 0; x < width; x += 1) {
  61.          uint8_t value = *(const uint8_t *)src;
  62.          uint8_t r;
  63.          r = value;
  64.          dst[0] = (float)r; /* r */
  65.          dst[1] = 0; /* g */
  66.          dst[2] = 0; /* b */
  67.          dst[3] = 1; /* a */
  68.          src += 1;
  69.          dst += 4;
  70.       }
  71.       src_row += src_stride;
  72.       dst_row += dst_stride/sizeof(*dst_row);
  73.    }
  74. }
  75.  
  76. static INLINE void
  77. util_format_none_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  78. {
  79.    unsigned x, y;
  80.    for(y = 0; y < height; y += 1) {
  81.       const float *src = src_row;
  82.       uint8_t *dst = dst_row;
  83.       for(x = 0; x < width; x += 1) {
  84.          uint8_t value = 0;
  85.          value |= (uint8_t)CLAMP(src[0], 0, 255);
  86.          *(uint8_t *)dst = value;
  87.          src += 4;
  88.          dst += 1;
  89.       }
  90.       dst_row += dst_stride;
  91.       src_row += src_stride/sizeof(*src_row);
  92.    }
  93. }
  94.  
  95. static INLINE void
  96. util_format_none_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  97. {
  98.          uint8_t value = *(const uint8_t *)src;
  99.          uint8_t r;
  100.          r = value;
  101.          dst[0] = (float)r; /* r */
  102.          dst[1] = 0; /* g */
  103.          dst[2] = 0; /* b */
  104.          dst[3] = 1; /* a */
  105. }
  106.  
  107. static INLINE void
  108. util_format_none_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  109. {
  110.    unsigned x, y;
  111.    for(y = 0; y < height; y += 1) {
  112.       uint8_t *dst = dst_row;
  113.       const uint8_t *src = src_row;
  114.       for(x = 0; x < width; x += 1) {
  115.          uint8_t value = *(const uint8_t *)src;
  116.          uint8_t r;
  117.          r = value;
  118.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  119.          dst[1] = 0; /* g */
  120.          dst[2] = 0; /* b */
  121.          dst[3] = 255; /* a */
  122.          src += 1;
  123.          dst += 4;
  124.       }
  125.       src_row += src_stride;
  126.       dst_row += dst_stride/sizeof(*dst_row);
  127.    }
  128. }
  129.  
  130. static INLINE void
  131. util_format_none_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  132. {
  133.    unsigned x, y;
  134.    for(y = 0; y < height; y += 1) {
  135.       const uint8_t *src = src_row;
  136.       uint8_t *dst = dst_row;
  137.       for(x = 0; x < width; x += 1) {
  138.          uint8_t value = 0;
  139.          value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  140.          *(uint8_t *)dst = value;
  141.          src += 4;
  142.          dst += 1;
  143.       }
  144.       dst_row += dst_stride;
  145.       src_row += src_stride/sizeof(*src_row);
  146.    }
  147. }
  148.  
  149. union util_format_b8g8r8a8_unorm {
  150.    uint32_t value;
  151.    struct {
  152.       uint8_t b;
  153.       uint8_t g;
  154.       uint8_t r;
  155.       uint8_t a;
  156.    } chan;
  157. };
  158.  
  159. static INLINE void
  160. util_format_b8g8r8a8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  161. {
  162.    unsigned x, y;
  163.    for(y = 0; y < height; y += 1) {
  164.       float *dst = dst_row;
  165.       const uint8_t *src = src_row;
  166.       for(x = 0; x < width; x += 1) {
  167.          uint32_t value = *(const uint32_t *)src;
  168.          uint32_t b;
  169.          uint32_t g;
  170.          uint32_t r;
  171.          uint32_t a;
  172.          b = (value) & 0xff;
  173.          g = (value >> 8) & 0xff;
  174.          r = (value >> 16) & 0xff;
  175.          a = value >> 24;
  176.          dst[0] = ubyte_to_float(r); /* r */
  177.          dst[1] = ubyte_to_float(g); /* g */
  178.          dst[2] = ubyte_to_float(b); /* b */
  179.          dst[3] = ubyte_to_float(a); /* a */
  180.          src += 4;
  181.          dst += 4;
  182.       }
  183.       src_row += src_stride;
  184.       dst_row += dst_stride/sizeof(*dst_row);
  185.    }
  186. }
  187.  
  188. static INLINE void
  189. util_format_b8g8r8a8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  190. {
  191.    unsigned x, y;
  192.    for(y = 0; y < height; y += 1) {
  193.       const float *src = src_row;
  194.       uint8_t *dst = dst_row;
  195.       for(x = 0; x < width; x += 1) {
  196.          uint32_t value = 0;
  197.          value |= (float_to_ubyte(src[2])) & 0xff;
  198.          value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
  199.          value |= ((float_to_ubyte(src[0])) & 0xff) << 16;
  200.          value |= (float_to_ubyte(src[3])) << 24;
  201.          *(uint32_t *)dst = value;
  202.          src += 4;
  203.          dst += 4;
  204.       }
  205.       dst_row += dst_stride;
  206.       src_row += src_stride/sizeof(*src_row);
  207.    }
  208. }
  209.  
  210. static INLINE void
  211. util_format_b8g8r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  212. {
  213.          uint32_t value = *(const uint32_t *)src;
  214.          uint32_t b;
  215.          uint32_t g;
  216.          uint32_t r;
  217.          uint32_t a;
  218.          b = (value) & 0xff;
  219.          g = (value >> 8) & 0xff;
  220.          r = (value >> 16) & 0xff;
  221.          a = value >> 24;
  222.          dst[0] = ubyte_to_float(r); /* r */
  223.          dst[1] = ubyte_to_float(g); /* g */
  224.          dst[2] = ubyte_to_float(b); /* b */
  225.          dst[3] = ubyte_to_float(a); /* a */
  226. }
  227.  
  228. static INLINE void
  229. util_format_b8g8r8a8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  230. {
  231.    unsigned x, y;
  232.    for(y = 0; y < height; y += 1) {
  233.       uint8_t *dst = dst_row;
  234.       const uint8_t *src = src_row;
  235.       for(x = 0; x < width; x += 1) {
  236.          uint32_t value = *(const uint32_t *)src;
  237.          uint32_t b;
  238.          uint32_t g;
  239.          uint32_t r;
  240.          uint32_t a;
  241.          b = (value) & 0xff;
  242.          g = (value >> 8) & 0xff;
  243.          r = (value >> 16) & 0xff;
  244.          a = value >> 24;
  245.          dst[0] = r; /* r */
  246.          dst[1] = g; /* g */
  247.          dst[2] = b; /* b */
  248.          dst[3] = a; /* a */
  249.          src += 4;
  250.          dst += 4;
  251.       }
  252.       src_row += src_stride;
  253.       dst_row += dst_stride/sizeof(*dst_row);
  254.    }
  255. }
  256.  
  257. static INLINE void
  258. util_format_b8g8r8a8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  259. {
  260.    unsigned x, y;
  261.    for(y = 0; y < height; y += 1) {
  262.       const uint8_t *src = src_row;
  263.       uint8_t *dst = dst_row;
  264.       for(x = 0; x < width; x += 1) {
  265.          uint32_t value = 0;
  266.          value |= (src[2]) & 0xff;
  267.          value |= ((src[1]) & 0xff) << 8;
  268.          value |= ((src[0]) & 0xff) << 16;
  269.          value |= (src[3]) << 24;
  270.          *(uint32_t *)dst = value;
  271.          src += 4;
  272.          dst += 4;
  273.       }
  274.       dst_row += dst_stride;
  275.       src_row += src_stride/sizeof(*src_row);
  276.    }
  277. }
  278.  
  279. union util_format_b8g8r8x8_unorm {
  280.    uint32_t value;
  281.    struct {
  282.       uint8_t b;
  283.       uint8_t g;
  284.       uint8_t r;
  285.       uint8_t x;
  286.    } chan;
  287. };
  288.  
  289. static INLINE void
  290. util_format_b8g8r8x8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  291. {
  292.    unsigned x, y;
  293.    for(y = 0; y < height; y += 1) {
  294.       float *dst = dst_row;
  295.       const uint8_t *src = src_row;
  296.       for(x = 0; x < width; x += 1) {
  297.          uint32_t value = *(const uint32_t *)src;
  298.          uint32_t b;
  299.          uint32_t g;
  300.          uint32_t r;
  301.          b = (value) & 0xff;
  302.          g = (value >> 8) & 0xff;
  303.          r = (value >> 16) & 0xff;
  304.          dst[0] = ubyte_to_float(r); /* r */
  305.          dst[1] = ubyte_to_float(g); /* g */
  306.          dst[2] = ubyte_to_float(b); /* b */
  307.          dst[3] = 1; /* a */
  308.          src += 4;
  309.          dst += 4;
  310.       }
  311.       src_row += src_stride;
  312.       dst_row += dst_stride/sizeof(*dst_row);
  313.    }
  314. }
  315.  
  316. static INLINE void
  317. util_format_b8g8r8x8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  318. {
  319.    unsigned x, y;
  320.    for(y = 0; y < height; y += 1) {
  321.       const float *src = src_row;
  322.       uint8_t *dst = dst_row;
  323.       for(x = 0; x < width; x += 1) {
  324.          uint32_t value = 0;
  325.          value |= (float_to_ubyte(src[2])) & 0xff;
  326.          value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
  327.          value |= ((float_to_ubyte(src[0])) & 0xff) << 16;
  328.          *(uint32_t *)dst = value;
  329.          src += 4;
  330.          dst += 4;
  331.       }
  332.       dst_row += dst_stride;
  333.       src_row += src_stride/sizeof(*src_row);
  334.    }
  335. }
  336.  
  337. static INLINE void
  338. util_format_b8g8r8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  339. {
  340.          uint32_t value = *(const uint32_t *)src;
  341.          uint32_t b;
  342.          uint32_t g;
  343.          uint32_t r;
  344.          b = (value) & 0xff;
  345.          g = (value >> 8) & 0xff;
  346.          r = (value >> 16) & 0xff;
  347.          dst[0] = ubyte_to_float(r); /* r */
  348.          dst[1] = ubyte_to_float(g); /* g */
  349.          dst[2] = ubyte_to_float(b); /* b */
  350.          dst[3] = 1; /* a */
  351. }
  352.  
  353. static INLINE void
  354. util_format_b8g8r8x8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  355. {
  356.    unsigned x, y;
  357.    for(y = 0; y < height; y += 1) {
  358.       uint8_t *dst = dst_row;
  359.       const uint8_t *src = src_row;
  360.       for(x = 0; x < width; x += 1) {
  361.          uint32_t value = *(const uint32_t *)src;
  362.          uint32_t b;
  363.          uint32_t g;
  364.          uint32_t r;
  365.          b = (value) & 0xff;
  366.          g = (value >> 8) & 0xff;
  367.          r = (value >> 16) & 0xff;
  368.          dst[0] = r; /* r */
  369.          dst[1] = g; /* g */
  370.          dst[2] = b; /* b */
  371.          dst[3] = 255; /* a */
  372.          src += 4;
  373.          dst += 4;
  374.       }
  375.       src_row += src_stride;
  376.       dst_row += dst_stride/sizeof(*dst_row);
  377.    }
  378. }
  379.  
  380. static INLINE void
  381. util_format_b8g8r8x8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  382. {
  383.    unsigned x, y;
  384.    for(y = 0; y < height; y += 1) {
  385.       const uint8_t *src = src_row;
  386.       uint8_t *dst = dst_row;
  387.       for(x = 0; x < width; x += 1) {
  388.          uint32_t value = 0;
  389.          value |= (src[2]) & 0xff;
  390.          value |= ((src[1]) & 0xff) << 8;
  391.          value |= ((src[0]) & 0xff) << 16;
  392.          *(uint32_t *)dst = value;
  393.          src += 4;
  394.          dst += 4;
  395.       }
  396.       dst_row += dst_stride;
  397.       src_row += src_stride/sizeof(*src_row);
  398.    }
  399. }
  400.  
  401. union util_format_a8r8g8b8_unorm {
  402.    uint32_t value;
  403.    struct {
  404.       uint8_t a;
  405.       uint8_t r;
  406.       uint8_t g;
  407.       uint8_t b;
  408.    } chan;
  409. };
  410.  
  411. static INLINE void
  412. util_format_a8r8g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  413. {
  414.    unsigned x, y;
  415.    for(y = 0; y < height; y += 1) {
  416.       float *dst = dst_row;
  417.       const uint8_t *src = src_row;
  418.       for(x = 0; x < width; x += 1) {
  419.          uint32_t value = *(const uint32_t *)src;
  420.          uint32_t a;
  421.          uint32_t r;
  422.          uint32_t g;
  423.          uint32_t b;
  424.          a = (value) & 0xff;
  425.          r = (value >> 8) & 0xff;
  426.          g = (value >> 16) & 0xff;
  427.          b = value >> 24;
  428.          dst[0] = ubyte_to_float(r); /* r */
  429.          dst[1] = ubyte_to_float(g); /* g */
  430.          dst[2] = ubyte_to_float(b); /* b */
  431.          dst[3] = ubyte_to_float(a); /* a */
  432.          src += 4;
  433.          dst += 4;
  434.       }
  435.       src_row += src_stride;
  436.       dst_row += dst_stride/sizeof(*dst_row);
  437.    }
  438. }
  439.  
  440. static INLINE void
  441. util_format_a8r8g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  442. {
  443.    unsigned x, y;
  444.    for(y = 0; y < height; y += 1) {
  445.       const float *src = src_row;
  446.       uint8_t *dst = dst_row;
  447.       for(x = 0; x < width; x += 1) {
  448.          uint32_t value = 0;
  449.          value |= (float_to_ubyte(src[3])) & 0xff;
  450.          value |= ((float_to_ubyte(src[0])) & 0xff) << 8;
  451.          value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
  452.          value |= (float_to_ubyte(src[2])) << 24;
  453.          *(uint32_t *)dst = value;
  454.          src += 4;
  455.          dst += 4;
  456.       }
  457.       dst_row += dst_stride;
  458.       src_row += src_stride/sizeof(*src_row);
  459.    }
  460. }
  461.  
  462. static INLINE void
  463. util_format_a8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  464. {
  465.          uint32_t value = *(const uint32_t *)src;
  466.          uint32_t a;
  467.          uint32_t r;
  468.          uint32_t g;
  469.          uint32_t b;
  470.          a = (value) & 0xff;
  471.          r = (value >> 8) & 0xff;
  472.          g = (value >> 16) & 0xff;
  473.          b = value >> 24;
  474.          dst[0] = ubyte_to_float(r); /* r */
  475.          dst[1] = ubyte_to_float(g); /* g */
  476.          dst[2] = ubyte_to_float(b); /* b */
  477.          dst[3] = ubyte_to_float(a); /* a */
  478. }
  479.  
  480. static INLINE void
  481. util_format_a8r8g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  482. {
  483.    unsigned x, y;
  484.    for(y = 0; y < height; y += 1) {
  485.       uint8_t *dst = dst_row;
  486.       const uint8_t *src = src_row;
  487.       for(x = 0; x < width; x += 1) {
  488.          uint32_t value = *(const uint32_t *)src;
  489.          uint32_t a;
  490.          uint32_t r;
  491.          uint32_t g;
  492.          uint32_t b;
  493.          a = (value) & 0xff;
  494.          r = (value >> 8) & 0xff;
  495.          g = (value >> 16) & 0xff;
  496.          b = value >> 24;
  497.          dst[0] = r; /* r */
  498.          dst[1] = g; /* g */
  499.          dst[2] = b; /* b */
  500.          dst[3] = a; /* a */
  501.          src += 4;
  502.          dst += 4;
  503.       }
  504.       src_row += src_stride;
  505.       dst_row += dst_stride/sizeof(*dst_row);
  506.    }
  507. }
  508.  
  509. static INLINE void
  510. util_format_a8r8g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  511. {
  512.    unsigned x, y;
  513.    for(y = 0; y < height; y += 1) {
  514.       const uint8_t *src = src_row;
  515.       uint8_t *dst = dst_row;
  516.       for(x = 0; x < width; x += 1) {
  517.          uint32_t value = 0;
  518.          value |= (src[3]) & 0xff;
  519.          value |= ((src[0]) & 0xff) << 8;
  520.          value |= ((src[1]) & 0xff) << 16;
  521.          value |= (src[2]) << 24;
  522.          *(uint32_t *)dst = value;
  523.          src += 4;
  524.          dst += 4;
  525.       }
  526.       dst_row += dst_stride;
  527.       src_row += src_stride/sizeof(*src_row);
  528.    }
  529. }
  530.  
  531. union util_format_x8r8g8b8_unorm {
  532.    uint32_t value;
  533.    struct {
  534.       uint8_t x;
  535.       uint8_t r;
  536.       uint8_t g;
  537.       uint8_t b;
  538.    } chan;
  539. };
  540.  
  541. static INLINE void
  542. util_format_x8r8g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  543. {
  544.    unsigned x, y;
  545.    for(y = 0; y < height; y += 1) {
  546.       float *dst = dst_row;
  547.       const uint8_t *src = src_row;
  548.       for(x = 0; x < width; x += 1) {
  549.          uint32_t value = *(const uint32_t *)src;
  550.          uint32_t r;
  551.          uint32_t g;
  552.          uint32_t b;
  553.          r = (value >> 8) & 0xff;
  554.          g = (value >> 16) & 0xff;
  555.          b = value >> 24;
  556.          dst[0] = ubyte_to_float(r); /* r */
  557.          dst[1] = ubyte_to_float(g); /* g */
  558.          dst[2] = ubyte_to_float(b); /* b */
  559.          dst[3] = 1; /* a */
  560.          src += 4;
  561.          dst += 4;
  562.       }
  563.       src_row += src_stride;
  564.       dst_row += dst_stride/sizeof(*dst_row);
  565.    }
  566. }
  567.  
  568. static INLINE void
  569. util_format_x8r8g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  570. {
  571.    unsigned x, y;
  572.    for(y = 0; y < height; y += 1) {
  573.       const float *src = src_row;
  574.       uint8_t *dst = dst_row;
  575.       for(x = 0; x < width; x += 1) {
  576.          uint32_t value = 0;
  577.          value |= ((float_to_ubyte(src[0])) & 0xff) << 8;
  578.          value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
  579.          value |= (float_to_ubyte(src[2])) << 24;
  580.          *(uint32_t *)dst = value;
  581.          src += 4;
  582.          dst += 4;
  583.       }
  584.       dst_row += dst_stride;
  585.       src_row += src_stride/sizeof(*src_row);
  586.    }
  587. }
  588.  
  589. static INLINE void
  590. util_format_x8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  591. {
  592.          uint32_t value = *(const uint32_t *)src;
  593.          uint32_t r;
  594.          uint32_t g;
  595.          uint32_t b;
  596.          r = (value >> 8) & 0xff;
  597.          g = (value >> 16) & 0xff;
  598.          b = value >> 24;
  599.          dst[0] = ubyte_to_float(r); /* r */
  600.          dst[1] = ubyte_to_float(g); /* g */
  601.          dst[2] = ubyte_to_float(b); /* b */
  602.          dst[3] = 1; /* a */
  603. }
  604.  
  605. static INLINE void
  606. util_format_x8r8g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  607. {
  608.    unsigned x, y;
  609.    for(y = 0; y < height; y += 1) {
  610.       uint8_t *dst = dst_row;
  611.       const uint8_t *src = src_row;
  612.       for(x = 0; x < width; x += 1) {
  613.          uint32_t value = *(const uint32_t *)src;
  614.          uint32_t r;
  615.          uint32_t g;
  616.          uint32_t b;
  617.          r = (value >> 8) & 0xff;
  618.          g = (value >> 16) & 0xff;
  619.          b = value >> 24;
  620.          dst[0] = r; /* r */
  621.          dst[1] = g; /* g */
  622.          dst[2] = b; /* b */
  623.          dst[3] = 255; /* a */
  624.          src += 4;
  625.          dst += 4;
  626.       }
  627.       src_row += src_stride;
  628.       dst_row += dst_stride/sizeof(*dst_row);
  629.    }
  630. }
  631.  
  632. static INLINE void
  633. util_format_x8r8g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  634. {
  635.    unsigned x, y;
  636.    for(y = 0; y < height; y += 1) {
  637.       const uint8_t *src = src_row;
  638.       uint8_t *dst = dst_row;
  639.       for(x = 0; x < width; x += 1) {
  640.          uint32_t value = 0;
  641.          value |= ((src[0]) & 0xff) << 8;
  642.          value |= ((src[1]) & 0xff) << 16;
  643.          value |= (src[2]) << 24;
  644.          *(uint32_t *)dst = value;
  645.          src += 4;
  646.          dst += 4;
  647.       }
  648.       dst_row += dst_stride;
  649.       src_row += src_stride/sizeof(*src_row);
  650.    }
  651. }
  652.  
  653. union util_format_a8b8g8r8_unorm {
  654.    uint32_t value;
  655.    struct {
  656.       uint8_t a;
  657.       uint8_t b;
  658.       uint8_t g;
  659.       uint8_t r;
  660.    } chan;
  661. };
  662.  
  663. static INLINE void
  664. util_format_a8b8g8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  665. {
  666.    unsigned x, y;
  667.    for(y = 0; y < height; y += 1) {
  668.       float *dst = dst_row;
  669.       const uint8_t *src = src_row;
  670.       for(x = 0; x < width; x += 1) {
  671.          uint32_t value = *(const uint32_t *)src;
  672.          uint32_t a;
  673.          uint32_t b;
  674.          uint32_t g;
  675.          uint32_t r;
  676.          a = (value) & 0xff;
  677.          b = (value >> 8) & 0xff;
  678.          g = (value >> 16) & 0xff;
  679.          r = value >> 24;
  680.          dst[0] = ubyte_to_float(r); /* r */
  681.          dst[1] = ubyte_to_float(g); /* g */
  682.          dst[2] = ubyte_to_float(b); /* b */
  683.          dst[3] = ubyte_to_float(a); /* a */
  684.          src += 4;
  685.          dst += 4;
  686.       }
  687.       src_row += src_stride;
  688.       dst_row += dst_stride/sizeof(*dst_row);
  689.    }
  690. }
  691.  
  692. static INLINE void
  693. util_format_a8b8g8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  694. {
  695.    unsigned x, y;
  696.    for(y = 0; y < height; y += 1) {
  697.       const float *src = src_row;
  698.       uint8_t *dst = dst_row;
  699.       for(x = 0; x < width; x += 1) {
  700.          uint32_t value = 0;
  701.          value |= (float_to_ubyte(src[3])) & 0xff;
  702.          value |= ((float_to_ubyte(src[2])) & 0xff) << 8;
  703.          value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
  704.          value |= (float_to_ubyte(src[0])) << 24;
  705.          *(uint32_t *)dst = value;
  706.          src += 4;
  707.          dst += 4;
  708.       }
  709.       dst_row += dst_stride;
  710.       src_row += src_stride/sizeof(*src_row);
  711.    }
  712. }
  713.  
  714. static INLINE void
  715. util_format_a8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  716. {
  717.          uint32_t value = *(const uint32_t *)src;
  718.          uint32_t a;
  719.          uint32_t b;
  720.          uint32_t g;
  721.          uint32_t r;
  722.          a = (value) & 0xff;
  723.          b = (value >> 8) & 0xff;
  724.          g = (value >> 16) & 0xff;
  725.          r = value >> 24;
  726.          dst[0] = ubyte_to_float(r); /* r */
  727.          dst[1] = ubyte_to_float(g); /* g */
  728.          dst[2] = ubyte_to_float(b); /* b */
  729.          dst[3] = ubyte_to_float(a); /* a */
  730. }
  731.  
  732. static INLINE void
  733. util_format_a8b8g8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  734. {
  735.    unsigned x, y;
  736.    for(y = 0; y < height; y += 1) {
  737.       uint8_t *dst = dst_row;
  738.       const uint8_t *src = src_row;
  739.       for(x = 0; x < width; x += 1) {
  740.          uint32_t value = *(const uint32_t *)src;
  741.          uint32_t a;
  742.          uint32_t b;
  743.          uint32_t g;
  744.          uint32_t r;
  745.          a = (value) & 0xff;
  746.          b = (value >> 8) & 0xff;
  747.          g = (value >> 16) & 0xff;
  748.          r = value >> 24;
  749.          dst[0] = r; /* r */
  750.          dst[1] = g; /* g */
  751.          dst[2] = b; /* b */
  752.          dst[3] = a; /* a */
  753.          src += 4;
  754.          dst += 4;
  755.       }
  756.       src_row += src_stride;
  757.       dst_row += dst_stride/sizeof(*dst_row);
  758.    }
  759. }
  760.  
  761. static INLINE void
  762. util_format_a8b8g8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  763. {
  764.    unsigned x, y;
  765.    for(y = 0; y < height; y += 1) {
  766.       const uint8_t *src = src_row;
  767.       uint8_t *dst = dst_row;
  768.       for(x = 0; x < width; x += 1) {
  769.          uint32_t value = 0;
  770.          value |= (src[3]) & 0xff;
  771.          value |= ((src[2]) & 0xff) << 8;
  772.          value |= ((src[1]) & 0xff) << 16;
  773.          value |= (src[0]) << 24;
  774.          *(uint32_t *)dst = value;
  775.          src += 4;
  776.          dst += 4;
  777.       }
  778.       dst_row += dst_stride;
  779.       src_row += src_stride/sizeof(*src_row);
  780.    }
  781. }
  782.  
  783. union util_format_x8b8g8r8_unorm {
  784.    uint32_t value;
  785.    struct {
  786.       uint8_t x;
  787.       uint8_t b;
  788.       uint8_t g;
  789.       uint8_t r;
  790.    } chan;
  791. };
  792.  
  793. static INLINE void
  794. util_format_x8b8g8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  795. {
  796.    unsigned x, y;
  797.    for(y = 0; y < height; y += 1) {
  798.       float *dst = dst_row;
  799.       const uint8_t *src = src_row;
  800.       for(x = 0; x < width; x += 1) {
  801.          uint32_t value = *(const uint32_t *)src;
  802.          uint32_t b;
  803.          uint32_t g;
  804.          uint32_t r;
  805.          b = (value >> 8) & 0xff;
  806.          g = (value >> 16) & 0xff;
  807.          r = value >> 24;
  808.          dst[0] = ubyte_to_float(r); /* r */
  809.          dst[1] = ubyte_to_float(g); /* g */
  810.          dst[2] = ubyte_to_float(b); /* b */
  811.          dst[3] = 1; /* a */
  812.          src += 4;
  813.          dst += 4;
  814.       }
  815.       src_row += src_stride;
  816.       dst_row += dst_stride/sizeof(*dst_row);
  817.    }
  818. }
  819.  
  820. static INLINE void
  821. util_format_x8b8g8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  822. {
  823.    unsigned x, y;
  824.    for(y = 0; y < height; y += 1) {
  825.       const float *src = src_row;
  826.       uint8_t *dst = dst_row;
  827.       for(x = 0; x < width; x += 1) {
  828.          uint32_t value = 0;
  829.          value |= ((float_to_ubyte(src[2])) & 0xff) << 8;
  830.          value |= ((float_to_ubyte(src[1])) & 0xff) << 16;
  831.          value |= (float_to_ubyte(src[0])) << 24;
  832.          *(uint32_t *)dst = value;
  833.          src += 4;
  834.          dst += 4;
  835.       }
  836.       dst_row += dst_stride;
  837.       src_row += src_stride/sizeof(*src_row);
  838.    }
  839. }
  840.  
  841. static INLINE void
  842. util_format_x8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  843. {
  844.          uint32_t value = *(const uint32_t *)src;
  845.          uint32_t b;
  846.          uint32_t g;
  847.          uint32_t r;
  848.          b = (value >> 8) & 0xff;
  849.          g = (value >> 16) & 0xff;
  850.          r = value >> 24;
  851.          dst[0] = ubyte_to_float(r); /* r */
  852.          dst[1] = ubyte_to_float(g); /* g */
  853.          dst[2] = ubyte_to_float(b); /* b */
  854.          dst[3] = 1; /* a */
  855. }
  856.  
  857. static INLINE void
  858. util_format_x8b8g8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  859. {
  860.    unsigned x, y;
  861.    for(y = 0; y < height; y += 1) {
  862.       uint8_t *dst = dst_row;
  863.       const uint8_t *src = src_row;
  864.       for(x = 0; x < width; x += 1) {
  865.          uint32_t value = *(const uint32_t *)src;
  866.          uint32_t b;
  867.          uint32_t g;
  868.          uint32_t r;
  869.          b = (value >> 8) & 0xff;
  870.          g = (value >> 16) & 0xff;
  871.          r = value >> 24;
  872.          dst[0] = r; /* r */
  873.          dst[1] = g; /* g */
  874.          dst[2] = b; /* b */
  875.          dst[3] = 255; /* a */
  876.          src += 4;
  877.          dst += 4;
  878.       }
  879.       src_row += src_stride;
  880.       dst_row += dst_stride/sizeof(*dst_row);
  881.    }
  882. }
  883.  
  884. static INLINE void
  885. util_format_x8b8g8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  886. {
  887.    unsigned x, y;
  888.    for(y = 0; y < height; y += 1) {
  889.       const uint8_t *src = src_row;
  890.       uint8_t *dst = dst_row;
  891.       for(x = 0; x < width; x += 1) {
  892.          uint32_t value = 0;
  893.          value |= ((src[2]) & 0xff) << 8;
  894.          value |= ((src[1]) & 0xff) << 16;
  895.          value |= (src[0]) << 24;
  896.          *(uint32_t *)dst = value;
  897.          src += 4;
  898.          dst += 4;
  899.       }
  900.       dst_row += dst_stride;
  901.       src_row += src_stride/sizeof(*src_row);
  902.    }
  903. }
  904.  
  905. union util_format_r8g8b8x8_unorm {
  906.    uint32_t value;
  907.    struct {
  908.       uint8_t r;
  909.       uint8_t g;
  910.       uint8_t b;
  911.       uint8_t x;
  912.    } chan;
  913. };
  914.  
  915. static INLINE void
  916. util_format_r8g8b8x8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  917. {
  918.    unsigned x, y;
  919.    for(y = 0; y < height; y += 1) {
  920.       float *dst = dst_row;
  921.       const uint8_t *src = src_row;
  922.       for(x = 0; x < width; x += 1) {
  923.          uint32_t value = *(const uint32_t *)src;
  924.          uint32_t r;
  925.          uint32_t g;
  926.          uint32_t b;
  927.          r = (value) & 0xff;
  928.          g = (value >> 8) & 0xff;
  929.          b = (value >> 16) & 0xff;
  930.          dst[0] = ubyte_to_float(r); /* r */
  931.          dst[1] = ubyte_to_float(g); /* g */
  932.          dst[2] = ubyte_to_float(b); /* b */
  933.          dst[3] = 1; /* a */
  934.          src += 4;
  935.          dst += 4;
  936.       }
  937.       src_row += src_stride;
  938.       dst_row += dst_stride/sizeof(*dst_row);
  939.    }
  940. }
  941.  
  942. static INLINE void
  943. util_format_r8g8b8x8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  944. {
  945.    unsigned x, y;
  946.    for(y = 0; y < height; y += 1) {
  947.       const float *src = src_row;
  948.       uint8_t *dst = dst_row;
  949.       for(x = 0; x < width; x += 1) {
  950.          uint32_t value = 0;
  951.          value |= (float_to_ubyte(src[0])) & 0xff;
  952.          value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
  953.          value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
  954.          *(uint32_t *)dst = value;
  955.          src += 4;
  956.          dst += 4;
  957.       }
  958.       dst_row += dst_stride;
  959.       src_row += src_stride/sizeof(*src_row);
  960.    }
  961. }
  962.  
  963. static INLINE void
  964. util_format_r8g8b8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  965. {
  966.          uint32_t value = *(const uint32_t *)src;
  967.          uint32_t r;
  968.          uint32_t g;
  969.          uint32_t b;
  970.          r = (value) & 0xff;
  971.          g = (value >> 8) & 0xff;
  972.          b = (value >> 16) & 0xff;
  973.          dst[0] = ubyte_to_float(r); /* r */
  974.          dst[1] = ubyte_to_float(g); /* g */
  975.          dst[2] = ubyte_to_float(b); /* b */
  976.          dst[3] = 1; /* a */
  977. }
  978.  
  979. static INLINE void
  980. util_format_r8g8b8x8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  981. {
  982.    unsigned x, y;
  983.    for(y = 0; y < height; y += 1) {
  984.       uint8_t *dst = dst_row;
  985.       const uint8_t *src = src_row;
  986.       for(x = 0; x < width; x += 1) {
  987.          uint32_t value = *(const uint32_t *)src;
  988.          uint32_t r;
  989.          uint32_t g;
  990.          uint32_t b;
  991.          r = (value) & 0xff;
  992.          g = (value >> 8) & 0xff;
  993.          b = (value >> 16) & 0xff;
  994.          dst[0] = r; /* r */
  995.          dst[1] = g; /* g */
  996.          dst[2] = b; /* b */
  997.          dst[3] = 255; /* a */
  998.          src += 4;
  999.          dst += 4;
  1000.       }
  1001.       src_row += src_stride;
  1002.       dst_row += dst_stride/sizeof(*dst_row);
  1003.    }
  1004. }
  1005.  
  1006. static INLINE void
  1007. util_format_r8g8b8x8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1008. {
  1009.    unsigned x, y;
  1010.    for(y = 0; y < height; y += 1) {
  1011.       const uint8_t *src = src_row;
  1012.       uint8_t *dst = dst_row;
  1013.       for(x = 0; x < width; x += 1) {
  1014.          uint32_t value = 0;
  1015.          value |= (src[0]) & 0xff;
  1016.          value |= ((src[1]) & 0xff) << 8;
  1017.          value |= ((src[2]) & 0xff) << 16;
  1018.          *(uint32_t *)dst = value;
  1019.          src += 4;
  1020.          dst += 4;
  1021.       }
  1022.       dst_row += dst_stride;
  1023.       src_row += src_stride/sizeof(*src_row);
  1024.    }
  1025. }
  1026.  
  1027. union util_format_l8_unorm {
  1028.    uint8_t value;
  1029.    struct {
  1030.       uint8_t rgb;
  1031.    } chan;
  1032. };
  1033.  
  1034. static INLINE void
  1035. util_format_l8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1036. {
  1037.    unsigned x, y;
  1038.    for(y = 0; y < height; y += 1) {
  1039.       float *dst = dst_row;
  1040.       const uint8_t *src = src_row;
  1041.       for(x = 0; x < width; x += 1) {
  1042.          uint8_t value = *(const uint8_t *)src;
  1043.          uint8_t rgb;
  1044.          rgb = value;
  1045.          dst[0] = ubyte_to_float(rgb); /* r */
  1046.          dst[1] = ubyte_to_float(rgb); /* g */
  1047.          dst[2] = ubyte_to_float(rgb); /* b */
  1048.          dst[3] = 1; /* a */
  1049.          src += 1;
  1050.          dst += 4;
  1051.       }
  1052.       src_row += src_stride;
  1053.       dst_row += dst_stride/sizeof(*dst_row);
  1054.    }
  1055. }
  1056.  
  1057. static INLINE void
  1058. util_format_l8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1059. {
  1060.    unsigned x, y;
  1061.    for(y = 0; y < height; y += 1) {
  1062.       const float *src = src_row;
  1063.       uint8_t *dst = dst_row;
  1064.       for(x = 0; x < width; x += 1) {
  1065.          uint8_t value = 0;
  1066.          value |= float_to_ubyte(src[0]);
  1067.          *(uint8_t *)dst = value;
  1068.          src += 4;
  1069.          dst += 1;
  1070.       }
  1071.       dst_row += dst_stride;
  1072.       src_row += src_stride/sizeof(*src_row);
  1073.    }
  1074. }
  1075.  
  1076. static INLINE void
  1077. util_format_l8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1078. {
  1079.          uint8_t value = *(const uint8_t *)src;
  1080.          uint8_t rgb;
  1081.          rgb = value;
  1082.          dst[0] = ubyte_to_float(rgb); /* r */
  1083.          dst[1] = ubyte_to_float(rgb); /* g */
  1084.          dst[2] = ubyte_to_float(rgb); /* b */
  1085.          dst[3] = 1; /* a */
  1086. }
  1087.  
  1088. static INLINE void
  1089. util_format_l8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1090. {
  1091.    unsigned x, y;
  1092.    for(y = 0; y < height; y += 1) {
  1093.       uint8_t *dst = dst_row;
  1094.       const uint8_t *src = src_row;
  1095.       for(x = 0; x < width; x += 1) {
  1096.          uint8_t value = *(const uint8_t *)src;
  1097.          uint8_t rgb;
  1098.          rgb = value;
  1099.          dst[0] = rgb; /* r */
  1100.          dst[1] = rgb; /* g */
  1101.          dst[2] = rgb; /* b */
  1102.          dst[3] = 255; /* a */
  1103.          src += 1;
  1104.          dst += 4;
  1105.       }
  1106.       src_row += src_stride;
  1107.       dst_row += dst_stride/sizeof(*dst_row);
  1108.    }
  1109. }
  1110.  
  1111. static INLINE void
  1112. util_format_l8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1113. {
  1114.    unsigned x, y;
  1115.    for(y = 0; y < height; y += 1) {
  1116.       const uint8_t *src = src_row;
  1117.       uint8_t *dst = dst_row;
  1118.       for(x = 0; x < width; x += 1) {
  1119.          uint8_t value = 0;
  1120.          value |= src[0];
  1121.          *(uint8_t *)dst = value;
  1122.          src += 4;
  1123.          dst += 1;
  1124.       }
  1125.       dst_row += dst_stride;
  1126.       src_row += src_stride/sizeof(*src_row);
  1127.    }
  1128. }
  1129.  
  1130. union util_format_a8_unorm {
  1131.    uint8_t value;
  1132.    struct {
  1133.       uint8_t a;
  1134.    } chan;
  1135. };
  1136.  
  1137. static INLINE void
  1138. util_format_a8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1139. {
  1140.    unsigned x, y;
  1141.    for(y = 0; y < height; y += 1) {
  1142.       float *dst = dst_row;
  1143.       const uint8_t *src = src_row;
  1144.       for(x = 0; x < width; x += 1) {
  1145.          uint8_t value = *(const uint8_t *)src;
  1146.          uint8_t a;
  1147.          a = value;
  1148.          dst[0] = 0; /* r */
  1149.          dst[1] = 0; /* g */
  1150.          dst[2] = 0; /* b */
  1151.          dst[3] = ubyte_to_float(a); /* a */
  1152.          src += 1;
  1153.          dst += 4;
  1154.       }
  1155.       src_row += src_stride;
  1156.       dst_row += dst_stride/sizeof(*dst_row);
  1157.    }
  1158. }
  1159.  
  1160. static INLINE void
  1161. util_format_a8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1162. {
  1163.    unsigned x, y;
  1164.    for(y = 0; y < height; y += 1) {
  1165.       const float *src = src_row;
  1166.       uint8_t *dst = dst_row;
  1167.       for(x = 0; x < width; x += 1) {
  1168.          uint8_t value = 0;
  1169.          value |= float_to_ubyte(src[3]);
  1170.          *(uint8_t *)dst = value;
  1171.          src += 4;
  1172.          dst += 1;
  1173.       }
  1174.       dst_row += dst_stride;
  1175.       src_row += src_stride/sizeof(*src_row);
  1176.    }
  1177. }
  1178.  
  1179. static INLINE void
  1180. util_format_a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1181. {
  1182.          uint8_t value = *(const uint8_t *)src;
  1183.          uint8_t a;
  1184.          a = value;
  1185.          dst[0] = 0; /* r */
  1186.          dst[1] = 0; /* g */
  1187.          dst[2] = 0; /* b */
  1188.          dst[3] = ubyte_to_float(a); /* a */
  1189. }
  1190.  
  1191. static INLINE void
  1192. util_format_a8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1193. {
  1194.    unsigned x, y;
  1195.    for(y = 0; y < height; y += 1) {
  1196.       uint8_t *dst = dst_row;
  1197.       const uint8_t *src = src_row;
  1198.       for(x = 0; x < width; x += 1) {
  1199.          uint8_t value = *(const uint8_t *)src;
  1200.          uint8_t a;
  1201.          a = value;
  1202.          dst[0] = 0; /* r */
  1203.          dst[1] = 0; /* g */
  1204.          dst[2] = 0; /* b */
  1205.          dst[3] = a; /* a */
  1206.          src += 1;
  1207.          dst += 4;
  1208.       }
  1209.       src_row += src_stride;
  1210.       dst_row += dst_stride/sizeof(*dst_row);
  1211.    }
  1212. }
  1213.  
  1214. static INLINE void
  1215. util_format_a8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1216. {
  1217.    unsigned x, y;
  1218.    for(y = 0; y < height; y += 1) {
  1219.       const uint8_t *src = src_row;
  1220.       uint8_t *dst = dst_row;
  1221.       for(x = 0; x < width; x += 1) {
  1222.          uint8_t value = 0;
  1223.          value |= src[3];
  1224.          *(uint8_t *)dst = value;
  1225.          src += 4;
  1226.          dst += 1;
  1227.       }
  1228.       dst_row += dst_stride;
  1229.       src_row += src_stride/sizeof(*src_row);
  1230.    }
  1231. }
  1232.  
  1233. union util_format_i8_unorm {
  1234.    uint8_t value;
  1235.    struct {
  1236.       uint8_t rgba;
  1237.    } chan;
  1238. };
  1239.  
  1240. static INLINE void
  1241. util_format_i8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1242. {
  1243.    unsigned x, y;
  1244.    for(y = 0; y < height; y += 1) {
  1245.       float *dst = dst_row;
  1246.       const uint8_t *src = src_row;
  1247.       for(x = 0; x < width; x += 1) {
  1248.          uint8_t value = *(const uint8_t *)src;
  1249.          uint8_t rgba;
  1250.          rgba = value;
  1251.          dst[0] = ubyte_to_float(rgba); /* r */
  1252.          dst[1] = ubyte_to_float(rgba); /* g */
  1253.          dst[2] = ubyte_to_float(rgba); /* b */
  1254.          dst[3] = ubyte_to_float(rgba); /* a */
  1255.          src += 1;
  1256.          dst += 4;
  1257.       }
  1258.       src_row += src_stride;
  1259.       dst_row += dst_stride/sizeof(*dst_row);
  1260.    }
  1261. }
  1262.  
  1263. static INLINE void
  1264. util_format_i8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1265. {
  1266.    unsigned x, y;
  1267.    for(y = 0; y < height; y += 1) {
  1268.       const float *src = src_row;
  1269.       uint8_t *dst = dst_row;
  1270.       for(x = 0; x < width; x += 1) {
  1271.          uint8_t value = 0;
  1272.          value |= float_to_ubyte(src[0]);
  1273.          *(uint8_t *)dst = value;
  1274.          src += 4;
  1275.          dst += 1;
  1276.       }
  1277.       dst_row += dst_stride;
  1278.       src_row += src_stride/sizeof(*src_row);
  1279.    }
  1280. }
  1281.  
  1282. static INLINE void
  1283. util_format_i8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1284. {
  1285.          uint8_t value = *(const uint8_t *)src;
  1286.          uint8_t rgba;
  1287.          rgba = value;
  1288.          dst[0] = ubyte_to_float(rgba); /* r */
  1289.          dst[1] = ubyte_to_float(rgba); /* g */
  1290.          dst[2] = ubyte_to_float(rgba); /* b */
  1291.          dst[3] = ubyte_to_float(rgba); /* a */
  1292. }
  1293.  
  1294. static INLINE void
  1295. util_format_i8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1296. {
  1297.    unsigned x, y;
  1298.    for(y = 0; y < height; y += 1) {
  1299.       uint8_t *dst = dst_row;
  1300.       const uint8_t *src = src_row;
  1301.       for(x = 0; x < width; x += 1) {
  1302.          uint8_t value = *(const uint8_t *)src;
  1303.          uint8_t rgba;
  1304.          rgba = value;
  1305.          dst[0] = rgba; /* r */
  1306.          dst[1] = rgba; /* g */
  1307.          dst[2] = rgba; /* b */
  1308.          dst[3] = rgba; /* a */
  1309.          src += 1;
  1310.          dst += 4;
  1311.       }
  1312.       src_row += src_stride;
  1313.       dst_row += dst_stride/sizeof(*dst_row);
  1314.    }
  1315. }
  1316.  
  1317. static INLINE void
  1318. util_format_i8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1319. {
  1320.    unsigned x, y;
  1321.    for(y = 0; y < height; y += 1) {
  1322.       const uint8_t *src = src_row;
  1323.       uint8_t *dst = dst_row;
  1324.       for(x = 0; x < width; x += 1) {
  1325.          uint8_t value = 0;
  1326.          value |= src[0];
  1327.          *(uint8_t *)dst = value;
  1328.          src += 4;
  1329.          dst += 1;
  1330.       }
  1331.       dst_row += dst_stride;
  1332.       src_row += src_stride/sizeof(*src_row);
  1333.    }
  1334. }
  1335.  
  1336. union util_format_l4a4_unorm {
  1337.    uint8_t value;
  1338.    struct {
  1339.       unsigned rgb:4;
  1340.       unsigned a:4;
  1341.    } chan;
  1342. };
  1343.  
  1344. static INLINE void
  1345. util_format_l4a4_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1346. {
  1347.    unsigned x, y;
  1348.    for(y = 0; y < height; y += 1) {
  1349.       float *dst = dst_row;
  1350.       const uint8_t *src = src_row;
  1351.       for(x = 0; x < width; x += 1) {
  1352.          uint8_t value = *(const uint8_t *)src;
  1353.          uint8_t rgb;
  1354.          uint8_t a;
  1355.          rgb = (value) & 0xf;
  1356.          a = value >> 4;
  1357.          dst[0] = (float)(rgb * (1.0f/0xf)); /* r */
  1358.          dst[1] = (float)(rgb * (1.0f/0xf)); /* g */
  1359.          dst[2] = (float)(rgb * (1.0f/0xf)); /* b */
  1360.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  1361.          src += 1;
  1362.          dst += 4;
  1363.       }
  1364.       src_row += src_stride;
  1365.       dst_row += dst_stride/sizeof(*dst_row);
  1366.    }
  1367. }
  1368.  
  1369. static INLINE void
  1370. util_format_l4a4_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1371. {
  1372.    unsigned x, y;
  1373.    for(y = 0; y < height; y += 1) {
  1374.       const float *src = src_row;
  1375.       uint8_t *dst = dst_row;
  1376.       for(x = 0; x < width; x += 1) {
  1377.          uint8_t value = 0;
  1378.          value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf;
  1379.          value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4;
  1380.          *(uint8_t *)dst = value;
  1381.          src += 4;
  1382.          dst += 1;
  1383.       }
  1384.       dst_row += dst_stride;
  1385.       src_row += src_stride/sizeof(*src_row);
  1386.    }
  1387. }
  1388.  
  1389. static INLINE void
  1390. util_format_l4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1391. {
  1392.          uint8_t value = *(const uint8_t *)src;
  1393.          uint8_t rgb;
  1394.          uint8_t a;
  1395.          rgb = (value) & 0xf;
  1396.          a = value >> 4;
  1397.          dst[0] = (float)(rgb * (1.0f/0xf)); /* r */
  1398.          dst[1] = (float)(rgb * (1.0f/0xf)); /* g */
  1399.          dst[2] = (float)(rgb * (1.0f/0xf)); /* b */
  1400.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  1401. }
  1402.  
  1403. static INLINE void
  1404. util_format_l4a4_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1405. {
  1406.    unsigned x, y;
  1407.    for(y = 0; y < height; y += 1) {
  1408.       uint8_t *dst = dst_row;
  1409.       const uint8_t *src = src_row;
  1410.       for(x = 0; x < width; x += 1) {
  1411.          uint8_t value = *(const uint8_t *)src;
  1412.          uint8_t rgb;
  1413.          uint8_t a;
  1414.          rgb = (value) & 0xf;
  1415.          a = value >> 4;
  1416.          dst[0] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* r */
  1417.          dst[1] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* g */
  1418.          dst[2] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* b */
  1419.          dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
  1420.          src += 1;
  1421.          dst += 4;
  1422.       }
  1423.       src_row += src_stride;
  1424.       dst_row += dst_stride/sizeof(*dst_row);
  1425.    }
  1426. }
  1427.  
  1428. static INLINE void
  1429. util_format_l4a4_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1430. {
  1431.    unsigned x, y;
  1432.    for(y = 0; y < height; y += 1) {
  1433.       const uint8_t *src = src_row;
  1434.       uint8_t *dst = dst_row;
  1435.       for(x = 0; x < width; x += 1) {
  1436.          uint8_t value = 0;
  1437.          value |= ((uint8_t)(src[0] >> 4)) & 0xf;
  1438.          value |= ((uint8_t)(src[3] >> 4)) << 4;
  1439.          *(uint8_t *)dst = value;
  1440.          src += 4;
  1441.          dst += 1;
  1442.       }
  1443.       dst_row += dst_stride;
  1444.       src_row += src_stride/sizeof(*src_row);
  1445.    }
  1446. }
  1447.  
  1448. union util_format_l8a8_unorm {
  1449.    uint16_t value;
  1450.    struct {
  1451.       uint8_t rgb;
  1452.       uint8_t a;
  1453.    } chan;
  1454. };
  1455.  
  1456. static INLINE void
  1457. util_format_l8a8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1458. {
  1459.    unsigned x, y;
  1460.    for(y = 0; y < height; y += 1) {
  1461.       float *dst = dst_row;
  1462.       const uint8_t *src = src_row;
  1463.       for(x = 0; x < width; x += 1) {
  1464.          uint16_t value = *(const uint16_t *)src;
  1465.          uint16_t rgb;
  1466.          uint16_t a;
  1467.          rgb = (value) & 0xff;
  1468.          a = value >> 8;
  1469.          dst[0] = ubyte_to_float(rgb); /* r */
  1470.          dst[1] = ubyte_to_float(rgb); /* g */
  1471.          dst[2] = ubyte_to_float(rgb); /* b */
  1472.          dst[3] = ubyte_to_float(a); /* a */
  1473.          src += 2;
  1474.          dst += 4;
  1475.       }
  1476.       src_row += src_stride;
  1477.       dst_row += dst_stride/sizeof(*dst_row);
  1478.    }
  1479. }
  1480.  
  1481. static INLINE void
  1482. util_format_l8a8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1483. {
  1484.    unsigned x, y;
  1485.    for(y = 0; y < height; y += 1) {
  1486.       const float *src = src_row;
  1487.       uint8_t *dst = dst_row;
  1488.       for(x = 0; x < width; x += 1) {
  1489.          uint16_t value = 0;
  1490.          value |= (float_to_ubyte(src[0])) & 0xff;
  1491.          value |= (float_to_ubyte(src[3])) << 8;
  1492.          *(uint16_t *)dst = value;
  1493.          src += 4;
  1494.          dst += 2;
  1495.       }
  1496.       dst_row += dst_stride;
  1497.       src_row += src_stride/sizeof(*src_row);
  1498.    }
  1499. }
  1500.  
  1501. static INLINE void
  1502. util_format_l8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1503. {
  1504.          uint16_t value = *(const uint16_t *)src;
  1505.          uint16_t rgb;
  1506.          uint16_t a;
  1507.          rgb = (value) & 0xff;
  1508.          a = value >> 8;
  1509.          dst[0] = ubyte_to_float(rgb); /* r */
  1510.          dst[1] = ubyte_to_float(rgb); /* g */
  1511.          dst[2] = ubyte_to_float(rgb); /* b */
  1512.          dst[3] = ubyte_to_float(a); /* a */
  1513. }
  1514.  
  1515. static INLINE void
  1516. util_format_l8a8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1517. {
  1518.    unsigned x, y;
  1519.    for(y = 0; y < height; y += 1) {
  1520.       uint8_t *dst = dst_row;
  1521.       const uint8_t *src = src_row;
  1522.       for(x = 0; x < width; x += 1) {
  1523.          uint16_t value = *(const uint16_t *)src;
  1524.          uint16_t rgb;
  1525.          uint16_t a;
  1526.          rgb = (value) & 0xff;
  1527.          a = value >> 8;
  1528.          dst[0] = rgb; /* r */
  1529.          dst[1] = rgb; /* g */
  1530.          dst[2] = rgb; /* b */
  1531.          dst[3] = a; /* a */
  1532.          src += 2;
  1533.          dst += 4;
  1534.       }
  1535.       src_row += src_stride;
  1536.       dst_row += dst_stride/sizeof(*dst_row);
  1537.    }
  1538. }
  1539.  
  1540. static INLINE void
  1541. util_format_l8a8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1542. {
  1543.    unsigned x, y;
  1544.    for(y = 0; y < height; y += 1) {
  1545.       const uint8_t *src = src_row;
  1546.       uint8_t *dst = dst_row;
  1547.       for(x = 0; x < width; x += 1) {
  1548.          uint16_t value = 0;
  1549.          value |= (src[0]) & 0xff;
  1550.          value |= (src[3]) << 8;
  1551.          *(uint16_t *)dst = value;
  1552.          src += 4;
  1553.          dst += 2;
  1554.       }
  1555.       dst_row += dst_stride;
  1556.       src_row += src_stride/sizeof(*src_row);
  1557.    }
  1558. }
  1559.  
  1560. union util_format_l16_unorm {
  1561.    uint16_t value;
  1562.    struct {
  1563.       uint16_t rgb;
  1564.    } chan;
  1565. };
  1566.  
  1567. static INLINE void
  1568. util_format_l16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1569. {
  1570.    unsigned x, y;
  1571.    for(y = 0; y < height; y += 1) {
  1572.       float *dst = dst_row;
  1573.       const uint8_t *src = src_row;
  1574.       for(x = 0; x < width; x += 1) {
  1575.          uint16_t value = *(const uint16_t *)src;
  1576.          uint16_t rgb;
  1577.          rgb = value;
  1578.          dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
  1579.          dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
  1580.          dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
  1581.          dst[3] = 1; /* a */
  1582.          src += 2;
  1583.          dst += 4;
  1584.       }
  1585.       src_row += src_stride;
  1586.       dst_row += dst_stride/sizeof(*dst_row);
  1587.    }
  1588. }
  1589.  
  1590. static INLINE void
  1591. util_format_l16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1592. {
  1593.    unsigned x, y;
  1594.    for(y = 0; y < height; y += 1) {
  1595.       const float *src = src_row;
  1596.       uint8_t *dst = dst_row;
  1597.       for(x = 0; x < width; x += 1) {
  1598.          uint16_t value = 0;
  1599.          value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  1600.          *(uint16_t *)dst = value;
  1601.          src += 4;
  1602.          dst += 2;
  1603.       }
  1604.       dst_row += dst_stride;
  1605.       src_row += src_stride/sizeof(*src_row);
  1606.    }
  1607. }
  1608.  
  1609. static INLINE void
  1610. util_format_l16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1611. {
  1612.          uint16_t value = *(const uint16_t *)src;
  1613.          uint16_t rgb;
  1614.          rgb = value;
  1615.          dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
  1616.          dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
  1617.          dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
  1618.          dst[3] = 1; /* a */
  1619. }
  1620.  
  1621. static INLINE void
  1622. util_format_l16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1623. {
  1624.    unsigned x, y;
  1625.    for(y = 0; y < height; y += 1) {
  1626.       uint8_t *dst = dst_row;
  1627.       const uint8_t *src = src_row;
  1628.       for(x = 0; x < width; x += 1) {
  1629.          uint16_t value = *(const uint16_t *)src;
  1630.          uint16_t rgb;
  1631.          rgb = value;
  1632.          dst[0] = (uint8_t)(rgb >> 8); /* r */
  1633.          dst[1] = (uint8_t)(rgb >> 8); /* g */
  1634.          dst[2] = (uint8_t)(rgb >> 8); /* b */
  1635.          dst[3] = 255; /* a */
  1636.          src += 2;
  1637.          dst += 4;
  1638.       }
  1639.       src_row += src_stride;
  1640.       dst_row += dst_stride/sizeof(*dst_row);
  1641.    }
  1642. }
  1643.  
  1644. static INLINE void
  1645. util_format_l16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1646. {
  1647.    unsigned x, y;
  1648.    for(y = 0; y < height; y += 1) {
  1649.       const uint8_t *src = src_row;
  1650.       uint8_t *dst = dst_row;
  1651.       for(x = 0; x < width; x += 1) {
  1652.          uint16_t value = 0;
  1653.          value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  1654.          *(uint16_t *)dst = value;
  1655.          src += 4;
  1656.          dst += 2;
  1657.       }
  1658.       dst_row += dst_stride;
  1659.       src_row += src_stride/sizeof(*src_row);
  1660.    }
  1661. }
  1662.  
  1663. union util_format_a16_unorm {
  1664.    uint16_t value;
  1665.    struct {
  1666.       uint16_t a;
  1667.    } chan;
  1668. };
  1669.  
  1670. static INLINE void
  1671. util_format_a16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1672. {
  1673.    unsigned x, y;
  1674.    for(y = 0; y < height; y += 1) {
  1675.       float *dst = dst_row;
  1676.       const uint8_t *src = src_row;
  1677.       for(x = 0; x < width; x += 1) {
  1678.          uint16_t value = *(const uint16_t *)src;
  1679.          uint16_t a;
  1680.          a = value;
  1681.          dst[0] = 0; /* r */
  1682.          dst[1] = 0; /* g */
  1683.          dst[2] = 0; /* b */
  1684.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  1685.          src += 2;
  1686.          dst += 4;
  1687.       }
  1688.       src_row += src_stride;
  1689.       dst_row += dst_stride/sizeof(*dst_row);
  1690.    }
  1691. }
  1692.  
  1693. static INLINE void
  1694. util_format_a16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1695. {
  1696.    unsigned x, y;
  1697.    for(y = 0; y < height; y += 1) {
  1698.       const float *src = src_row;
  1699.       uint8_t *dst = dst_row;
  1700.       for(x = 0; x < width; x += 1) {
  1701.          uint16_t value = 0;
  1702.          value |= (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff);
  1703.          *(uint16_t *)dst = value;
  1704.          src += 4;
  1705.          dst += 2;
  1706.       }
  1707.       dst_row += dst_stride;
  1708.       src_row += src_stride/sizeof(*src_row);
  1709.    }
  1710. }
  1711.  
  1712. static INLINE void
  1713. util_format_a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1714. {
  1715.          uint16_t value = *(const uint16_t *)src;
  1716.          uint16_t a;
  1717.          a = value;
  1718.          dst[0] = 0; /* r */
  1719.          dst[1] = 0; /* g */
  1720.          dst[2] = 0; /* b */
  1721.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  1722. }
  1723.  
  1724. static INLINE void
  1725. util_format_a16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1726. {
  1727.    unsigned x, y;
  1728.    for(y = 0; y < height; y += 1) {
  1729.       uint8_t *dst = dst_row;
  1730.       const uint8_t *src = src_row;
  1731.       for(x = 0; x < width; x += 1) {
  1732.          uint16_t value = *(const uint16_t *)src;
  1733.          uint16_t a;
  1734.          a = value;
  1735.          dst[0] = 0; /* r */
  1736.          dst[1] = 0; /* g */
  1737.          dst[2] = 0; /* b */
  1738.          dst[3] = (uint8_t)(a >> 8); /* a */
  1739.          src += 2;
  1740.          dst += 4;
  1741.       }
  1742.       src_row += src_stride;
  1743.       dst_row += dst_stride/sizeof(*dst_row);
  1744.    }
  1745. }
  1746.  
  1747. static INLINE void
  1748. util_format_a16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1749. {
  1750.    unsigned x, y;
  1751.    for(y = 0; y < height; y += 1) {
  1752.       const uint8_t *src = src_row;
  1753.       uint8_t *dst = dst_row;
  1754.       for(x = 0; x < width; x += 1) {
  1755.          uint16_t value = 0;
  1756.          value |= (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff);
  1757.          *(uint16_t *)dst = value;
  1758.          src += 4;
  1759.          dst += 2;
  1760.       }
  1761.       dst_row += dst_stride;
  1762.       src_row += src_stride/sizeof(*src_row);
  1763.    }
  1764. }
  1765.  
  1766. union util_format_i16_unorm {
  1767.    uint16_t value;
  1768.    struct {
  1769.       uint16_t rgba;
  1770.    } chan;
  1771. };
  1772.  
  1773. static INLINE void
  1774. util_format_i16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1775. {
  1776.    unsigned x, y;
  1777.    for(y = 0; y < height; y += 1) {
  1778.       float *dst = dst_row;
  1779.       const uint8_t *src = src_row;
  1780.       for(x = 0; x < width; x += 1) {
  1781.          uint16_t value = *(const uint16_t *)src;
  1782.          uint16_t rgba;
  1783.          rgba = value;
  1784.          dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */
  1785.          dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */
  1786.          dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */
  1787.          dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */
  1788.          src += 2;
  1789.          dst += 4;
  1790.       }
  1791.       src_row += src_stride;
  1792.       dst_row += dst_stride/sizeof(*dst_row);
  1793.    }
  1794. }
  1795.  
  1796. static INLINE void
  1797. util_format_i16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1798. {
  1799.    unsigned x, y;
  1800.    for(y = 0; y < height; y += 1) {
  1801.       const float *src = src_row;
  1802.       uint8_t *dst = dst_row;
  1803.       for(x = 0; x < width; x += 1) {
  1804.          uint16_t value = 0;
  1805.          value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  1806.          *(uint16_t *)dst = value;
  1807.          src += 4;
  1808.          dst += 2;
  1809.       }
  1810.       dst_row += dst_stride;
  1811.       src_row += src_stride/sizeof(*src_row);
  1812.    }
  1813. }
  1814.  
  1815. static INLINE void
  1816. util_format_i16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1817. {
  1818.          uint16_t value = *(const uint16_t *)src;
  1819.          uint16_t rgba;
  1820.          rgba = value;
  1821.          dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */
  1822.          dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */
  1823.          dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */
  1824.          dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */
  1825. }
  1826.  
  1827. static INLINE void
  1828. util_format_i16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1829. {
  1830.    unsigned x, y;
  1831.    for(y = 0; y < height; y += 1) {
  1832.       uint8_t *dst = dst_row;
  1833.       const uint8_t *src = src_row;
  1834.       for(x = 0; x < width; x += 1) {
  1835.          uint16_t value = *(const uint16_t *)src;
  1836.          uint16_t rgba;
  1837.          rgba = value;
  1838.          dst[0] = (uint8_t)(rgba >> 8); /* r */
  1839.          dst[1] = (uint8_t)(rgba >> 8); /* g */
  1840.          dst[2] = (uint8_t)(rgba >> 8); /* b */
  1841.          dst[3] = (uint8_t)(rgba >> 8); /* a */
  1842.          src += 2;
  1843.          dst += 4;
  1844.       }
  1845.       src_row += src_stride;
  1846.       dst_row += dst_stride/sizeof(*dst_row);
  1847.    }
  1848. }
  1849.  
  1850. static INLINE void
  1851. util_format_i16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1852. {
  1853.    unsigned x, y;
  1854.    for(y = 0; y < height; y += 1) {
  1855.       const uint8_t *src = src_row;
  1856.       uint8_t *dst = dst_row;
  1857.       for(x = 0; x < width; x += 1) {
  1858.          uint16_t value = 0;
  1859.          value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  1860.          *(uint16_t *)dst = value;
  1861.          src += 4;
  1862.          dst += 2;
  1863.       }
  1864.       dst_row += dst_stride;
  1865.       src_row += src_stride/sizeof(*src_row);
  1866.    }
  1867. }
  1868.  
  1869. union util_format_l16a16_unorm {
  1870.    uint32_t value;
  1871.    struct {
  1872.       uint16_t rgb;
  1873.       uint16_t a;
  1874.    } chan;
  1875. };
  1876.  
  1877. static INLINE void
  1878. util_format_l16a16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1879. {
  1880.    unsigned x, y;
  1881.    for(y = 0; y < height; y += 1) {
  1882.       float *dst = dst_row;
  1883.       const uint8_t *src = src_row;
  1884.       for(x = 0; x < width; x += 1) {
  1885.          uint32_t value = *(const uint32_t *)src;
  1886.          uint32_t rgb;
  1887.          uint32_t a;
  1888.          rgb = (value) & 0xffff;
  1889.          a = value >> 16;
  1890.          dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
  1891.          dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
  1892.          dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
  1893.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  1894.          src += 4;
  1895.          dst += 4;
  1896.       }
  1897.       src_row += src_stride;
  1898.       dst_row += dst_stride/sizeof(*dst_row);
  1899.    }
  1900. }
  1901.  
  1902. static INLINE void
  1903. util_format_l16a16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  1904. {
  1905.    unsigned x, y;
  1906.    for(y = 0; y < height; y += 1) {
  1907.       const float *src = src_row;
  1908.       uint8_t *dst = dst_row;
  1909.       for(x = 0; x < width; x += 1) {
  1910.          uint32_t value = 0;
  1911.          value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
  1912.          value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16;
  1913.          *(uint32_t *)dst = value;
  1914.          src += 4;
  1915.          dst += 4;
  1916.       }
  1917.       dst_row += dst_stride;
  1918.       src_row += src_stride/sizeof(*src_row);
  1919.    }
  1920. }
  1921.  
  1922. static INLINE void
  1923. util_format_l16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  1924. {
  1925.          uint32_t value = *(const uint32_t *)src;
  1926.          uint32_t rgb;
  1927.          uint32_t a;
  1928.          rgb = (value) & 0xffff;
  1929.          a = value >> 16;
  1930.          dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */
  1931.          dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */
  1932.          dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */
  1933.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  1934. }
  1935.  
  1936. static INLINE void
  1937. util_format_l16a16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1938. {
  1939.    unsigned x, y;
  1940.    for(y = 0; y < height; y += 1) {
  1941.       uint8_t *dst = dst_row;
  1942.       const uint8_t *src = src_row;
  1943.       for(x = 0; x < width; x += 1) {
  1944.          uint32_t value = *(const uint32_t *)src;
  1945.          uint32_t rgb;
  1946.          uint32_t a;
  1947.          rgb = (value) & 0xffff;
  1948.          a = value >> 16;
  1949.          dst[0] = (uint8_t)(rgb >> 8); /* r */
  1950.          dst[1] = (uint8_t)(rgb >> 8); /* g */
  1951.          dst[2] = (uint8_t)(rgb >> 8); /* b */
  1952.          dst[3] = (uint8_t)(a >> 8); /* a */
  1953.          src += 4;
  1954.          dst += 4;
  1955.       }
  1956.       src_row += src_stride;
  1957.       dst_row += dst_stride/sizeof(*dst_row);
  1958.    }
  1959. }
  1960.  
  1961. static INLINE void
  1962. util_format_l16a16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1963. {
  1964.    unsigned x, y;
  1965.    for(y = 0; y < height; y += 1) {
  1966.       const uint8_t *src = src_row;
  1967.       uint8_t *dst = dst_row;
  1968.       for(x = 0; x < width; x += 1) {
  1969.          uint32_t value = 0;
  1970.          value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
  1971.          value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16;
  1972.          *(uint32_t *)dst = value;
  1973.          src += 4;
  1974.          dst += 4;
  1975.       }
  1976.       dst_row += dst_stride;
  1977.       src_row += src_stride/sizeof(*src_row);
  1978.    }
  1979. }
  1980.  
  1981. union util_format_a8_snorm {
  1982.    uint8_t value;
  1983.    struct {
  1984.       int8_t a;
  1985.    } chan;
  1986. };
  1987.  
  1988. static INLINE void
  1989. util_format_a8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  1990. {
  1991.    unsigned x, y;
  1992.    for(y = 0; y < height; y += 1) {
  1993.       float *dst = dst_row;
  1994.       const uint8_t *src = src_row;
  1995.       for(x = 0; x < width; x += 1) {
  1996.          uint8_t value = *(const uint8_t *)src;
  1997.          int8_t a;
  1998.          a = (int8_t)(value) ;
  1999.          dst[0] = 0; /* r */
  2000.          dst[1] = 0; /* g */
  2001.          dst[2] = 0; /* b */
  2002.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  2003.          src += 1;
  2004.          dst += 4;
  2005.       }
  2006.       src_row += src_stride;
  2007.       dst_row += dst_stride/sizeof(*dst_row);
  2008.    }
  2009. }
  2010.  
  2011. static INLINE void
  2012. util_format_a8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2013. {
  2014.    unsigned x, y;
  2015.    for(y = 0; y < height; y += 1) {
  2016.       const float *src = src_row;
  2017.       uint8_t *dst = dst_row;
  2018.       for(x = 0; x < width; x += 1) {
  2019.          uint8_t value = 0;
  2020.          value |= (uint8_t)((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) ;
  2021.          *(uint8_t *)dst = value;
  2022.          src += 4;
  2023.          dst += 1;
  2024.       }
  2025.       dst_row += dst_stride;
  2026.       src_row += src_stride/sizeof(*src_row);
  2027.    }
  2028. }
  2029.  
  2030. static INLINE void
  2031. util_format_a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2032. {
  2033.          uint8_t value = *(const uint8_t *)src;
  2034.          int8_t a;
  2035.          a = (int8_t)(value) ;
  2036.          dst[0] = 0; /* r */
  2037.          dst[1] = 0; /* g */
  2038.          dst[2] = 0; /* b */
  2039.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  2040. }
  2041.  
  2042. static INLINE void
  2043. util_format_a8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2044. {
  2045.    unsigned x, y;
  2046.    for(y = 0; y < height; y += 1) {
  2047.       uint8_t *dst = dst_row;
  2048.       const uint8_t *src = src_row;
  2049.       for(x = 0; x < width; x += 1) {
  2050.          uint8_t value = *(const uint8_t *)src;
  2051.          int8_t a;
  2052.          a = (int8_t)(value) ;
  2053.          dst[0] = 0; /* r */
  2054.          dst[1] = 0; /* g */
  2055.          dst[2] = 0; /* b */
  2056.          dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
  2057.          src += 1;
  2058.          dst += 4;
  2059.       }
  2060.       src_row += src_stride;
  2061.       dst_row += dst_stride/sizeof(*dst_row);
  2062.    }
  2063. }
  2064.  
  2065. static INLINE void
  2066. util_format_a8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2067. {
  2068.    unsigned x, y;
  2069.    for(y = 0; y < height; y += 1) {
  2070.       const uint8_t *src = src_row;
  2071.       uint8_t *dst = dst_row;
  2072.       for(x = 0; x < width; x += 1) {
  2073.          uint8_t value = 0;
  2074.          value |= (uint8_t)((int8_t)(src[3] >> 1)) ;
  2075.          *(uint8_t *)dst = value;
  2076.          src += 4;
  2077.          dst += 1;
  2078.       }
  2079.       dst_row += dst_stride;
  2080.       src_row += src_stride/sizeof(*src_row);
  2081.    }
  2082. }
  2083.  
  2084. union util_format_l8_snorm {
  2085.    uint8_t value;
  2086.    struct {
  2087.       int8_t rgb;
  2088.    } chan;
  2089. };
  2090.  
  2091. static INLINE void
  2092. util_format_l8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2093. {
  2094.    unsigned x, y;
  2095.    for(y = 0; y < height; y += 1) {
  2096.       float *dst = dst_row;
  2097.       const uint8_t *src = src_row;
  2098.       for(x = 0; x < width; x += 1) {
  2099.          uint8_t value = *(const uint8_t *)src;
  2100.          int8_t rgb;
  2101.          rgb = (int8_t)(value) ;
  2102.          dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
  2103.          dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
  2104.          dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
  2105.          dst[3] = 1; /* a */
  2106.          src += 1;
  2107.          dst += 4;
  2108.       }
  2109.       src_row += src_stride;
  2110.       dst_row += dst_stride/sizeof(*dst_row);
  2111.    }
  2112. }
  2113.  
  2114. static INLINE void
  2115. util_format_l8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2116. {
  2117.    unsigned x, y;
  2118.    for(y = 0; y < height; y += 1) {
  2119.       const float *src = src_row;
  2120.       uint8_t *dst = dst_row;
  2121.       for(x = 0; x < width; x += 1) {
  2122.          uint8_t value = 0;
  2123.          value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
  2124.          *(uint8_t *)dst = value;
  2125.          src += 4;
  2126.          dst += 1;
  2127.       }
  2128.       dst_row += dst_stride;
  2129.       src_row += src_stride/sizeof(*src_row);
  2130.    }
  2131. }
  2132.  
  2133. static INLINE void
  2134. util_format_l8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2135. {
  2136.          uint8_t value = *(const uint8_t *)src;
  2137.          int8_t rgb;
  2138.          rgb = (int8_t)(value) ;
  2139.          dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
  2140.          dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
  2141.          dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
  2142.          dst[3] = 1; /* a */
  2143. }
  2144.  
  2145. static INLINE void
  2146. util_format_l8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2147. {
  2148.    unsigned x, y;
  2149.    for(y = 0; y < height; y += 1) {
  2150.       uint8_t *dst = dst_row;
  2151.       const uint8_t *src = src_row;
  2152.       for(x = 0; x < width; x += 1) {
  2153.          uint8_t value = *(const uint8_t *)src;
  2154.          int8_t rgb;
  2155.          rgb = (int8_t)(value) ;
  2156.          dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */
  2157.          dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */
  2158.          dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */
  2159.          dst[3] = 255; /* a */
  2160.          src += 1;
  2161.          dst += 4;
  2162.       }
  2163.       src_row += src_stride;
  2164.       dst_row += dst_stride/sizeof(*dst_row);
  2165.    }
  2166. }
  2167.  
  2168. static INLINE void
  2169. util_format_l8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2170. {
  2171.    unsigned x, y;
  2172.    for(y = 0; y < height; y += 1) {
  2173.       const uint8_t *src = src_row;
  2174.       uint8_t *dst = dst_row;
  2175.       for(x = 0; x < width; x += 1) {
  2176.          uint8_t value = 0;
  2177.          value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
  2178.          *(uint8_t *)dst = value;
  2179.          src += 4;
  2180.          dst += 1;
  2181.       }
  2182.       dst_row += dst_stride;
  2183.       src_row += src_stride/sizeof(*src_row);
  2184.    }
  2185. }
  2186.  
  2187. union util_format_l8a8_snorm {
  2188.    uint16_t value;
  2189.    struct {
  2190.       int8_t rgb;
  2191.       int8_t a;
  2192.    } chan;
  2193. };
  2194.  
  2195. static INLINE void
  2196. util_format_l8a8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2197. {
  2198.    unsigned x, y;
  2199.    for(y = 0; y < height; y += 1) {
  2200.       float *dst = dst_row;
  2201.       const uint8_t *src = src_row;
  2202.       for(x = 0; x < width; x += 1) {
  2203.          uint16_t value = *(const uint16_t *)src;
  2204.          int16_t rgb;
  2205.          int16_t a;
  2206.          rgb = ((int16_t)(value << 8) ) >> 8;
  2207.          a = ((int16_t)(value) ) >> 8;
  2208.          dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
  2209.          dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
  2210.          dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
  2211.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  2212.          src += 2;
  2213.          dst += 4;
  2214.       }
  2215.       src_row += src_stride;
  2216.       dst_row += dst_stride/sizeof(*dst_row);
  2217.    }
  2218. }
  2219.  
  2220. static INLINE void
  2221. util_format_l8a8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2222. {
  2223.    unsigned x, y;
  2224.    for(y = 0; y < height; y += 1) {
  2225.       const float *src = src_row;
  2226.       uint8_t *dst = dst_row;
  2227.       for(x = 0; x < width; x += 1) {
  2228.          uint16_t value = 0;
  2229.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  2230.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ;
  2231.          *(uint16_t *)dst = value;
  2232.          src += 4;
  2233.          dst += 2;
  2234.       }
  2235.       dst_row += dst_stride;
  2236.       src_row += src_stride/sizeof(*src_row);
  2237.    }
  2238. }
  2239.  
  2240. static INLINE void
  2241. util_format_l8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2242. {
  2243.          uint16_t value = *(const uint16_t *)src;
  2244.          int16_t rgb;
  2245.          int16_t a;
  2246.          rgb = ((int16_t)(value << 8) ) >> 8;
  2247.          a = ((int16_t)(value) ) >> 8;
  2248.          dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */
  2249.          dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */
  2250.          dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */
  2251.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  2252. }
  2253.  
  2254. static INLINE void
  2255. util_format_l8a8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2256. {
  2257.    unsigned x, y;
  2258.    for(y = 0; y < height; y += 1) {
  2259.       uint8_t *dst = dst_row;
  2260.       const uint8_t *src = src_row;
  2261.       for(x = 0; x < width; x += 1) {
  2262.          uint16_t value = *(const uint16_t *)src;
  2263.          int16_t rgb;
  2264.          int16_t a;
  2265.          rgb = ((int16_t)(value << 8) ) >> 8;
  2266.          a = ((int16_t)(value) ) >> 8;
  2267.          dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */
  2268.          dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */
  2269.          dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */
  2270.          dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
  2271.          src += 2;
  2272.          dst += 4;
  2273.       }
  2274.       src_row += src_stride;
  2275.       dst_row += dst_stride/sizeof(*dst_row);
  2276.    }
  2277. }
  2278.  
  2279. static INLINE void
  2280. util_format_l8a8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2281. {
  2282.    unsigned x, y;
  2283.    for(y = 0; y < height; y += 1) {
  2284.       const uint8_t *src = src_row;
  2285.       uint8_t *dst = dst_row;
  2286.       for(x = 0; x < width; x += 1) {
  2287.          uint16_t value = 0;
  2288.          value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
  2289.          value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ;
  2290.          *(uint16_t *)dst = value;
  2291.          src += 4;
  2292.          dst += 2;
  2293.       }
  2294.       dst_row += dst_stride;
  2295.       src_row += src_stride/sizeof(*src_row);
  2296.    }
  2297. }
  2298.  
  2299. union util_format_i8_snorm {
  2300.    uint8_t value;
  2301.    struct {
  2302.       int8_t rgba;
  2303.    } chan;
  2304. };
  2305.  
  2306. static INLINE void
  2307. util_format_i8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2308. {
  2309.    unsigned x, y;
  2310.    for(y = 0; y < height; y += 1) {
  2311.       float *dst = dst_row;
  2312.       const uint8_t *src = src_row;
  2313.       for(x = 0; x < width; x += 1) {
  2314.          uint8_t value = *(const uint8_t *)src;
  2315.          int8_t rgba;
  2316.          rgba = (int8_t)(value) ;
  2317.          dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */
  2318.          dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */
  2319.          dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */
  2320.          dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */
  2321.          src += 1;
  2322.          dst += 4;
  2323.       }
  2324.       src_row += src_stride;
  2325.       dst_row += dst_stride/sizeof(*dst_row);
  2326.    }
  2327. }
  2328.  
  2329. static INLINE void
  2330. util_format_i8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2331. {
  2332.    unsigned x, y;
  2333.    for(y = 0; y < height; y += 1) {
  2334.       const float *src = src_row;
  2335.       uint8_t *dst = dst_row;
  2336.       for(x = 0; x < width; x += 1) {
  2337.          uint8_t value = 0;
  2338.          value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
  2339.          *(uint8_t *)dst = value;
  2340.          src += 4;
  2341.          dst += 1;
  2342.       }
  2343.       dst_row += dst_stride;
  2344.       src_row += src_stride/sizeof(*src_row);
  2345.    }
  2346. }
  2347.  
  2348. static INLINE void
  2349. util_format_i8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2350. {
  2351.          uint8_t value = *(const uint8_t *)src;
  2352.          int8_t rgba;
  2353.          rgba = (int8_t)(value) ;
  2354.          dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */
  2355.          dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */
  2356.          dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */
  2357.          dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */
  2358. }
  2359.  
  2360. static INLINE void
  2361. util_format_i8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2362. {
  2363.    unsigned x, y;
  2364.    for(y = 0; y < height; y += 1) {
  2365.       uint8_t *dst = dst_row;
  2366.       const uint8_t *src = src_row;
  2367.       for(x = 0; x < width; x += 1) {
  2368.          uint8_t value = *(const uint8_t *)src;
  2369.          int8_t rgba;
  2370.          rgba = (int8_t)(value) ;
  2371.          dst[0] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* r */
  2372.          dst[1] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* g */
  2373.          dst[2] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* b */
  2374.          dst[3] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* a */
  2375.          src += 1;
  2376.          dst += 4;
  2377.       }
  2378.       src_row += src_stride;
  2379.       dst_row += dst_stride/sizeof(*dst_row);
  2380.    }
  2381. }
  2382.  
  2383. static INLINE void
  2384. util_format_i8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2385. {
  2386.    unsigned x, y;
  2387.    for(y = 0; y < height; y += 1) {
  2388.       const uint8_t *src = src_row;
  2389.       uint8_t *dst = dst_row;
  2390.       for(x = 0; x < width; x += 1) {
  2391.          uint8_t value = 0;
  2392.          value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
  2393.          *(uint8_t *)dst = value;
  2394.          src += 4;
  2395.          dst += 1;
  2396.       }
  2397.       dst_row += dst_stride;
  2398.       src_row += src_stride/sizeof(*src_row);
  2399.    }
  2400. }
  2401.  
  2402. union util_format_a16_snorm {
  2403.    uint16_t value;
  2404.    struct {
  2405.       int16_t a;
  2406.    } chan;
  2407. };
  2408.  
  2409. static INLINE void
  2410. util_format_a16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2411. {
  2412.    unsigned x, y;
  2413.    for(y = 0; y < height; y += 1) {
  2414.       float *dst = dst_row;
  2415.       const uint8_t *src = src_row;
  2416.       for(x = 0; x < width; x += 1) {
  2417.          uint16_t value = *(const uint16_t *)src;
  2418.          int16_t a;
  2419.          a = (int16_t)(value) ;
  2420.          dst[0] = 0; /* r */
  2421.          dst[1] = 0; /* g */
  2422.          dst[2] = 0; /* b */
  2423.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  2424.          src += 2;
  2425.          dst += 4;
  2426.       }
  2427.       src_row += src_stride;
  2428.       dst_row += dst_stride/sizeof(*dst_row);
  2429.    }
  2430. }
  2431.  
  2432. static INLINE void
  2433. util_format_a16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2434. {
  2435.    unsigned x, y;
  2436.    for(y = 0; y < height; y += 1) {
  2437.       const float *src = src_row;
  2438.       uint8_t *dst = dst_row;
  2439.       for(x = 0; x < width; x += 1) {
  2440.          uint16_t value = 0;
  2441.          value |= (uint16_t)((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) ;
  2442.          *(uint16_t *)dst = value;
  2443.          src += 4;
  2444.          dst += 2;
  2445.       }
  2446.       dst_row += dst_stride;
  2447.       src_row += src_stride/sizeof(*src_row);
  2448.    }
  2449. }
  2450.  
  2451. static INLINE void
  2452. util_format_a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2453. {
  2454.          uint16_t value = *(const uint16_t *)src;
  2455.          int16_t a;
  2456.          a = (int16_t)(value) ;
  2457.          dst[0] = 0; /* r */
  2458.          dst[1] = 0; /* g */
  2459.          dst[2] = 0; /* b */
  2460.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  2461. }
  2462.  
  2463. static INLINE void
  2464. util_format_a16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2465. {
  2466.    unsigned x, y;
  2467.    for(y = 0; y < height; y += 1) {
  2468.       uint8_t *dst = dst_row;
  2469.       const uint8_t *src = src_row;
  2470.       for(x = 0; x < width; x += 1) {
  2471.          uint16_t value = *(const uint16_t *)src;
  2472.          int16_t a;
  2473.          a = (int16_t)(value) ;
  2474.          dst[0] = 0; /* r */
  2475.          dst[1] = 0; /* g */
  2476.          dst[2] = 0; /* b */
  2477.          dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
  2478.          src += 2;
  2479.          dst += 4;
  2480.       }
  2481.       src_row += src_stride;
  2482.       dst_row += dst_stride/sizeof(*dst_row);
  2483.    }
  2484. }
  2485.  
  2486. static INLINE void
  2487. util_format_a16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2488. {
  2489.    unsigned x, y;
  2490.    for(y = 0; y < height; y += 1) {
  2491.       const uint8_t *src = src_row;
  2492.       uint8_t *dst = dst_row;
  2493.       for(x = 0; x < width; x += 1) {
  2494.          uint16_t value = 0;
  2495.          value |= (uint16_t)((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) ;
  2496.          *(uint16_t *)dst = value;
  2497.          src += 4;
  2498.          dst += 2;
  2499.       }
  2500.       dst_row += dst_stride;
  2501.       src_row += src_stride/sizeof(*src_row);
  2502.    }
  2503. }
  2504.  
  2505. union util_format_l16_snorm {
  2506.    uint16_t value;
  2507.    struct {
  2508.       int16_t rgb;
  2509.    } chan;
  2510. };
  2511.  
  2512. static INLINE void
  2513. util_format_l16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2514. {
  2515.    unsigned x, y;
  2516.    for(y = 0; y < height; y += 1) {
  2517.       float *dst = dst_row;
  2518.       const uint8_t *src = src_row;
  2519.       for(x = 0; x < width; x += 1) {
  2520.          uint16_t value = *(const uint16_t *)src;
  2521.          int16_t rgb;
  2522.          rgb = (int16_t)(value) ;
  2523.          dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
  2524.          dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
  2525.          dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
  2526.          dst[3] = 1; /* a */
  2527.          src += 2;
  2528.          dst += 4;
  2529.       }
  2530.       src_row += src_stride;
  2531.       dst_row += dst_stride/sizeof(*dst_row);
  2532.    }
  2533. }
  2534.  
  2535. static INLINE void
  2536. util_format_l16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2537. {
  2538.    unsigned x, y;
  2539.    for(y = 0; y < height; y += 1) {
  2540.       const float *src = src_row;
  2541.       uint8_t *dst = dst_row;
  2542.       for(x = 0; x < width; x += 1) {
  2543.          uint16_t value = 0;
  2544.          value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
  2545.          *(uint16_t *)dst = value;
  2546.          src += 4;
  2547.          dst += 2;
  2548.       }
  2549.       dst_row += dst_stride;
  2550.       src_row += src_stride/sizeof(*src_row);
  2551.    }
  2552. }
  2553.  
  2554. static INLINE void
  2555. util_format_l16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2556. {
  2557.          uint16_t value = *(const uint16_t *)src;
  2558.          int16_t rgb;
  2559.          rgb = (int16_t)(value) ;
  2560.          dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
  2561.          dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
  2562.          dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
  2563.          dst[3] = 1; /* a */
  2564. }
  2565.  
  2566. static INLINE void
  2567. util_format_l16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2568. {
  2569.    unsigned x, y;
  2570.    for(y = 0; y < height; y += 1) {
  2571.       uint8_t *dst = dst_row;
  2572.       const uint8_t *src = src_row;
  2573.       for(x = 0; x < width; x += 1) {
  2574.          uint16_t value = *(const uint16_t *)src;
  2575.          int16_t rgb;
  2576.          rgb = (int16_t)(value) ;
  2577.          dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */
  2578.          dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */
  2579.          dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */
  2580.          dst[3] = 255; /* a */
  2581.          src += 2;
  2582.          dst += 4;
  2583.       }
  2584.       src_row += src_stride;
  2585.       dst_row += dst_stride/sizeof(*dst_row);
  2586.    }
  2587. }
  2588.  
  2589. static INLINE void
  2590. util_format_l16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2591. {
  2592.    unsigned x, y;
  2593.    for(y = 0; y < height; y += 1) {
  2594.       const uint8_t *src = src_row;
  2595.       uint8_t *dst = dst_row;
  2596.       for(x = 0; x < width; x += 1) {
  2597.          uint16_t value = 0;
  2598.          value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
  2599.          *(uint16_t *)dst = value;
  2600.          src += 4;
  2601.          dst += 2;
  2602.       }
  2603.       dst_row += dst_stride;
  2604.       src_row += src_stride/sizeof(*src_row);
  2605.    }
  2606. }
  2607.  
  2608. union util_format_l16a16_snorm {
  2609.    uint32_t value;
  2610.    struct {
  2611.       int16_t rgb;
  2612.       int16_t a;
  2613.    } chan;
  2614. };
  2615.  
  2616. static INLINE void
  2617. util_format_l16a16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2618. {
  2619.    unsigned x, y;
  2620.    for(y = 0; y < height; y += 1) {
  2621.       float *dst = dst_row;
  2622.       const uint8_t *src = src_row;
  2623.       for(x = 0; x < width; x += 1) {
  2624.          uint32_t value = *(const uint32_t *)src;
  2625.          int32_t rgb;
  2626.          int32_t a;
  2627.          rgb = ((int32_t)(value << 16) ) >> 16;
  2628.          a = ((int32_t)(value) ) >> 16;
  2629.          dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
  2630.          dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
  2631.          dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
  2632.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  2633.          src += 4;
  2634.          dst += 4;
  2635.       }
  2636.       src_row += src_stride;
  2637.       dst_row += dst_stride/sizeof(*dst_row);
  2638.    }
  2639. }
  2640.  
  2641. static INLINE void
  2642. util_format_l16a16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2643. {
  2644.    unsigned x, y;
  2645.    for(y = 0; y < height; y += 1) {
  2646.       const float *src = src_row;
  2647.       uint8_t *dst = dst_row;
  2648.       for(x = 0; x < width; x += 1) {
  2649.          uint32_t value = 0;
  2650.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
  2651.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ;
  2652.          *(uint32_t *)dst = value;
  2653.          src += 4;
  2654.          dst += 4;
  2655.       }
  2656.       dst_row += dst_stride;
  2657.       src_row += src_stride/sizeof(*src_row);
  2658.    }
  2659. }
  2660.  
  2661. static INLINE void
  2662. util_format_l16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2663. {
  2664.          uint32_t value = *(const uint32_t *)src;
  2665.          int32_t rgb;
  2666.          int32_t a;
  2667.          rgb = ((int32_t)(value << 16) ) >> 16;
  2668.          a = ((int32_t)(value) ) >> 16;
  2669.          dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */
  2670.          dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */
  2671.          dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */
  2672.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  2673. }
  2674.  
  2675. static INLINE void
  2676. util_format_l16a16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2677. {
  2678.    unsigned x, y;
  2679.    for(y = 0; y < height; y += 1) {
  2680.       uint8_t *dst = dst_row;
  2681.       const uint8_t *src = src_row;
  2682.       for(x = 0; x < width; x += 1) {
  2683.          uint32_t value = *(const uint32_t *)src;
  2684.          int32_t rgb;
  2685.          int32_t a;
  2686.          rgb = ((int32_t)(value << 16) ) >> 16;
  2687.          a = ((int32_t)(value) ) >> 16;
  2688.          dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */
  2689.          dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */
  2690.          dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */
  2691.          dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
  2692.          src += 4;
  2693.          dst += 4;
  2694.       }
  2695.       src_row += src_stride;
  2696.       dst_row += dst_stride/sizeof(*dst_row);
  2697.    }
  2698. }
  2699.  
  2700. static INLINE void
  2701. util_format_l16a16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2702. {
  2703.    unsigned x, y;
  2704.    for(y = 0; y < height; y += 1) {
  2705.       const uint8_t *src = src_row;
  2706.       uint8_t *dst = dst_row;
  2707.       for(x = 0; x < width; x += 1) {
  2708.          uint32_t value = 0;
  2709.          value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
  2710.          value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ;
  2711.          *(uint32_t *)dst = value;
  2712.          src += 4;
  2713.          dst += 4;
  2714.       }
  2715.       dst_row += dst_stride;
  2716.       src_row += src_stride/sizeof(*src_row);
  2717.    }
  2718. }
  2719.  
  2720. union util_format_i16_snorm {
  2721.    uint16_t value;
  2722.    struct {
  2723.       int16_t rgba;
  2724.    } chan;
  2725. };
  2726.  
  2727. static INLINE void
  2728. util_format_i16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2729. {
  2730.    unsigned x, y;
  2731.    for(y = 0; y < height; y += 1) {
  2732.       float *dst = dst_row;
  2733.       const uint8_t *src = src_row;
  2734.       for(x = 0; x < width; x += 1) {
  2735.          uint16_t value = *(const uint16_t *)src;
  2736.          int16_t rgba;
  2737.          rgba = (int16_t)(value) ;
  2738.          dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */
  2739.          dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */
  2740.          dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */
  2741.          dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */
  2742.          src += 2;
  2743.          dst += 4;
  2744.       }
  2745.       src_row += src_stride;
  2746.       dst_row += dst_stride/sizeof(*dst_row);
  2747.    }
  2748. }
  2749.  
  2750. static INLINE void
  2751. util_format_i16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2752. {
  2753.    unsigned x, y;
  2754.    for(y = 0; y < height; y += 1) {
  2755.       const float *src = src_row;
  2756.       uint8_t *dst = dst_row;
  2757.       for(x = 0; x < width; x += 1) {
  2758.          uint16_t value = 0;
  2759.          value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
  2760.          *(uint16_t *)dst = value;
  2761.          src += 4;
  2762.          dst += 2;
  2763.       }
  2764.       dst_row += dst_stride;
  2765.       src_row += src_stride/sizeof(*src_row);
  2766.    }
  2767. }
  2768.  
  2769. static INLINE void
  2770. util_format_i16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2771. {
  2772.          uint16_t value = *(const uint16_t *)src;
  2773.          int16_t rgba;
  2774.          rgba = (int16_t)(value) ;
  2775.          dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */
  2776.          dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */
  2777.          dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */
  2778.          dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */
  2779. }
  2780.  
  2781. static INLINE void
  2782. util_format_i16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2783. {
  2784.    unsigned x, y;
  2785.    for(y = 0; y < height; y += 1) {
  2786.       uint8_t *dst = dst_row;
  2787.       const uint8_t *src = src_row;
  2788.       for(x = 0; x < width; x += 1) {
  2789.          uint16_t value = *(const uint16_t *)src;
  2790.          int16_t rgba;
  2791.          rgba = (int16_t)(value) ;
  2792.          dst[0] = (uint8_t)(MAX2(rgba, 0) >> 7); /* r */
  2793.          dst[1] = (uint8_t)(MAX2(rgba, 0) >> 7); /* g */
  2794.          dst[2] = (uint8_t)(MAX2(rgba, 0) >> 7); /* b */
  2795.          dst[3] = (uint8_t)(MAX2(rgba, 0) >> 7); /* a */
  2796.          src += 2;
  2797.          dst += 4;
  2798.       }
  2799.       src_row += src_stride;
  2800.       dst_row += dst_stride/sizeof(*dst_row);
  2801.    }
  2802. }
  2803.  
  2804. static INLINE void
  2805. util_format_i16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2806. {
  2807.    unsigned x, y;
  2808.    for(y = 0; y < height; y += 1) {
  2809.       const uint8_t *src = src_row;
  2810.       uint8_t *dst = dst_row;
  2811.       for(x = 0; x < width; x += 1) {
  2812.          uint16_t value = 0;
  2813.          value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
  2814.          *(uint16_t *)dst = value;
  2815.          src += 4;
  2816.          dst += 2;
  2817.       }
  2818.       dst_row += dst_stride;
  2819.       src_row += src_stride/sizeof(*src_row);
  2820.    }
  2821. }
  2822.  
  2823. union util_format_a16_float {
  2824.    uint16_t value;
  2825.    struct {
  2826.       uint16_t a;
  2827.    } chan;
  2828. };
  2829.  
  2830. static INLINE void
  2831. util_format_a16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2832. {
  2833.    unsigned x, y;
  2834.    for(y = 0; y < height; y += 1) {
  2835.       float *dst = dst_row;
  2836.       const uint8_t *src = src_row;
  2837.       for(x = 0; x < width; x += 1) {
  2838.          union util_format_a16_float pixel;
  2839.          memcpy(&pixel, src, sizeof pixel);
  2840.          dst[0] = 0; /* r */
  2841.          dst[1] = 0; /* g */
  2842.          dst[2] = 0; /* b */
  2843.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  2844.          src += 2;
  2845.          dst += 4;
  2846.       }
  2847.       src_row += src_stride;
  2848.       dst_row += dst_stride/sizeof(*dst_row);
  2849.    }
  2850. }
  2851.  
  2852. static INLINE void
  2853. util_format_a16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2854. {
  2855.    unsigned x, y;
  2856.    for(y = 0; y < height; y += 1) {
  2857.       const float *src = src_row;
  2858.       uint8_t *dst = dst_row;
  2859.       for(x = 0; x < width; x += 1) {
  2860.          union util_format_a16_float pixel;
  2861.          pixel.chan.a = util_float_to_half(src[3]);
  2862.          memcpy(dst, &pixel, sizeof pixel);
  2863.          src += 4;
  2864.          dst += 2;
  2865.       }
  2866.       dst_row += dst_stride;
  2867.       src_row += src_stride/sizeof(*src_row);
  2868.    }
  2869. }
  2870.  
  2871. static INLINE void
  2872. util_format_a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2873. {
  2874.          union util_format_a16_float pixel;
  2875.          memcpy(&pixel, src, sizeof pixel);
  2876.          dst[0] = 0; /* r */
  2877.          dst[1] = 0; /* g */
  2878.          dst[2] = 0; /* b */
  2879.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  2880. }
  2881.  
  2882. static INLINE void
  2883. util_format_a16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2884. {
  2885.    unsigned x, y;
  2886.    for(y = 0; y < height; y += 1) {
  2887.       uint8_t *dst = dst_row;
  2888.       const uint8_t *src = src_row;
  2889.       for(x = 0; x < width; x += 1) {
  2890.          union util_format_a16_float pixel;
  2891.          memcpy(&pixel, src, sizeof pixel);
  2892.          dst[0] = 0; /* r */
  2893.          dst[1] = 0; /* g */
  2894.          dst[2] = 0; /* b */
  2895.          dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
  2896.          src += 2;
  2897.          dst += 4;
  2898.       }
  2899.       src_row += src_stride;
  2900.       dst_row += dst_stride/sizeof(*dst_row);
  2901.    }
  2902. }
  2903.  
  2904. static INLINE void
  2905. util_format_a16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2906. {
  2907.    unsigned x, y;
  2908.    for(y = 0; y < height; y += 1) {
  2909.       const uint8_t *src = src_row;
  2910.       uint8_t *dst = dst_row;
  2911.       for(x = 0; x < width; x += 1) {
  2912.          union util_format_a16_float pixel;
  2913.          pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
  2914.          memcpy(dst, &pixel, sizeof pixel);
  2915.          src += 4;
  2916.          dst += 2;
  2917.       }
  2918.       dst_row += dst_stride;
  2919.       src_row += src_stride/sizeof(*src_row);
  2920.    }
  2921. }
  2922.  
  2923. union util_format_l16_float {
  2924.    uint16_t value;
  2925.    struct {
  2926.       uint16_t rgb;
  2927.    } chan;
  2928. };
  2929.  
  2930. static INLINE void
  2931. util_format_l16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2932. {
  2933.    unsigned x, y;
  2934.    for(y = 0; y < height; y += 1) {
  2935.       float *dst = dst_row;
  2936.       const uint8_t *src = src_row;
  2937.       for(x = 0; x < width; x += 1) {
  2938.          union util_format_l16_float pixel;
  2939.          memcpy(&pixel, src, sizeof pixel);
  2940.          dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
  2941.          dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
  2942.          dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
  2943.          dst[3] = 1; /* a */
  2944.          src += 2;
  2945.          dst += 4;
  2946.       }
  2947.       src_row += src_stride;
  2948.       dst_row += dst_stride/sizeof(*dst_row);
  2949.    }
  2950. }
  2951.  
  2952. static INLINE void
  2953. util_format_l16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  2954. {
  2955.    unsigned x, y;
  2956.    for(y = 0; y < height; y += 1) {
  2957.       const float *src = src_row;
  2958.       uint8_t *dst = dst_row;
  2959.       for(x = 0; x < width; x += 1) {
  2960.          union util_format_l16_float pixel;
  2961.          pixel.chan.rgb = util_float_to_half(src[0]);
  2962.          memcpy(dst, &pixel, sizeof pixel);
  2963.          src += 4;
  2964.          dst += 2;
  2965.       }
  2966.       dst_row += dst_stride;
  2967.       src_row += src_stride/sizeof(*src_row);
  2968.    }
  2969. }
  2970.  
  2971. static INLINE void
  2972. util_format_l16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  2973. {
  2974.          union util_format_l16_float pixel;
  2975.          memcpy(&pixel, src, sizeof pixel);
  2976.          dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
  2977.          dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
  2978.          dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
  2979.          dst[3] = 1; /* a */
  2980. }
  2981.  
  2982. static INLINE void
  2983. util_format_l16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  2984. {
  2985.    unsigned x, y;
  2986.    for(y = 0; y < height; y += 1) {
  2987.       uint8_t *dst = dst_row;
  2988.       const uint8_t *src = src_row;
  2989.       for(x = 0; x < width; x += 1) {
  2990.          union util_format_l16_float pixel;
  2991.          memcpy(&pixel, src, sizeof pixel);
  2992.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */
  2993.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */
  2994.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */
  2995.          dst[3] = 255; /* a */
  2996.          src += 2;
  2997.          dst += 4;
  2998.       }
  2999.       src_row += src_stride;
  3000.       dst_row += dst_stride/sizeof(*dst_row);
  3001.    }
  3002. }
  3003.  
  3004. static INLINE void
  3005. util_format_l16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3006. {
  3007.    unsigned x, y;
  3008.    for(y = 0; y < height; y += 1) {
  3009.       const uint8_t *src = src_row;
  3010.       uint8_t *dst = dst_row;
  3011.       for(x = 0; x < width; x += 1) {
  3012.          union util_format_l16_float pixel;
  3013.          pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  3014.          memcpy(dst, &pixel, sizeof pixel);
  3015.          src += 4;
  3016.          dst += 2;
  3017.       }
  3018.       dst_row += dst_stride;
  3019.       src_row += src_stride/sizeof(*src_row);
  3020.    }
  3021. }
  3022.  
  3023. union util_format_l16a16_float {
  3024.    uint32_t value;
  3025.    struct {
  3026.       uint16_t rgb;
  3027.       uint16_t a;
  3028.    } chan;
  3029. };
  3030.  
  3031. static INLINE void
  3032. util_format_l16a16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3033. {
  3034.    unsigned x, y;
  3035.    for(y = 0; y < height; y += 1) {
  3036.       float *dst = dst_row;
  3037.       const uint8_t *src = src_row;
  3038.       for(x = 0; x < width; x += 1) {
  3039.          union util_format_l16a16_float pixel;
  3040.          memcpy(&pixel, src, sizeof pixel);
  3041.          dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
  3042.          dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
  3043.          dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
  3044.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  3045.          src += 4;
  3046.          dst += 4;
  3047.       }
  3048.       src_row += src_stride;
  3049.       dst_row += dst_stride/sizeof(*dst_row);
  3050.    }
  3051. }
  3052.  
  3053. static INLINE void
  3054. util_format_l16a16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3055. {
  3056.    unsigned x, y;
  3057.    for(y = 0; y < height; y += 1) {
  3058.       const float *src = src_row;
  3059.       uint8_t *dst = dst_row;
  3060.       for(x = 0; x < width; x += 1) {
  3061.          union util_format_l16a16_float pixel;
  3062.          pixel.chan.rgb = util_float_to_half(src[0]);
  3063.          pixel.chan.a = util_float_to_half(src[3]);
  3064.          memcpy(dst, &pixel, sizeof pixel);
  3065.          src += 4;
  3066.          dst += 4;
  3067.       }
  3068.       dst_row += dst_stride;
  3069.       src_row += src_stride/sizeof(*src_row);
  3070.    }
  3071. }
  3072.  
  3073. static INLINE void
  3074. util_format_l16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3075. {
  3076.          union util_format_l16a16_float pixel;
  3077.          memcpy(&pixel, src, sizeof pixel);
  3078.          dst[0] = util_half_to_float(pixel.chan.rgb); /* r */
  3079.          dst[1] = util_half_to_float(pixel.chan.rgb); /* g */
  3080.          dst[2] = util_half_to_float(pixel.chan.rgb); /* b */
  3081.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  3082. }
  3083.  
  3084. static INLINE void
  3085. util_format_l16a16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3086. {
  3087.    unsigned x, y;
  3088.    for(y = 0; y < height; y += 1) {
  3089.       uint8_t *dst = dst_row;
  3090.       const uint8_t *src = src_row;
  3091.       for(x = 0; x < width; x += 1) {
  3092.          union util_format_l16a16_float pixel;
  3093.          memcpy(&pixel, src, sizeof pixel);
  3094.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */
  3095.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */
  3096.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */
  3097.          dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
  3098.          src += 4;
  3099.          dst += 4;
  3100.       }
  3101.       src_row += src_stride;
  3102.       dst_row += dst_stride/sizeof(*dst_row);
  3103.    }
  3104. }
  3105.  
  3106. static INLINE void
  3107. util_format_l16a16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3108. {
  3109.    unsigned x, y;
  3110.    for(y = 0; y < height; y += 1) {
  3111.       const uint8_t *src = src_row;
  3112.       uint8_t *dst = dst_row;
  3113.       for(x = 0; x < width; x += 1) {
  3114.          union util_format_l16a16_float pixel;
  3115.          pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  3116.          pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
  3117.          memcpy(dst, &pixel, sizeof pixel);
  3118.          src += 4;
  3119.          dst += 4;
  3120.       }
  3121.       dst_row += dst_stride;
  3122.       src_row += src_stride/sizeof(*src_row);
  3123.    }
  3124. }
  3125.  
  3126. union util_format_i16_float {
  3127.    uint16_t value;
  3128.    struct {
  3129.       uint16_t rgba;
  3130.    } chan;
  3131. };
  3132.  
  3133. static INLINE void
  3134. util_format_i16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3135. {
  3136.    unsigned x, y;
  3137.    for(y = 0; y < height; y += 1) {
  3138.       float *dst = dst_row;
  3139.       const uint8_t *src = src_row;
  3140.       for(x = 0; x < width; x += 1) {
  3141.          union util_format_i16_float pixel;
  3142.          memcpy(&pixel, src, sizeof pixel);
  3143.          dst[0] = util_half_to_float(pixel.chan.rgba); /* r */
  3144.          dst[1] = util_half_to_float(pixel.chan.rgba); /* g */
  3145.          dst[2] = util_half_to_float(pixel.chan.rgba); /* b */
  3146.          dst[3] = util_half_to_float(pixel.chan.rgba); /* a */
  3147.          src += 2;
  3148.          dst += 4;
  3149.       }
  3150.       src_row += src_stride;
  3151.       dst_row += dst_stride/sizeof(*dst_row);
  3152.    }
  3153. }
  3154.  
  3155. static INLINE void
  3156. util_format_i16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3157. {
  3158.    unsigned x, y;
  3159.    for(y = 0; y < height; y += 1) {
  3160.       const float *src = src_row;
  3161.       uint8_t *dst = dst_row;
  3162.       for(x = 0; x < width; x += 1) {
  3163.          union util_format_i16_float pixel;
  3164.          pixel.chan.rgba = util_float_to_half(src[0]);
  3165.          memcpy(dst, &pixel, sizeof pixel);
  3166.          src += 4;
  3167.          dst += 2;
  3168.       }
  3169.       dst_row += dst_stride;
  3170.       src_row += src_stride/sizeof(*src_row);
  3171.    }
  3172. }
  3173.  
  3174. static INLINE void
  3175. util_format_i16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3176. {
  3177.          union util_format_i16_float pixel;
  3178.          memcpy(&pixel, src, sizeof pixel);
  3179.          dst[0] = util_half_to_float(pixel.chan.rgba); /* r */
  3180.          dst[1] = util_half_to_float(pixel.chan.rgba); /* g */
  3181.          dst[2] = util_half_to_float(pixel.chan.rgba); /* b */
  3182.          dst[3] = util_half_to_float(pixel.chan.rgba); /* a */
  3183. }
  3184.  
  3185. static INLINE void
  3186. util_format_i16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3187. {
  3188.    unsigned x, y;
  3189.    for(y = 0; y < height; y += 1) {
  3190.       uint8_t *dst = dst_row;
  3191.       const uint8_t *src = src_row;
  3192.       for(x = 0; x < width; x += 1) {
  3193.          union util_format_i16_float pixel;
  3194.          memcpy(&pixel, src, sizeof pixel);
  3195.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* r */
  3196.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* g */
  3197.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* b */
  3198.          dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* a */
  3199.          src += 2;
  3200.          dst += 4;
  3201.       }
  3202.       src_row += src_stride;
  3203.       dst_row += dst_stride/sizeof(*dst_row);
  3204.    }
  3205. }
  3206.  
  3207. static INLINE void
  3208. util_format_i16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3209. {
  3210.    unsigned x, y;
  3211.    for(y = 0; y < height; y += 1) {
  3212.       const uint8_t *src = src_row;
  3213.       uint8_t *dst = dst_row;
  3214.       for(x = 0; x < width; x += 1) {
  3215.          union util_format_i16_float pixel;
  3216.          pixel.chan.rgba = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  3217.          memcpy(dst, &pixel, sizeof pixel);
  3218.          src += 4;
  3219.          dst += 2;
  3220.       }
  3221.       dst_row += dst_stride;
  3222.       src_row += src_stride/sizeof(*src_row);
  3223.    }
  3224. }
  3225.  
  3226. union util_format_a32_float {
  3227.    uint32_t value;
  3228.    struct {
  3229.       float a;
  3230.    } chan;
  3231. };
  3232.  
  3233. static INLINE void
  3234. util_format_a32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3235. {
  3236.    unsigned x, y;
  3237.    for(y = 0; y < height; y += 1) {
  3238.       float *dst = dst_row;
  3239.       const uint8_t *src = src_row;
  3240.       for(x = 0; x < width; x += 1) {
  3241.          union util_format_a32_float pixel;
  3242.          memcpy(&pixel, src, sizeof pixel);
  3243.          dst[0] = 0; /* r */
  3244.          dst[1] = 0; /* g */
  3245.          dst[2] = 0; /* b */
  3246.          dst[3] = pixel.chan.a; /* a */
  3247.          src += 4;
  3248.          dst += 4;
  3249.       }
  3250.       src_row += src_stride;
  3251.       dst_row += dst_stride/sizeof(*dst_row);
  3252.    }
  3253. }
  3254.  
  3255. static INLINE void
  3256. util_format_a32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3257. {
  3258.    unsigned x, y;
  3259.    for(y = 0; y < height; y += 1) {
  3260.       const float *src = src_row;
  3261.       uint8_t *dst = dst_row;
  3262.       for(x = 0; x < width; x += 1) {
  3263.          union util_format_a32_float pixel;
  3264.          pixel.chan.a = src[3];
  3265.          memcpy(dst, &pixel, sizeof pixel);
  3266.          src += 4;
  3267.          dst += 4;
  3268.       }
  3269.       dst_row += dst_stride;
  3270.       src_row += src_stride/sizeof(*src_row);
  3271.    }
  3272. }
  3273.  
  3274. static INLINE void
  3275. util_format_a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3276. {
  3277.          union util_format_a32_float pixel;
  3278.          memcpy(&pixel, src, sizeof pixel);
  3279.          dst[0] = 0; /* r */
  3280.          dst[1] = 0; /* g */
  3281.          dst[2] = 0; /* b */
  3282.          dst[3] = pixel.chan.a; /* a */
  3283. }
  3284.  
  3285. static INLINE void
  3286. util_format_a32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3287. {
  3288.    unsigned x, y;
  3289.    for(y = 0; y < height; y += 1) {
  3290.       uint8_t *dst = dst_row;
  3291.       const uint8_t *src = src_row;
  3292.       for(x = 0; x < width; x += 1) {
  3293.          union util_format_a32_float pixel;
  3294.          memcpy(&pixel, src, sizeof pixel);
  3295.          dst[0] = 0; /* r */
  3296.          dst[1] = 0; /* g */
  3297.          dst[2] = 0; /* b */
  3298.          dst[3] = float_to_ubyte(pixel.chan.a); /* a */
  3299.          src += 4;
  3300.          dst += 4;
  3301.       }
  3302.       src_row += src_stride;
  3303.       dst_row += dst_stride/sizeof(*dst_row);
  3304.    }
  3305. }
  3306.  
  3307. static INLINE void
  3308. util_format_a32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3309. {
  3310.    unsigned x, y;
  3311.    for(y = 0; y < height; y += 1) {
  3312.       const uint8_t *src = src_row;
  3313.       uint8_t *dst = dst_row;
  3314.       for(x = 0; x < width; x += 1) {
  3315.          union util_format_a32_float pixel;
  3316.          pixel.chan.a = ubyte_to_float(src[3]);
  3317.          memcpy(dst, &pixel, sizeof pixel);
  3318.          src += 4;
  3319.          dst += 4;
  3320.       }
  3321.       dst_row += dst_stride;
  3322.       src_row += src_stride/sizeof(*src_row);
  3323.    }
  3324. }
  3325.  
  3326. union util_format_l32_float {
  3327.    uint32_t value;
  3328.    struct {
  3329.       float rgb;
  3330.    } chan;
  3331. };
  3332.  
  3333. static INLINE void
  3334. util_format_l32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3335. {
  3336.    unsigned x, y;
  3337.    for(y = 0; y < height; y += 1) {
  3338.       float *dst = dst_row;
  3339.       const uint8_t *src = src_row;
  3340.       for(x = 0; x < width; x += 1) {
  3341.          union util_format_l32_float pixel;
  3342.          memcpy(&pixel, src, sizeof pixel);
  3343.          dst[0] = pixel.chan.rgb; /* r */
  3344.          dst[1] = pixel.chan.rgb; /* g */
  3345.          dst[2] = pixel.chan.rgb; /* b */
  3346.          dst[3] = 1; /* a */
  3347.          src += 4;
  3348.          dst += 4;
  3349.       }
  3350.       src_row += src_stride;
  3351.       dst_row += dst_stride/sizeof(*dst_row);
  3352.    }
  3353. }
  3354.  
  3355. static INLINE void
  3356. util_format_l32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3357. {
  3358.    unsigned x, y;
  3359.    for(y = 0; y < height; y += 1) {
  3360.       const float *src = src_row;
  3361.       uint8_t *dst = dst_row;
  3362.       for(x = 0; x < width; x += 1) {
  3363.          union util_format_l32_float pixel;
  3364.          pixel.chan.rgb = src[0];
  3365.          memcpy(dst, &pixel, sizeof pixel);
  3366.          src += 4;
  3367.          dst += 4;
  3368.       }
  3369.       dst_row += dst_stride;
  3370.       src_row += src_stride/sizeof(*src_row);
  3371.    }
  3372. }
  3373.  
  3374. static INLINE void
  3375. util_format_l32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3376. {
  3377.          union util_format_l32_float pixel;
  3378.          memcpy(&pixel, src, sizeof pixel);
  3379.          dst[0] = pixel.chan.rgb; /* r */
  3380.          dst[1] = pixel.chan.rgb; /* g */
  3381.          dst[2] = pixel.chan.rgb; /* b */
  3382.          dst[3] = 1; /* a */
  3383. }
  3384.  
  3385. static INLINE void
  3386. util_format_l32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3387. {
  3388.    unsigned x, y;
  3389.    for(y = 0; y < height; y += 1) {
  3390.       uint8_t *dst = dst_row;
  3391.       const uint8_t *src = src_row;
  3392.       for(x = 0; x < width; x += 1) {
  3393.          union util_format_l32_float pixel;
  3394.          memcpy(&pixel, src, sizeof pixel);
  3395.          dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */
  3396.          dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */
  3397.          dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */
  3398.          dst[3] = 255; /* a */
  3399.          src += 4;
  3400.          dst += 4;
  3401.       }
  3402.       src_row += src_stride;
  3403.       dst_row += dst_stride/sizeof(*dst_row);
  3404.    }
  3405. }
  3406.  
  3407. static INLINE void
  3408. util_format_l32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3409. {
  3410.    unsigned x, y;
  3411.    for(y = 0; y < height; y += 1) {
  3412.       const uint8_t *src = src_row;
  3413.       uint8_t *dst = dst_row;
  3414.       for(x = 0; x < width; x += 1) {
  3415.          union util_format_l32_float pixel;
  3416.          pixel.chan.rgb = ubyte_to_float(src[0]);
  3417.          memcpy(dst, &pixel, sizeof pixel);
  3418.          src += 4;
  3419.          dst += 4;
  3420.       }
  3421.       dst_row += dst_stride;
  3422.       src_row += src_stride/sizeof(*src_row);
  3423.    }
  3424. }
  3425.  
  3426. union util_format_l32a32_float {
  3427.    uint64_t value;
  3428.    struct {
  3429.       float rgb;
  3430.       float a;
  3431.    } chan;
  3432. };
  3433.  
  3434. static INLINE void
  3435. util_format_l32a32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3436. {
  3437.    unsigned x, y;
  3438.    for(y = 0; y < height; y += 1) {
  3439.       float *dst = dst_row;
  3440.       const uint8_t *src = src_row;
  3441.       for(x = 0; x < width; x += 1) {
  3442.          union util_format_l32a32_float pixel;
  3443.          memcpy(&pixel, src, sizeof pixel);
  3444.          dst[0] = pixel.chan.rgb; /* r */
  3445.          dst[1] = pixel.chan.rgb; /* g */
  3446.          dst[2] = pixel.chan.rgb; /* b */
  3447.          dst[3] = pixel.chan.a; /* a */
  3448.          src += 8;
  3449.          dst += 4;
  3450.       }
  3451.       src_row += src_stride;
  3452.       dst_row += dst_stride/sizeof(*dst_row);
  3453.    }
  3454. }
  3455.  
  3456. static INLINE void
  3457. util_format_l32a32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3458. {
  3459.    unsigned x, y;
  3460.    for(y = 0; y < height; y += 1) {
  3461.       const float *src = src_row;
  3462.       uint8_t *dst = dst_row;
  3463.       for(x = 0; x < width; x += 1) {
  3464.          union util_format_l32a32_float pixel;
  3465.          pixel.chan.rgb = src[0];
  3466.          pixel.chan.a = src[3];
  3467.          memcpy(dst, &pixel, sizeof pixel);
  3468.          src += 4;
  3469.          dst += 8;
  3470.       }
  3471.       dst_row += dst_stride;
  3472.       src_row += src_stride/sizeof(*src_row);
  3473.    }
  3474. }
  3475.  
  3476. static INLINE void
  3477. util_format_l32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3478. {
  3479.          union util_format_l32a32_float pixel;
  3480.          memcpy(&pixel, src, sizeof pixel);
  3481.          dst[0] = pixel.chan.rgb; /* r */
  3482.          dst[1] = pixel.chan.rgb; /* g */
  3483.          dst[2] = pixel.chan.rgb; /* b */
  3484.          dst[3] = pixel.chan.a; /* a */
  3485. }
  3486.  
  3487. static INLINE void
  3488. util_format_l32a32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3489. {
  3490.    unsigned x, y;
  3491.    for(y = 0; y < height; y += 1) {
  3492.       uint8_t *dst = dst_row;
  3493.       const uint8_t *src = src_row;
  3494.       for(x = 0; x < width; x += 1) {
  3495.          union util_format_l32a32_float pixel;
  3496.          memcpy(&pixel, src, sizeof pixel);
  3497.          dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */
  3498.          dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */
  3499.          dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */
  3500.          dst[3] = float_to_ubyte(pixel.chan.a); /* a */
  3501.          src += 8;
  3502.          dst += 4;
  3503.       }
  3504.       src_row += src_stride;
  3505.       dst_row += dst_stride/sizeof(*dst_row);
  3506.    }
  3507. }
  3508.  
  3509. static INLINE void
  3510. util_format_l32a32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3511. {
  3512.    unsigned x, y;
  3513.    for(y = 0; y < height; y += 1) {
  3514.       const uint8_t *src = src_row;
  3515.       uint8_t *dst = dst_row;
  3516.       for(x = 0; x < width; x += 1) {
  3517.          union util_format_l32a32_float pixel;
  3518.          pixel.chan.rgb = ubyte_to_float(src[0]);
  3519.          pixel.chan.a = ubyte_to_float(src[3]);
  3520.          memcpy(dst, &pixel, sizeof pixel);
  3521.          src += 4;
  3522.          dst += 8;
  3523.       }
  3524.       dst_row += dst_stride;
  3525.       src_row += src_stride/sizeof(*src_row);
  3526.    }
  3527. }
  3528.  
  3529. union util_format_i32_float {
  3530.    uint32_t value;
  3531.    struct {
  3532.       float rgba;
  3533.    } chan;
  3534. };
  3535.  
  3536. static INLINE void
  3537. util_format_i32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3538. {
  3539.    unsigned x, y;
  3540.    for(y = 0; y < height; y += 1) {
  3541.       float *dst = dst_row;
  3542.       const uint8_t *src = src_row;
  3543.       for(x = 0; x < width; x += 1) {
  3544.          union util_format_i32_float pixel;
  3545.          memcpy(&pixel, src, sizeof pixel);
  3546.          dst[0] = pixel.chan.rgba; /* r */
  3547.          dst[1] = pixel.chan.rgba; /* g */
  3548.          dst[2] = pixel.chan.rgba; /* b */
  3549.          dst[3] = pixel.chan.rgba; /* a */
  3550.          src += 4;
  3551.          dst += 4;
  3552.       }
  3553.       src_row += src_stride;
  3554.       dst_row += dst_stride/sizeof(*dst_row);
  3555.    }
  3556. }
  3557.  
  3558. static INLINE void
  3559. util_format_i32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3560. {
  3561.    unsigned x, y;
  3562.    for(y = 0; y < height; y += 1) {
  3563.       const float *src = src_row;
  3564.       uint8_t *dst = dst_row;
  3565.       for(x = 0; x < width; x += 1) {
  3566.          union util_format_i32_float pixel;
  3567.          pixel.chan.rgba = src[0];
  3568.          memcpy(dst, &pixel, sizeof pixel);
  3569.          src += 4;
  3570.          dst += 4;
  3571.       }
  3572.       dst_row += dst_stride;
  3573.       src_row += src_stride/sizeof(*src_row);
  3574.    }
  3575. }
  3576.  
  3577. static INLINE void
  3578. util_format_i32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3579. {
  3580.          union util_format_i32_float pixel;
  3581.          memcpy(&pixel, src, sizeof pixel);
  3582.          dst[0] = pixel.chan.rgba; /* r */
  3583.          dst[1] = pixel.chan.rgba; /* g */
  3584.          dst[2] = pixel.chan.rgba; /* b */
  3585.          dst[3] = pixel.chan.rgba; /* a */
  3586. }
  3587.  
  3588. static INLINE void
  3589. util_format_i32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3590. {
  3591.    unsigned x, y;
  3592.    for(y = 0; y < height; y += 1) {
  3593.       uint8_t *dst = dst_row;
  3594.       const uint8_t *src = src_row;
  3595.       for(x = 0; x < width; x += 1) {
  3596.          union util_format_i32_float pixel;
  3597.          memcpy(&pixel, src, sizeof pixel);
  3598.          dst[0] = float_to_ubyte(pixel.chan.rgba); /* r */
  3599.          dst[1] = float_to_ubyte(pixel.chan.rgba); /* g */
  3600.          dst[2] = float_to_ubyte(pixel.chan.rgba); /* b */
  3601.          dst[3] = float_to_ubyte(pixel.chan.rgba); /* a */
  3602.          src += 4;
  3603.          dst += 4;
  3604.       }
  3605.       src_row += src_stride;
  3606.       dst_row += dst_stride/sizeof(*dst_row);
  3607.    }
  3608. }
  3609.  
  3610. static INLINE void
  3611. util_format_i32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3612. {
  3613.    unsigned x, y;
  3614.    for(y = 0; y < height; y += 1) {
  3615.       const uint8_t *src = src_row;
  3616.       uint8_t *dst = dst_row;
  3617.       for(x = 0; x < width; x += 1) {
  3618.          union util_format_i32_float pixel;
  3619.          pixel.chan.rgba = ubyte_to_float(src[0]);
  3620.          memcpy(dst, &pixel, sizeof pixel);
  3621.          src += 4;
  3622.          dst += 4;
  3623.       }
  3624.       dst_row += dst_stride;
  3625.       src_row += src_stride/sizeof(*src_row);
  3626.    }
  3627. }
  3628.  
  3629. union util_format_r8sg8sb8ux8u_norm {
  3630.    uint32_t value;
  3631.    struct {
  3632.       int8_t r;
  3633.       int8_t g;
  3634.       uint8_t b;
  3635.       uint8_t x;
  3636.    } chan;
  3637. };
  3638.  
  3639. static INLINE void
  3640. util_format_r8sg8sb8ux8u_norm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3641. {
  3642.    unsigned x, y;
  3643.    for(y = 0; y < height; y += 1) {
  3644.       float *dst = dst_row;
  3645.       const uint8_t *src = src_row;
  3646.       for(x = 0; x < width; x += 1) {
  3647.          uint32_t value = *(const uint32_t *)src;
  3648.          int32_t r;
  3649.          int32_t g;
  3650.          uint32_t b;
  3651.          r = ((int32_t)(value << 24) ) >> 24;
  3652.          g = ((int32_t)(value << 16) ) >> 24;
  3653.          b = (value >> 16) & 0xff;
  3654.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  3655.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  3656.          dst[2] = ubyte_to_float(b); /* b */
  3657.          dst[3] = 1; /* a */
  3658.          src += 4;
  3659.          dst += 4;
  3660.       }
  3661.       src_row += src_stride;
  3662.       dst_row += dst_stride/sizeof(*dst_row);
  3663.    }
  3664. }
  3665.  
  3666. static INLINE void
  3667. util_format_r8sg8sb8ux8u_norm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3668. {
  3669.    unsigned x, y;
  3670.    for(y = 0; y < height; y += 1) {
  3671.       const float *src = src_row;
  3672.       uint8_t *dst = dst_row;
  3673.       for(x = 0; x < width; x += 1) {
  3674.          uint32_t value = 0;
  3675.          value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  3676.          value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
  3677.          value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
  3678.          *(uint32_t *)dst = value;
  3679.          src += 4;
  3680.          dst += 4;
  3681.       }
  3682.       dst_row += dst_stride;
  3683.       src_row += src_stride/sizeof(*src_row);
  3684.    }
  3685. }
  3686.  
  3687. static INLINE void
  3688. util_format_r8sg8sb8ux8u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3689. {
  3690.          uint32_t value = *(const uint32_t *)src;
  3691.          int32_t r;
  3692.          int32_t g;
  3693.          uint32_t b;
  3694.          r = ((int32_t)(value << 24) ) >> 24;
  3695.          g = ((int32_t)(value << 16) ) >> 24;
  3696.          b = (value >> 16) & 0xff;
  3697.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  3698.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  3699.          dst[2] = ubyte_to_float(b); /* b */
  3700.          dst[3] = 1; /* a */
  3701. }
  3702.  
  3703. static INLINE void
  3704. util_format_r8sg8sb8ux8u_norm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3705. {
  3706.    unsigned x, y;
  3707.    for(y = 0; y < height; y += 1) {
  3708.       uint8_t *dst = dst_row;
  3709.       const uint8_t *src = src_row;
  3710.       for(x = 0; x < width; x += 1) {
  3711.          uint32_t value = *(const uint32_t *)src;
  3712.          int32_t r;
  3713.          int32_t g;
  3714.          uint32_t b;
  3715.          r = ((int32_t)(value << 24) ) >> 24;
  3716.          g = ((int32_t)(value << 16) ) >> 24;
  3717.          b = (value >> 16) & 0xff;
  3718.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  3719.          dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
  3720.          dst[2] = b; /* b */
  3721.          dst[3] = 255; /* a */
  3722.          src += 4;
  3723.          dst += 4;
  3724.       }
  3725.       src_row += src_stride;
  3726.       dst_row += dst_stride/sizeof(*dst_row);
  3727.    }
  3728. }
  3729.  
  3730. static INLINE void
  3731. util_format_r8sg8sb8ux8u_norm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3732. {
  3733.    unsigned x, y;
  3734.    for(y = 0; y < height; y += 1) {
  3735.       const uint8_t *src = src_row;
  3736.       uint8_t *dst = dst_row;
  3737.       for(x = 0; x < width; x += 1) {
  3738.          uint32_t value = 0;
  3739.          value |= (uint32_t)(((uint32_t)(src[0] >> 1)) & 0xff) ;
  3740.          value |= (uint32_t)((((uint32_t)(src[1] >> 1)) & 0xff) << 8) ;
  3741.          value |= ((src[2]) & 0xff) << 16;
  3742.          *(uint32_t *)dst = value;
  3743.          src += 4;
  3744.          dst += 4;
  3745.       }
  3746.       dst_row += dst_stride;
  3747.       src_row += src_stride/sizeof(*src_row);
  3748.    }
  3749. }
  3750.  
  3751. union util_format_r5sg5sb6u_norm {
  3752.    uint16_t value;
  3753.    struct {
  3754.       int r:5;
  3755.       int g:5;
  3756.       unsigned b:6;
  3757.    } chan;
  3758. };
  3759.  
  3760. static INLINE void
  3761. util_format_r5sg5sb6u_norm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3762. {
  3763.    unsigned x, y;
  3764.    for(y = 0; y < height; y += 1) {
  3765.       float *dst = dst_row;
  3766.       const uint8_t *src = src_row;
  3767.       for(x = 0; x < width; x += 1) {
  3768.          uint16_t value = *(const uint16_t *)src;
  3769.          int16_t r;
  3770.          int16_t g;
  3771.          uint16_t b;
  3772.          r = ((int16_t)(value << 11) ) >> 11;
  3773.          g = ((int16_t)(value << 6) ) >> 11;
  3774.          b = value >> 10;
  3775.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  3776.          dst[1] = (float)(g * (1.0f/0xf)); /* g */
  3777.          dst[2] = (float)(b * (1.0f/0x3f)); /* b */
  3778.          dst[3] = 1; /* a */
  3779.          src += 2;
  3780.          dst += 4;
  3781.       }
  3782.       src_row += src_stride;
  3783.       dst_row += dst_stride/sizeof(*dst_row);
  3784.    }
  3785. }
  3786.  
  3787. static INLINE void
  3788. util_format_r5sg5sb6u_norm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3789. {
  3790.    unsigned x, y;
  3791.    for(y = 0; y < height; y += 1) {
  3792.       const float *src = src_row;
  3793.       uint8_t *dst = dst_row;
  3794.       for(x = 0; x < width; x += 1) {
  3795.          uint16_t value = 0;
  3796.          value |= (uint16_t)(((uint16_t)util_iround(CLAMP(src[0], -1, 1) * 0xf)) & 0x1f) ;
  3797.          value |= (uint16_t)((((uint16_t)util_iround(CLAMP(src[1], -1, 1) * 0xf)) & 0x1f) << 5) ;
  3798.          value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x3f)) << 10;
  3799.          *(uint16_t *)dst = value;
  3800.          src += 4;
  3801.          dst += 2;
  3802.       }
  3803.       dst_row += dst_stride;
  3804.       src_row += src_stride/sizeof(*src_row);
  3805.    }
  3806. }
  3807.  
  3808. static INLINE void
  3809. util_format_r5sg5sb6u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3810. {
  3811.          uint16_t value = *(const uint16_t *)src;
  3812.          int16_t r;
  3813.          int16_t g;
  3814.          uint16_t b;
  3815.          r = ((int16_t)(value << 11) ) >> 11;
  3816.          g = ((int16_t)(value << 6) ) >> 11;
  3817.          b = value >> 10;
  3818.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  3819.          dst[1] = (float)(g * (1.0f/0xf)); /* g */
  3820.          dst[2] = (float)(b * (1.0f/0x3f)); /* b */
  3821.          dst[3] = 1; /* a */
  3822. }
  3823.  
  3824. static INLINE void
  3825. util_format_r5sg5sb6u_norm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3826. {
  3827.    unsigned x, y;
  3828.    for(y = 0; y < height; y += 1) {
  3829.       uint8_t *dst = dst_row;
  3830.       const uint8_t *src = src_row;
  3831.       for(x = 0; x < width; x += 1) {
  3832.          uint16_t value = *(const uint16_t *)src;
  3833.          int16_t r;
  3834.          int16_t g;
  3835.          uint16_t b;
  3836.          r = ((int16_t)(value << 11) ) >> 11;
  3837.          g = ((int16_t)(value << 6) ) >> 11;
  3838.          b = value >> 10;
  3839.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0xf); /* r */
  3840.          dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0xf); /* g */
  3841.          dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x3f); /* b */
  3842.          dst[3] = 255; /* a */
  3843.          src += 2;
  3844.          dst += 4;
  3845.       }
  3846.       src_row += src_stride;
  3847.       dst_row += dst_stride/sizeof(*dst_row);
  3848.    }
  3849. }
  3850.  
  3851. static INLINE void
  3852. util_format_r5sg5sb6u_norm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3853. {
  3854.    unsigned x, y;
  3855.    for(y = 0; y < height; y += 1) {
  3856.       const uint8_t *src = src_row;
  3857.       uint8_t *dst = dst_row;
  3858.       for(x = 0; x < width; x += 1) {
  3859.          uint16_t value = 0;
  3860.          value |= (uint16_t)(((uint16_t)(src[0] >> 4)) & 0x1f) ;
  3861.          value |= (uint16_t)((((uint16_t)(src[1] >> 4)) & 0x1f) << 5) ;
  3862.          value |= ((uint16_t)(src[2] >> 2)) << 10;
  3863.          *(uint16_t *)dst = value;
  3864.          src += 4;
  3865.          dst += 2;
  3866.       }
  3867.       dst_row += dst_stride;
  3868.       src_row += src_stride/sizeof(*src_row);
  3869.    }
  3870. }
  3871.  
  3872. union util_format_r64_float {
  3873.    uint64_t value;
  3874.    struct {
  3875.       double r;
  3876.    } chan;
  3877. };
  3878.  
  3879. static INLINE void
  3880. util_format_r64_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3881. {
  3882.    unsigned x, y;
  3883.    for(y = 0; y < height; y += 1) {
  3884.       float *dst = dst_row;
  3885.       const uint8_t *src = src_row;
  3886.       for(x = 0; x < width; x += 1) {
  3887.          union util_format_r64_float pixel;
  3888.          memcpy(&pixel, src, sizeof pixel);
  3889.          dst[0] = (float)pixel.chan.r; /* r */
  3890.          dst[1] = 0; /* g */
  3891.          dst[2] = 0; /* b */
  3892.          dst[3] = 1; /* a */
  3893.          src += 8;
  3894.          dst += 4;
  3895.       }
  3896.       src_row += src_stride;
  3897.       dst_row += dst_stride/sizeof(*dst_row);
  3898.    }
  3899. }
  3900.  
  3901. static INLINE void
  3902. util_format_r64_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  3903. {
  3904.    unsigned x, y;
  3905.    for(y = 0; y < height; y += 1) {
  3906.       const float *src = src_row;
  3907.       uint8_t *dst = dst_row;
  3908.       for(x = 0; x < width; x += 1) {
  3909.          union util_format_r64_float pixel;
  3910.          pixel.chan.r = (double)src[0];
  3911.          memcpy(dst, &pixel, sizeof pixel);
  3912.          src += 4;
  3913.          dst += 8;
  3914.       }
  3915.       dst_row += dst_stride;
  3916.       src_row += src_stride/sizeof(*src_row);
  3917.    }
  3918. }
  3919.  
  3920. static INLINE void
  3921. util_format_r64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  3922. {
  3923.          union util_format_r64_float pixel;
  3924.          memcpy(&pixel, src, sizeof pixel);
  3925.          dst[0] = (float)pixel.chan.r; /* r */
  3926.          dst[1] = 0; /* g */
  3927.          dst[2] = 0; /* b */
  3928.          dst[3] = 1; /* a */
  3929. }
  3930.  
  3931. static INLINE void
  3932. util_format_r64_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3933. {
  3934.    unsigned x, y;
  3935.    for(y = 0; y < height; y += 1) {
  3936.       uint8_t *dst = dst_row;
  3937.       const uint8_t *src = src_row;
  3938.       for(x = 0; x < width; x += 1) {
  3939.          union util_format_r64_float pixel;
  3940.          memcpy(&pixel, src, sizeof pixel);
  3941.          dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
  3942.          dst[1] = 0; /* g */
  3943.          dst[2] = 0; /* b */
  3944.          dst[3] = 255; /* a */
  3945.          src += 8;
  3946.          dst += 4;
  3947.       }
  3948.       src_row += src_stride;
  3949.       dst_row += dst_stride/sizeof(*dst_row);
  3950.    }
  3951. }
  3952.  
  3953. static INLINE void
  3954. util_format_r64_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3955. {
  3956.    unsigned x, y;
  3957.    for(y = 0; y < height; y += 1) {
  3958.       const uint8_t *src = src_row;
  3959.       uint8_t *dst = dst_row;
  3960.       for(x = 0; x < width; x += 1) {
  3961.          union util_format_r64_float pixel;
  3962.          pixel.chan.r = (double)(src[0] * (1.0f/0xff));
  3963.          memcpy(dst, &pixel, sizeof pixel);
  3964.          src += 4;
  3965.          dst += 8;
  3966.       }
  3967.       dst_row += dst_stride;
  3968.       src_row += src_stride/sizeof(*src_row);
  3969.    }
  3970. }
  3971.  
  3972. union util_format_r64g64_float {
  3973.    struct {
  3974.       double r;
  3975.       double g;
  3976.    } chan;
  3977. };
  3978.  
  3979. static INLINE void
  3980. util_format_r64g64_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  3981. {
  3982.    unsigned x, y;
  3983.    for(y = 0; y < height; y += 1) {
  3984.       float *dst = dst_row;
  3985.       const uint8_t *src = src_row;
  3986.       for(x = 0; x < width; x += 1) {
  3987.          union util_format_r64g64_float pixel;
  3988.          memcpy(&pixel, src, sizeof pixel);
  3989.          dst[0] = (float)pixel.chan.r; /* r */
  3990.          dst[1] = (float)pixel.chan.g; /* g */
  3991.          dst[2] = 0; /* b */
  3992.          dst[3] = 1; /* a */
  3993.          src += 16;
  3994.          dst += 4;
  3995.       }
  3996.       src_row += src_stride;
  3997.       dst_row += dst_stride/sizeof(*dst_row);
  3998.    }
  3999. }
  4000.  
  4001. static INLINE void
  4002. util_format_r64g64_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4003. {
  4004.    unsigned x, y;
  4005.    for(y = 0; y < height; y += 1) {
  4006.       const float *src = src_row;
  4007.       uint8_t *dst = dst_row;
  4008.       for(x = 0; x < width; x += 1) {
  4009.          union util_format_r64g64_float pixel;
  4010.          pixel.chan.r = (double)src[0];
  4011.          pixel.chan.g = (double)src[1];
  4012.          memcpy(dst, &pixel, sizeof pixel);
  4013.          src += 4;
  4014.          dst += 16;
  4015.       }
  4016.       dst_row += dst_stride;
  4017.       src_row += src_stride/sizeof(*src_row);
  4018.    }
  4019. }
  4020.  
  4021. static INLINE void
  4022. util_format_r64g64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4023. {
  4024.          union util_format_r64g64_float pixel;
  4025.          memcpy(&pixel, src, sizeof pixel);
  4026.          dst[0] = (float)pixel.chan.r; /* r */
  4027.          dst[1] = (float)pixel.chan.g; /* g */
  4028.          dst[2] = 0; /* b */
  4029.          dst[3] = 1; /* a */
  4030. }
  4031.  
  4032. static INLINE void
  4033. util_format_r64g64_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4034. {
  4035.    unsigned x, y;
  4036.    for(y = 0; y < height; y += 1) {
  4037.       uint8_t *dst = dst_row;
  4038.       const uint8_t *src = src_row;
  4039.       for(x = 0; x < width; x += 1) {
  4040.          union util_format_r64g64_float pixel;
  4041.          memcpy(&pixel, src, sizeof pixel);
  4042.          dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
  4043.          dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
  4044.          dst[2] = 0; /* b */
  4045.          dst[3] = 255; /* a */
  4046.          src += 16;
  4047.          dst += 4;
  4048.       }
  4049.       src_row += src_stride;
  4050.       dst_row += dst_stride/sizeof(*dst_row);
  4051.    }
  4052. }
  4053.  
  4054. static INLINE void
  4055. util_format_r64g64_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4056. {
  4057.    unsigned x, y;
  4058.    for(y = 0; y < height; y += 1) {
  4059.       const uint8_t *src = src_row;
  4060.       uint8_t *dst = dst_row;
  4061.       for(x = 0; x < width; x += 1) {
  4062.          union util_format_r64g64_float pixel;
  4063.          pixel.chan.r = (double)(src[0] * (1.0f/0xff));
  4064.          pixel.chan.g = (double)(src[1] * (1.0f/0xff));
  4065.          memcpy(dst, &pixel, sizeof pixel);
  4066.          src += 4;
  4067.          dst += 16;
  4068.       }
  4069.       dst_row += dst_stride;
  4070.       src_row += src_stride/sizeof(*src_row);
  4071.    }
  4072. }
  4073.  
  4074. union util_format_r64g64b64_float {
  4075.    struct {
  4076.       double r;
  4077.       double g;
  4078.       double b;
  4079.    } chan;
  4080. };
  4081.  
  4082. static INLINE void
  4083. util_format_r64g64b64_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4084. {
  4085.    unsigned x, y;
  4086.    for(y = 0; y < height; y += 1) {
  4087.       float *dst = dst_row;
  4088.       const uint8_t *src = src_row;
  4089.       for(x = 0; x < width; x += 1) {
  4090.          union util_format_r64g64b64_float pixel;
  4091.          memcpy(&pixel, src, sizeof pixel);
  4092.          dst[0] = (float)pixel.chan.r; /* r */
  4093.          dst[1] = (float)pixel.chan.g; /* g */
  4094.          dst[2] = (float)pixel.chan.b; /* b */
  4095.          dst[3] = 1; /* a */
  4096.          src += 24;
  4097.          dst += 4;
  4098.       }
  4099.       src_row += src_stride;
  4100.       dst_row += dst_stride/sizeof(*dst_row);
  4101.    }
  4102. }
  4103.  
  4104. static INLINE void
  4105. util_format_r64g64b64_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4106. {
  4107.    unsigned x, y;
  4108.    for(y = 0; y < height; y += 1) {
  4109.       const float *src = src_row;
  4110.       uint8_t *dst = dst_row;
  4111.       for(x = 0; x < width; x += 1) {
  4112.          union util_format_r64g64b64_float pixel;
  4113.          pixel.chan.r = (double)src[0];
  4114.          pixel.chan.g = (double)src[1];
  4115.          pixel.chan.b = (double)src[2];
  4116.          memcpy(dst, &pixel, sizeof pixel);
  4117.          src += 4;
  4118.          dst += 24;
  4119.       }
  4120.       dst_row += dst_stride;
  4121.       src_row += src_stride/sizeof(*src_row);
  4122.    }
  4123. }
  4124.  
  4125. static INLINE void
  4126. util_format_r64g64b64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4127. {
  4128.          union util_format_r64g64b64_float pixel;
  4129.          memcpy(&pixel, src, sizeof pixel);
  4130.          dst[0] = (float)pixel.chan.r; /* r */
  4131.          dst[1] = (float)pixel.chan.g; /* g */
  4132.          dst[2] = (float)pixel.chan.b; /* b */
  4133.          dst[3] = 1; /* a */
  4134. }
  4135.  
  4136. static INLINE void
  4137. util_format_r64g64b64_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4138. {
  4139.    unsigned x, y;
  4140.    for(y = 0; y < height; y += 1) {
  4141.       uint8_t *dst = dst_row;
  4142.       const uint8_t *src = src_row;
  4143.       for(x = 0; x < width; x += 1) {
  4144.          union util_format_r64g64b64_float pixel;
  4145.          memcpy(&pixel, src, sizeof pixel);
  4146.          dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
  4147.          dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
  4148.          dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */
  4149.          dst[3] = 255; /* a */
  4150.          src += 24;
  4151.          dst += 4;
  4152.       }
  4153.       src_row += src_stride;
  4154.       dst_row += dst_stride/sizeof(*dst_row);
  4155.    }
  4156. }
  4157.  
  4158. static INLINE void
  4159. util_format_r64g64b64_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4160. {
  4161.    unsigned x, y;
  4162.    for(y = 0; y < height; y += 1) {
  4163.       const uint8_t *src = src_row;
  4164.       uint8_t *dst = dst_row;
  4165.       for(x = 0; x < width; x += 1) {
  4166.          union util_format_r64g64b64_float pixel;
  4167.          pixel.chan.r = (double)(src[0] * (1.0f/0xff));
  4168.          pixel.chan.g = (double)(src[1] * (1.0f/0xff));
  4169.          pixel.chan.b = (double)(src[2] * (1.0f/0xff));
  4170.          memcpy(dst, &pixel, sizeof pixel);
  4171.          src += 4;
  4172.          dst += 24;
  4173.       }
  4174.       dst_row += dst_stride;
  4175.       src_row += src_stride/sizeof(*src_row);
  4176.    }
  4177. }
  4178.  
  4179. union util_format_r64g64b64a64_float {
  4180.    struct {
  4181.       double r;
  4182.       double g;
  4183.       double b;
  4184.       double a;
  4185.    } chan;
  4186. };
  4187.  
  4188. static INLINE void
  4189. util_format_r64g64b64a64_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4190. {
  4191.    unsigned x, y;
  4192.    for(y = 0; y < height; y += 1) {
  4193.       float *dst = dst_row;
  4194.       const uint8_t *src = src_row;
  4195.       for(x = 0; x < width; x += 1) {
  4196.          union util_format_r64g64b64a64_float pixel;
  4197.          memcpy(&pixel, src, sizeof pixel);
  4198.          dst[0] = (float)pixel.chan.r; /* r */
  4199.          dst[1] = (float)pixel.chan.g; /* g */
  4200.          dst[2] = (float)pixel.chan.b; /* b */
  4201.          dst[3] = (float)pixel.chan.a; /* a */
  4202.          src += 32;
  4203.          dst += 4;
  4204.       }
  4205.       src_row += src_stride;
  4206.       dst_row += dst_stride/sizeof(*dst_row);
  4207.    }
  4208. }
  4209.  
  4210. static INLINE void
  4211. util_format_r64g64b64a64_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4212. {
  4213.    unsigned x, y;
  4214.    for(y = 0; y < height; y += 1) {
  4215.       const float *src = src_row;
  4216.       uint8_t *dst = dst_row;
  4217.       for(x = 0; x < width; x += 1) {
  4218.          union util_format_r64g64b64a64_float pixel;
  4219.          pixel.chan.r = (double)src[0];
  4220.          pixel.chan.g = (double)src[1];
  4221.          pixel.chan.b = (double)src[2];
  4222.          pixel.chan.a = (double)src[3];
  4223.          memcpy(dst, &pixel, sizeof pixel);
  4224.          src += 4;
  4225.          dst += 32;
  4226.       }
  4227.       dst_row += dst_stride;
  4228.       src_row += src_stride/sizeof(*src_row);
  4229.    }
  4230. }
  4231.  
  4232. static INLINE void
  4233. util_format_r64g64b64a64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4234. {
  4235.          union util_format_r64g64b64a64_float pixel;
  4236.          memcpy(&pixel, src, sizeof pixel);
  4237.          dst[0] = (float)pixel.chan.r; /* r */
  4238.          dst[1] = (float)pixel.chan.g; /* g */
  4239.          dst[2] = (float)pixel.chan.b; /* b */
  4240.          dst[3] = (float)pixel.chan.a; /* a */
  4241. }
  4242.  
  4243. static INLINE void
  4244. util_format_r64g64b64a64_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4245. {
  4246.    unsigned x, y;
  4247.    for(y = 0; y < height; y += 1) {
  4248.       uint8_t *dst = dst_row;
  4249.       const uint8_t *src = src_row;
  4250.       for(x = 0; x < width; x += 1) {
  4251.          union util_format_r64g64b64a64_float pixel;
  4252.          memcpy(&pixel, src, sizeof pixel);
  4253.          dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */
  4254.          dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */
  4255.          dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */
  4256.          dst[3] = (uint8_t)util_iround(CLAMP(pixel.chan.a, 0, 1) * 0xff); /* a */
  4257.          src += 32;
  4258.          dst += 4;
  4259.       }
  4260.       src_row += src_stride;
  4261.       dst_row += dst_stride/sizeof(*dst_row);
  4262.    }
  4263. }
  4264.  
  4265. static INLINE void
  4266. util_format_r64g64b64a64_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4267. {
  4268.    unsigned x, y;
  4269.    for(y = 0; y < height; y += 1) {
  4270.       const uint8_t *src = src_row;
  4271.       uint8_t *dst = dst_row;
  4272.       for(x = 0; x < width; x += 1) {
  4273.          union util_format_r64g64b64a64_float pixel;
  4274.          pixel.chan.r = (double)(src[0] * (1.0f/0xff));
  4275.          pixel.chan.g = (double)(src[1] * (1.0f/0xff));
  4276.          pixel.chan.b = (double)(src[2] * (1.0f/0xff));
  4277.          pixel.chan.a = (double)(src[3] * (1.0f/0xff));
  4278.          memcpy(dst, &pixel, sizeof pixel);
  4279.          src += 4;
  4280.          dst += 32;
  4281.       }
  4282.       dst_row += dst_stride;
  4283.       src_row += src_stride/sizeof(*src_row);
  4284.    }
  4285. }
  4286.  
  4287. union util_format_r32_float {
  4288.    uint32_t value;
  4289.    struct {
  4290.       float r;
  4291.    } chan;
  4292. };
  4293.  
  4294. static INLINE void
  4295. util_format_r32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4296. {
  4297.    unsigned x, y;
  4298.    for(y = 0; y < height; y += 1) {
  4299.       float *dst = dst_row;
  4300.       const uint8_t *src = src_row;
  4301.       for(x = 0; x < width; x += 1) {
  4302.          union util_format_r32_float pixel;
  4303.          memcpy(&pixel, src, sizeof pixel);
  4304.          dst[0] = pixel.chan.r; /* r */
  4305.          dst[1] = 0; /* g */
  4306.          dst[2] = 0; /* b */
  4307.          dst[3] = 1; /* a */
  4308.          src += 4;
  4309.          dst += 4;
  4310.       }
  4311.       src_row += src_stride;
  4312.       dst_row += dst_stride/sizeof(*dst_row);
  4313.    }
  4314. }
  4315.  
  4316. static INLINE void
  4317. util_format_r32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4318. {
  4319.    unsigned x, y;
  4320.    for(y = 0; y < height; y += 1) {
  4321.       const float *src = src_row;
  4322.       uint8_t *dst = dst_row;
  4323.       for(x = 0; x < width; x += 1) {
  4324.          union util_format_r32_float pixel;
  4325.          pixel.chan.r = src[0];
  4326.          memcpy(dst, &pixel, sizeof pixel);
  4327.          src += 4;
  4328.          dst += 4;
  4329.       }
  4330.       dst_row += dst_stride;
  4331.       src_row += src_stride/sizeof(*src_row);
  4332.    }
  4333. }
  4334.  
  4335. static INLINE void
  4336. util_format_r32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4337. {
  4338.          union util_format_r32_float pixel;
  4339.          memcpy(&pixel, src, sizeof pixel);
  4340.          dst[0] = pixel.chan.r; /* r */
  4341.          dst[1] = 0; /* g */
  4342.          dst[2] = 0; /* b */
  4343.          dst[3] = 1; /* a */
  4344. }
  4345.  
  4346. static INLINE void
  4347. util_format_r32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4348. {
  4349.    unsigned x, y;
  4350.    for(y = 0; y < height; y += 1) {
  4351.       uint8_t *dst = dst_row;
  4352.       const uint8_t *src = src_row;
  4353.       for(x = 0; x < width; x += 1) {
  4354.          union util_format_r32_float pixel;
  4355.          memcpy(&pixel, src, sizeof pixel);
  4356.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  4357.          dst[1] = 0; /* g */
  4358.          dst[2] = 0; /* b */
  4359.          dst[3] = 255; /* a */
  4360.          src += 4;
  4361.          dst += 4;
  4362.       }
  4363.       src_row += src_stride;
  4364.       dst_row += dst_stride/sizeof(*dst_row);
  4365.    }
  4366. }
  4367.  
  4368. static INLINE void
  4369. util_format_r32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4370. {
  4371.    unsigned x, y;
  4372.    for(y = 0; y < height; y += 1) {
  4373.       const uint8_t *src = src_row;
  4374.       uint8_t *dst = dst_row;
  4375.       for(x = 0; x < width; x += 1) {
  4376.          union util_format_r32_float pixel;
  4377.          pixel.chan.r = ubyte_to_float(src[0]);
  4378.          memcpy(dst, &pixel, sizeof pixel);
  4379.          src += 4;
  4380.          dst += 4;
  4381.       }
  4382.       dst_row += dst_stride;
  4383.       src_row += src_stride/sizeof(*src_row);
  4384.    }
  4385. }
  4386.  
  4387. union util_format_r32g32_float {
  4388.    uint64_t value;
  4389.    struct {
  4390.       float r;
  4391.       float g;
  4392.    } chan;
  4393. };
  4394.  
  4395. static INLINE void
  4396. util_format_r32g32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4397. {
  4398.    unsigned x, y;
  4399.    for(y = 0; y < height; y += 1) {
  4400.       float *dst = dst_row;
  4401.       const uint8_t *src = src_row;
  4402.       for(x = 0; x < width; x += 1) {
  4403.          union util_format_r32g32_float pixel;
  4404.          memcpy(&pixel, src, sizeof pixel);
  4405.          dst[0] = pixel.chan.r; /* r */
  4406.          dst[1] = pixel.chan.g; /* g */
  4407.          dst[2] = 0; /* b */
  4408.          dst[3] = 1; /* a */
  4409.          src += 8;
  4410.          dst += 4;
  4411.       }
  4412.       src_row += src_stride;
  4413.       dst_row += dst_stride/sizeof(*dst_row);
  4414.    }
  4415. }
  4416.  
  4417. static INLINE void
  4418. util_format_r32g32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4419. {
  4420.    unsigned x, y;
  4421.    for(y = 0; y < height; y += 1) {
  4422.       const float *src = src_row;
  4423.       uint8_t *dst = dst_row;
  4424.       for(x = 0; x < width; x += 1) {
  4425.          union util_format_r32g32_float pixel;
  4426.          pixel.chan.r = src[0];
  4427.          pixel.chan.g = src[1];
  4428.          memcpy(dst, &pixel, sizeof pixel);
  4429.          src += 4;
  4430.          dst += 8;
  4431.       }
  4432.       dst_row += dst_stride;
  4433.       src_row += src_stride/sizeof(*src_row);
  4434.    }
  4435. }
  4436.  
  4437. static INLINE void
  4438. util_format_r32g32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4439. {
  4440.          union util_format_r32g32_float pixel;
  4441.          memcpy(&pixel, src, sizeof pixel);
  4442.          dst[0] = pixel.chan.r; /* r */
  4443.          dst[1] = pixel.chan.g; /* g */
  4444.          dst[2] = 0; /* b */
  4445.          dst[3] = 1; /* a */
  4446. }
  4447.  
  4448. static INLINE void
  4449. util_format_r32g32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4450. {
  4451.    unsigned x, y;
  4452.    for(y = 0; y < height; y += 1) {
  4453.       uint8_t *dst = dst_row;
  4454.       const uint8_t *src = src_row;
  4455.       for(x = 0; x < width; x += 1) {
  4456.          union util_format_r32g32_float pixel;
  4457.          memcpy(&pixel, src, sizeof pixel);
  4458.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  4459.          dst[1] = float_to_ubyte(pixel.chan.g); /* g */
  4460.          dst[2] = 0; /* b */
  4461.          dst[3] = 255; /* a */
  4462.          src += 8;
  4463.          dst += 4;
  4464.       }
  4465.       src_row += src_stride;
  4466.       dst_row += dst_stride/sizeof(*dst_row);
  4467.    }
  4468. }
  4469.  
  4470. static INLINE void
  4471. util_format_r32g32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4472. {
  4473.    unsigned x, y;
  4474.    for(y = 0; y < height; y += 1) {
  4475.       const uint8_t *src = src_row;
  4476.       uint8_t *dst = dst_row;
  4477.       for(x = 0; x < width; x += 1) {
  4478.          union util_format_r32g32_float pixel;
  4479.          pixel.chan.r = ubyte_to_float(src[0]);
  4480.          pixel.chan.g = ubyte_to_float(src[1]);
  4481.          memcpy(dst, &pixel, sizeof pixel);
  4482.          src += 4;
  4483.          dst += 8;
  4484.       }
  4485.       dst_row += dst_stride;
  4486.       src_row += src_stride/sizeof(*src_row);
  4487.    }
  4488. }
  4489.  
  4490. union util_format_r32g32b32_float {
  4491.    struct {
  4492.       float r;
  4493.       float g;
  4494.       float b;
  4495.    } chan;
  4496. };
  4497.  
  4498. static INLINE void
  4499. util_format_r32g32b32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4500. {
  4501.    unsigned x, y;
  4502.    for(y = 0; y < height; y += 1) {
  4503.       float *dst = dst_row;
  4504.       const uint8_t *src = src_row;
  4505.       for(x = 0; x < width; x += 1) {
  4506.          union util_format_r32g32b32_float pixel;
  4507.          memcpy(&pixel, src, sizeof pixel);
  4508.          dst[0] = pixel.chan.r; /* r */
  4509.          dst[1] = pixel.chan.g; /* g */
  4510.          dst[2] = pixel.chan.b; /* b */
  4511.          dst[3] = 1; /* a */
  4512.          src += 12;
  4513.          dst += 4;
  4514.       }
  4515.       src_row += src_stride;
  4516.       dst_row += dst_stride/sizeof(*dst_row);
  4517.    }
  4518. }
  4519.  
  4520. static INLINE void
  4521. util_format_r32g32b32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4522. {
  4523.    unsigned x, y;
  4524.    for(y = 0; y < height; y += 1) {
  4525.       const float *src = src_row;
  4526.       uint8_t *dst = dst_row;
  4527.       for(x = 0; x < width; x += 1) {
  4528.          union util_format_r32g32b32_float pixel;
  4529.          pixel.chan.r = src[0];
  4530.          pixel.chan.g = src[1];
  4531.          pixel.chan.b = src[2];
  4532.          memcpy(dst, &pixel, sizeof pixel);
  4533.          src += 4;
  4534.          dst += 12;
  4535.       }
  4536.       dst_row += dst_stride;
  4537.       src_row += src_stride/sizeof(*src_row);
  4538.    }
  4539. }
  4540.  
  4541. static INLINE void
  4542. util_format_r32g32b32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4543. {
  4544.          union util_format_r32g32b32_float pixel;
  4545.          memcpy(&pixel, src, sizeof pixel);
  4546.          dst[0] = pixel.chan.r; /* r */
  4547.          dst[1] = pixel.chan.g; /* g */
  4548.          dst[2] = pixel.chan.b; /* b */
  4549.          dst[3] = 1; /* a */
  4550. }
  4551.  
  4552. static INLINE void
  4553. util_format_r32g32b32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4554. {
  4555.    unsigned x, y;
  4556.    for(y = 0; y < height; y += 1) {
  4557.       uint8_t *dst = dst_row;
  4558.       const uint8_t *src = src_row;
  4559.       for(x = 0; x < width; x += 1) {
  4560.          union util_format_r32g32b32_float pixel;
  4561.          memcpy(&pixel, src, sizeof pixel);
  4562.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  4563.          dst[1] = float_to_ubyte(pixel.chan.g); /* g */
  4564.          dst[2] = float_to_ubyte(pixel.chan.b); /* b */
  4565.          dst[3] = 255; /* a */
  4566.          src += 12;
  4567.          dst += 4;
  4568.       }
  4569.       src_row += src_stride;
  4570.       dst_row += dst_stride/sizeof(*dst_row);
  4571.    }
  4572. }
  4573.  
  4574. static INLINE void
  4575. util_format_r32g32b32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4576. {
  4577.    unsigned x, y;
  4578.    for(y = 0; y < height; y += 1) {
  4579.       const uint8_t *src = src_row;
  4580.       uint8_t *dst = dst_row;
  4581.       for(x = 0; x < width; x += 1) {
  4582.          union util_format_r32g32b32_float pixel;
  4583.          pixel.chan.r = ubyte_to_float(src[0]);
  4584.          pixel.chan.g = ubyte_to_float(src[1]);
  4585.          pixel.chan.b = ubyte_to_float(src[2]);
  4586.          memcpy(dst, &pixel, sizeof pixel);
  4587.          src += 4;
  4588.          dst += 12;
  4589.       }
  4590.       dst_row += dst_stride;
  4591.       src_row += src_stride/sizeof(*src_row);
  4592.    }
  4593. }
  4594.  
  4595. union util_format_r32g32b32a32_float {
  4596.    struct {
  4597.       float r;
  4598.       float g;
  4599.       float b;
  4600.       float a;
  4601.    } chan;
  4602. };
  4603.  
  4604. static INLINE void
  4605. util_format_r32g32b32a32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4606. {
  4607.    unsigned x, y;
  4608.    for(y = 0; y < height; y += 1) {
  4609.       float *dst = dst_row;
  4610.       const uint8_t *src = src_row;
  4611.       for(x = 0; x < width; x += 1) {
  4612.          union util_format_r32g32b32a32_float pixel;
  4613.          memcpy(&pixel, src, sizeof pixel);
  4614.          dst[0] = pixel.chan.r; /* r */
  4615.          dst[1] = pixel.chan.g; /* g */
  4616.          dst[2] = pixel.chan.b; /* b */
  4617.          dst[3] = pixel.chan.a; /* a */
  4618.          src += 16;
  4619.          dst += 4;
  4620.       }
  4621.       src_row += src_stride;
  4622.       dst_row += dst_stride/sizeof(*dst_row);
  4623.    }
  4624. }
  4625.  
  4626. static INLINE void
  4627. util_format_r32g32b32a32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4628. {
  4629.    unsigned x, y;
  4630.    for(y = 0; y < height; y += 1) {
  4631.       const float *src = src_row;
  4632.       uint8_t *dst = dst_row;
  4633.       for(x = 0; x < width; x += 1) {
  4634.          union util_format_r32g32b32a32_float pixel;
  4635.          pixel.chan.r = src[0];
  4636.          pixel.chan.g = src[1];
  4637.          pixel.chan.b = src[2];
  4638.          pixel.chan.a = src[3];
  4639.          memcpy(dst, &pixel, sizeof pixel);
  4640.          src += 4;
  4641.          dst += 16;
  4642.       }
  4643.       dst_row += dst_stride;
  4644.       src_row += src_stride/sizeof(*src_row);
  4645.    }
  4646. }
  4647.  
  4648. static INLINE void
  4649. util_format_r32g32b32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4650. {
  4651.          union util_format_r32g32b32a32_float pixel;
  4652.          memcpy(&pixel, src, sizeof pixel);
  4653.          dst[0] = pixel.chan.r; /* r */
  4654.          dst[1] = pixel.chan.g; /* g */
  4655.          dst[2] = pixel.chan.b; /* b */
  4656.          dst[3] = pixel.chan.a; /* a */
  4657. }
  4658.  
  4659. static INLINE void
  4660. util_format_r32g32b32a32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4661. {
  4662.    unsigned x, y;
  4663.    for(y = 0; y < height; y += 1) {
  4664.       uint8_t *dst = dst_row;
  4665.       const uint8_t *src = src_row;
  4666.       for(x = 0; x < width; x += 1) {
  4667.          union util_format_r32g32b32a32_float pixel;
  4668.          memcpy(&pixel, src, sizeof pixel);
  4669.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  4670.          dst[1] = float_to_ubyte(pixel.chan.g); /* g */
  4671.          dst[2] = float_to_ubyte(pixel.chan.b); /* b */
  4672.          dst[3] = float_to_ubyte(pixel.chan.a); /* a */
  4673.          src += 16;
  4674.          dst += 4;
  4675.       }
  4676.       src_row += src_stride;
  4677.       dst_row += dst_stride/sizeof(*dst_row);
  4678.    }
  4679. }
  4680.  
  4681. static INLINE void
  4682. util_format_r32g32b32a32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4683. {
  4684.    unsigned x, y;
  4685.    for(y = 0; y < height; y += 1) {
  4686.       const uint8_t *src = src_row;
  4687.       uint8_t *dst = dst_row;
  4688.       for(x = 0; x < width; x += 1) {
  4689.          union util_format_r32g32b32a32_float pixel;
  4690.          pixel.chan.r = ubyte_to_float(src[0]);
  4691.          pixel.chan.g = ubyte_to_float(src[1]);
  4692.          pixel.chan.b = ubyte_to_float(src[2]);
  4693.          pixel.chan.a = ubyte_to_float(src[3]);
  4694.          memcpy(dst, &pixel, sizeof pixel);
  4695.          src += 4;
  4696.          dst += 16;
  4697.       }
  4698.       dst_row += dst_stride;
  4699.       src_row += src_stride/sizeof(*src_row);
  4700.    }
  4701. }
  4702.  
  4703. union util_format_r32_unorm {
  4704.    uint32_t value;
  4705.    struct {
  4706.       uint32_t r;
  4707.    } chan;
  4708. };
  4709.  
  4710. static INLINE void
  4711. util_format_r32_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4712. {
  4713.    unsigned x, y;
  4714.    for(y = 0; y < height; y += 1) {
  4715.       float *dst = dst_row;
  4716.       const uint8_t *src = src_row;
  4717.       for(x = 0; x < width; x += 1) {
  4718.          uint32_t value = *(const uint32_t *)src;
  4719.          uint32_t r;
  4720.          r = value;
  4721.          dst[0] = (float)(r * (1.0/0xffffffff)); /* r */
  4722.          dst[1] = 0; /* g */
  4723.          dst[2] = 0; /* b */
  4724.          dst[3] = 1; /* a */
  4725.          src += 4;
  4726.          dst += 4;
  4727.       }
  4728.       src_row += src_stride;
  4729.       dst_row += dst_stride/sizeof(*dst_row);
  4730.    }
  4731. }
  4732.  
  4733. static INLINE void
  4734. util_format_r32_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4735. {
  4736.    unsigned x, y;
  4737.    for(y = 0; y < height; y += 1) {
  4738.       const float *src = src_row;
  4739.       uint8_t *dst = dst_row;
  4740.       for(x = 0; x < width; x += 1) {
  4741.          uint32_t value = 0;
  4742.          value |= (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
  4743.          *(uint32_t *)dst = value;
  4744.          src += 4;
  4745.          dst += 4;
  4746.       }
  4747.       dst_row += dst_stride;
  4748.       src_row += src_stride/sizeof(*src_row);
  4749.    }
  4750. }
  4751.  
  4752. static INLINE void
  4753. util_format_r32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4754. {
  4755.          uint32_t value = *(const uint32_t *)src;
  4756.          uint32_t r;
  4757.          r = value;
  4758.          dst[0] = (float)(r * (1.0/0xffffffff)); /* r */
  4759.          dst[1] = 0; /* g */
  4760.          dst[2] = 0; /* b */
  4761.          dst[3] = 1; /* a */
  4762. }
  4763.  
  4764. static INLINE void
  4765. util_format_r32_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4766. {
  4767.    unsigned x, y;
  4768.    for(y = 0; y < height; y += 1) {
  4769.       uint8_t *dst = dst_row;
  4770.       const uint8_t *src = src_row;
  4771.       for(x = 0; x < width; x += 1) {
  4772.          uint32_t value = *(const uint32_t *)src;
  4773.          uint32_t r;
  4774.          r = value;
  4775.          dst[0] = (uint8_t)(r >> 24); /* r */
  4776.          dst[1] = 0; /* g */
  4777.          dst[2] = 0; /* b */
  4778.          dst[3] = 255; /* a */
  4779.          src += 4;
  4780.          dst += 4;
  4781.       }
  4782.       src_row += src_stride;
  4783.       dst_row += dst_stride/sizeof(*dst_row);
  4784.    }
  4785. }
  4786.  
  4787. static INLINE void
  4788. util_format_r32_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4789. {
  4790.    unsigned x, y;
  4791.    for(y = 0; y < height; y += 1) {
  4792.       const uint8_t *src = src_row;
  4793.       uint8_t *dst = dst_row;
  4794.       for(x = 0; x < width; x += 1) {
  4795.          uint32_t value = 0;
  4796.          value |= (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
  4797.          *(uint32_t *)dst = value;
  4798.          src += 4;
  4799.          dst += 4;
  4800.       }
  4801.       dst_row += dst_stride;
  4802.       src_row += src_stride/sizeof(*src_row);
  4803.    }
  4804. }
  4805.  
  4806. union util_format_r32g32_unorm {
  4807.    uint64_t value;
  4808.    struct {
  4809.       uint32_t r;
  4810.       uint32_t g;
  4811.    } chan;
  4812. };
  4813.  
  4814. static INLINE void
  4815. util_format_r32g32_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4816. {
  4817.    unsigned x, y;
  4818.    for(y = 0; y < height; y += 1) {
  4819.       float *dst = dst_row;
  4820.       const uint8_t *src = src_row;
  4821.       for(x = 0; x < width; x += 1) {
  4822.          union util_format_r32g32_unorm pixel;
  4823.          memcpy(&pixel, src, sizeof pixel);
  4824.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  4825.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  4826.          dst[2] = 0; /* b */
  4827.          dst[3] = 1; /* a */
  4828.          src += 8;
  4829.          dst += 4;
  4830.       }
  4831.       src_row += src_stride;
  4832.       dst_row += dst_stride/sizeof(*dst_row);
  4833.    }
  4834. }
  4835.  
  4836. static INLINE void
  4837. util_format_r32g32_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4838. {
  4839.    unsigned x, y;
  4840.    for(y = 0; y < height; y += 1) {
  4841.       const float *src = src_row;
  4842.       uint8_t *dst = dst_row;
  4843.       for(x = 0; x < width; x += 1) {
  4844.          union util_format_r32g32_unorm pixel;
  4845.          pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
  4846.          pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
  4847.          memcpy(dst, &pixel, sizeof pixel);
  4848.          src += 4;
  4849.          dst += 8;
  4850.       }
  4851.       dst_row += dst_stride;
  4852.       src_row += src_stride/sizeof(*src_row);
  4853.    }
  4854. }
  4855.  
  4856. static INLINE void
  4857. util_format_r32g32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4858. {
  4859.          union util_format_r32g32_unorm pixel;
  4860.          memcpy(&pixel, src, sizeof pixel);
  4861.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  4862.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  4863.          dst[2] = 0; /* b */
  4864.          dst[3] = 1; /* a */
  4865. }
  4866.  
  4867. static INLINE void
  4868. util_format_r32g32_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4869. {
  4870.    unsigned x, y;
  4871.    for(y = 0; y < height; y += 1) {
  4872.       uint8_t *dst = dst_row;
  4873.       const uint8_t *src = src_row;
  4874.       for(x = 0; x < width; x += 1) {
  4875.          union util_format_r32g32_unorm pixel;
  4876.          memcpy(&pixel, src, sizeof pixel);
  4877.          dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
  4878.          dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
  4879.          dst[2] = 0; /* b */
  4880.          dst[3] = 255; /* a */
  4881.          src += 8;
  4882.          dst += 4;
  4883.       }
  4884.       src_row += src_stride;
  4885.       dst_row += dst_stride/sizeof(*dst_row);
  4886.    }
  4887. }
  4888.  
  4889. static INLINE void
  4890. util_format_r32g32_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4891. {
  4892.    unsigned x, y;
  4893.    for(y = 0; y < height; y += 1) {
  4894.       const uint8_t *src = src_row;
  4895.       uint8_t *dst = dst_row;
  4896.       for(x = 0; x < width; x += 1) {
  4897.          union util_format_r32g32_unorm pixel;
  4898.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
  4899.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
  4900.          memcpy(dst, &pixel, sizeof pixel);
  4901.          src += 4;
  4902.          dst += 8;
  4903.       }
  4904.       dst_row += dst_stride;
  4905.       src_row += src_stride/sizeof(*src_row);
  4906.    }
  4907. }
  4908.  
  4909. union util_format_r32g32b32_unorm {
  4910.    struct {
  4911.       uint32_t r;
  4912.       uint32_t g;
  4913.       uint32_t b;
  4914.    } chan;
  4915. };
  4916.  
  4917. static INLINE void
  4918. util_format_r32g32b32_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4919. {
  4920.    unsigned x, y;
  4921.    for(y = 0; y < height; y += 1) {
  4922.       float *dst = dst_row;
  4923.       const uint8_t *src = src_row;
  4924.       for(x = 0; x < width; x += 1) {
  4925.          union util_format_r32g32b32_unorm pixel;
  4926.          memcpy(&pixel, src, sizeof pixel);
  4927.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  4928.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  4929.          dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
  4930.          dst[3] = 1; /* a */
  4931.          src += 12;
  4932.          dst += 4;
  4933.       }
  4934.       src_row += src_stride;
  4935.       dst_row += dst_stride/sizeof(*dst_row);
  4936.    }
  4937. }
  4938.  
  4939. static INLINE void
  4940. util_format_r32g32b32_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  4941. {
  4942.    unsigned x, y;
  4943.    for(y = 0; y < height; y += 1) {
  4944.       const float *src = src_row;
  4945.       uint8_t *dst = dst_row;
  4946.       for(x = 0; x < width; x += 1) {
  4947.          union util_format_r32g32b32_unorm pixel;
  4948.          pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
  4949.          pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
  4950.          pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff);
  4951.          memcpy(dst, &pixel, sizeof pixel);
  4952.          src += 4;
  4953.          dst += 12;
  4954.       }
  4955.       dst_row += dst_stride;
  4956.       src_row += src_stride/sizeof(*src_row);
  4957.    }
  4958. }
  4959.  
  4960. static INLINE void
  4961. util_format_r32g32b32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  4962. {
  4963.          union util_format_r32g32b32_unorm pixel;
  4964.          memcpy(&pixel, src, sizeof pixel);
  4965.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  4966.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  4967.          dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
  4968.          dst[3] = 1; /* a */
  4969. }
  4970.  
  4971. static INLINE void
  4972. util_format_r32g32b32_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4973. {
  4974.    unsigned x, y;
  4975.    for(y = 0; y < height; y += 1) {
  4976.       uint8_t *dst = dst_row;
  4977.       const uint8_t *src = src_row;
  4978.       for(x = 0; x < width; x += 1) {
  4979.          union util_format_r32g32b32_unorm pixel;
  4980.          memcpy(&pixel, src, sizeof pixel);
  4981.          dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
  4982.          dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
  4983.          dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */
  4984.          dst[3] = 255; /* a */
  4985.          src += 12;
  4986.          dst += 4;
  4987.       }
  4988.       src_row += src_stride;
  4989.       dst_row += dst_stride/sizeof(*dst_row);
  4990.    }
  4991. }
  4992.  
  4993. static INLINE void
  4994. util_format_r32g32b32_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  4995. {
  4996.    unsigned x, y;
  4997.    for(y = 0; y < height; y += 1) {
  4998.       const uint8_t *src = src_row;
  4999.       uint8_t *dst = dst_row;
  5000.       for(x = 0; x < width; x += 1) {
  5001.          union util_format_r32g32b32_unorm pixel;
  5002.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
  5003.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
  5004.          pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff);
  5005.          memcpy(dst, &pixel, sizeof pixel);
  5006.          src += 4;
  5007.          dst += 12;
  5008.       }
  5009.       dst_row += dst_stride;
  5010.       src_row += src_stride/sizeof(*src_row);
  5011.    }
  5012. }
  5013.  
  5014. union util_format_r32g32b32a32_unorm {
  5015.    struct {
  5016.       uint32_t r;
  5017.       uint32_t g;
  5018.       uint32_t b;
  5019.       uint32_t a;
  5020.    } chan;
  5021. };
  5022.  
  5023. static INLINE void
  5024. util_format_r32g32b32a32_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5025. {
  5026.    unsigned x, y;
  5027.    for(y = 0; y < height; y += 1) {
  5028.       float *dst = dst_row;
  5029.       const uint8_t *src = src_row;
  5030.       for(x = 0; x < width; x += 1) {
  5031.          union util_format_r32g32b32a32_unorm pixel;
  5032.          memcpy(&pixel, src, sizeof pixel);
  5033.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  5034.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  5035.          dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
  5036.          dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */
  5037.          src += 16;
  5038.          dst += 4;
  5039.       }
  5040.       src_row += src_stride;
  5041.       dst_row += dst_stride/sizeof(*dst_row);
  5042.    }
  5043. }
  5044.  
  5045. static INLINE void
  5046. util_format_r32g32b32a32_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5047. {
  5048.    unsigned x, y;
  5049.    for(y = 0; y < height; y += 1) {
  5050.       const float *src = src_row;
  5051.       uint8_t *dst = dst_row;
  5052.       for(x = 0; x < width; x += 1) {
  5053.          union util_format_r32g32b32a32_unorm pixel;
  5054.          pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff);
  5055.          pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff);
  5056.          pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff);
  5057.          pixel.chan.a = (uint32_t)(CLAMP(src[3], 0, 1) * (double)0xffffffff);
  5058.          memcpy(dst, &pixel, sizeof pixel);
  5059.          src += 4;
  5060.          dst += 16;
  5061.       }
  5062.       dst_row += dst_stride;
  5063.       src_row += src_stride/sizeof(*src_row);
  5064.    }
  5065. }
  5066.  
  5067. static INLINE void
  5068. util_format_r32g32b32a32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5069. {
  5070.          union util_format_r32g32b32a32_unorm pixel;
  5071.          memcpy(&pixel, src, sizeof pixel);
  5072.          dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */
  5073.          dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */
  5074.          dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */
  5075.          dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */
  5076. }
  5077.  
  5078. static INLINE void
  5079. util_format_r32g32b32a32_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5080. {
  5081.    unsigned x, y;
  5082.    for(y = 0; y < height; y += 1) {
  5083.       uint8_t *dst = dst_row;
  5084.       const uint8_t *src = src_row;
  5085.       for(x = 0; x < width; x += 1) {
  5086.          union util_format_r32g32b32a32_unorm pixel;
  5087.          memcpy(&pixel, src, sizeof pixel);
  5088.          dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */
  5089.          dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */
  5090.          dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */
  5091.          dst[3] = (uint8_t)(pixel.chan.a >> 24); /* a */
  5092.          src += 16;
  5093.          dst += 4;
  5094.       }
  5095.       src_row += src_stride;
  5096.       dst_row += dst_stride/sizeof(*dst_row);
  5097.    }
  5098. }
  5099.  
  5100. static INLINE void
  5101. util_format_r32g32b32a32_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5102. {
  5103.    unsigned x, y;
  5104.    for(y = 0; y < height; y += 1) {
  5105.       const uint8_t *src = src_row;
  5106.       uint8_t *dst = dst_row;
  5107.       for(x = 0; x < width; x += 1) {
  5108.          union util_format_r32g32b32a32_unorm pixel;
  5109.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff);
  5110.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff);
  5111.          pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff);
  5112.          pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0xffffffff / 0xff);
  5113.          memcpy(dst, &pixel, sizeof pixel);
  5114.          src += 4;
  5115.          dst += 16;
  5116.       }
  5117.       dst_row += dst_stride;
  5118.       src_row += src_stride/sizeof(*src_row);
  5119.    }
  5120. }
  5121.  
  5122. union util_format_r32_uscaled {
  5123.    uint32_t value;
  5124.    struct {
  5125.       uint32_t r;
  5126.    } chan;
  5127. };
  5128.  
  5129. static INLINE void
  5130. util_format_r32_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5131. {
  5132.    unsigned x, y;
  5133.    for(y = 0; y < height; y += 1) {
  5134.       float *dst = dst_row;
  5135.       const uint8_t *src = src_row;
  5136.       for(x = 0; x < width; x += 1) {
  5137.          uint32_t value = *(const uint32_t *)src;
  5138.          uint32_t r;
  5139.          r = value;
  5140.          dst[0] = (float)r; /* r */
  5141.          dst[1] = 0; /* g */
  5142.          dst[2] = 0; /* b */
  5143.          dst[3] = 1; /* a */
  5144.          src += 4;
  5145.          dst += 4;
  5146.       }
  5147.       src_row += src_stride;
  5148.       dst_row += dst_stride/sizeof(*dst_row);
  5149.    }
  5150. }
  5151.  
  5152. static INLINE void
  5153. util_format_r32_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5154. {
  5155.    unsigned x, y;
  5156.    for(y = 0; y < height; y += 1) {
  5157.       const float *src = src_row;
  5158.       uint8_t *dst = dst_row;
  5159.       for(x = 0; x < width; x += 1) {
  5160.          uint32_t value = 0;
  5161.          value |= (uint32_t)CLAMP(src[0], 0, 4294967295);
  5162.          *(uint32_t *)dst = value;
  5163.          src += 4;
  5164.          dst += 4;
  5165.       }
  5166.       dst_row += dst_stride;
  5167.       src_row += src_stride/sizeof(*src_row);
  5168.    }
  5169. }
  5170.  
  5171. static INLINE void
  5172. util_format_r32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5173. {
  5174.          uint32_t value = *(const uint32_t *)src;
  5175.          uint32_t r;
  5176.          r = value;
  5177.          dst[0] = (float)r; /* r */
  5178.          dst[1] = 0; /* g */
  5179.          dst[2] = 0; /* b */
  5180.          dst[3] = 1; /* a */
  5181. }
  5182.  
  5183. static INLINE void
  5184. util_format_r32_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5185. {
  5186.    unsigned x, y;
  5187.    for(y = 0; y < height; y += 1) {
  5188.       uint8_t *dst = dst_row;
  5189.       const uint8_t *src = src_row;
  5190.       for(x = 0; x < width; x += 1) {
  5191.          uint32_t value = *(const uint32_t *)src;
  5192.          uint32_t r;
  5193.          r = value;
  5194.          dst[0] = (uint8_t)(((uint64_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  5195.          dst[1] = 0; /* g */
  5196.          dst[2] = 0; /* b */
  5197.          dst[3] = 255; /* a */
  5198.          src += 4;
  5199.          dst += 4;
  5200.       }
  5201.       src_row += src_stride;
  5202.       dst_row += dst_stride/sizeof(*dst_row);
  5203.    }
  5204. }
  5205.  
  5206. static INLINE void
  5207. util_format_r32_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5208. {
  5209.    unsigned x, y;
  5210.    for(y = 0; y < height; y += 1) {
  5211.       const uint8_t *src = src_row;
  5212.       uint8_t *dst = dst_row;
  5213.       for(x = 0; x < width; x += 1) {
  5214.          uint32_t value = 0;
  5215.          value |= (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  5216.          *(uint32_t *)dst = value;
  5217.          src += 4;
  5218.          dst += 4;
  5219.       }
  5220.       dst_row += dst_stride;
  5221.       src_row += src_stride/sizeof(*src_row);
  5222.    }
  5223. }
  5224.  
  5225. union util_format_r32g32_uscaled {
  5226.    uint64_t value;
  5227.    struct {
  5228.       uint32_t r;
  5229.       uint32_t g;
  5230.    } chan;
  5231. };
  5232.  
  5233. static INLINE void
  5234. util_format_r32g32_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5235. {
  5236.    unsigned x, y;
  5237.    for(y = 0; y < height; y += 1) {
  5238.       float *dst = dst_row;
  5239.       const uint8_t *src = src_row;
  5240.       for(x = 0; x < width; x += 1) {
  5241.          union util_format_r32g32_uscaled pixel;
  5242.          memcpy(&pixel, src, sizeof pixel);
  5243.          dst[0] = (float)pixel.chan.r; /* r */
  5244.          dst[1] = (float)pixel.chan.g; /* g */
  5245.          dst[2] = 0; /* b */
  5246.          dst[3] = 1; /* a */
  5247.          src += 8;
  5248.          dst += 4;
  5249.       }
  5250.       src_row += src_stride;
  5251.       dst_row += dst_stride/sizeof(*dst_row);
  5252.    }
  5253. }
  5254.  
  5255. static INLINE void
  5256. util_format_r32g32_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5257. {
  5258.    unsigned x, y;
  5259.    for(y = 0; y < height; y += 1) {
  5260.       const float *src = src_row;
  5261.       uint8_t *dst = dst_row;
  5262.       for(x = 0; x < width; x += 1) {
  5263.          union util_format_r32g32_uscaled pixel;
  5264.          pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
  5265.          pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
  5266.          memcpy(dst, &pixel, sizeof pixel);
  5267.          src += 4;
  5268.          dst += 8;
  5269.       }
  5270.       dst_row += dst_stride;
  5271.       src_row += src_stride/sizeof(*src_row);
  5272.    }
  5273. }
  5274.  
  5275. static INLINE void
  5276. util_format_r32g32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5277. {
  5278.          union util_format_r32g32_uscaled pixel;
  5279.          memcpy(&pixel, src, sizeof pixel);
  5280.          dst[0] = (float)pixel.chan.r; /* r */
  5281.          dst[1] = (float)pixel.chan.g; /* g */
  5282.          dst[2] = 0; /* b */
  5283.          dst[3] = 1; /* a */
  5284. }
  5285.  
  5286. static INLINE void
  5287. util_format_r32g32_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5288. {
  5289.    unsigned x, y;
  5290.    for(y = 0; y < height; y += 1) {
  5291.       uint8_t *dst = dst_row;
  5292.       const uint8_t *src = src_row;
  5293.       for(x = 0; x < width; x += 1) {
  5294.          union util_format_r32g32_uscaled pixel;
  5295.          memcpy(&pixel, src, sizeof pixel);
  5296.          dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  5297.          dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  5298.          dst[2] = 0; /* b */
  5299.          dst[3] = 255; /* a */
  5300.          src += 8;
  5301.          dst += 4;
  5302.       }
  5303.       src_row += src_stride;
  5304.       dst_row += dst_stride/sizeof(*dst_row);
  5305.    }
  5306. }
  5307.  
  5308. static INLINE void
  5309. util_format_r32g32_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5310. {
  5311.    unsigned x, y;
  5312.    for(y = 0; y < height; y += 1) {
  5313.       const uint8_t *src = src_row;
  5314.       uint8_t *dst = dst_row;
  5315.       for(x = 0; x < width; x += 1) {
  5316.          union util_format_r32g32_uscaled pixel;
  5317.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  5318.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  5319.          memcpy(dst, &pixel, sizeof pixel);
  5320.          src += 4;
  5321.          dst += 8;
  5322.       }
  5323.       dst_row += dst_stride;
  5324.       src_row += src_stride/sizeof(*src_row);
  5325.    }
  5326. }
  5327.  
  5328. union util_format_r32g32b32_uscaled {
  5329.    struct {
  5330.       uint32_t r;
  5331.       uint32_t g;
  5332.       uint32_t b;
  5333.    } chan;
  5334. };
  5335.  
  5336. static INLINE void
  5337. util_format_r32g32b32_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5338. {
  5339.    unsigned x, y;
  5340.    for(y = 0; y < height; y += 1) {
  5341.       float *dst = dst_row;
  5342.       const uint8_t *src = src_row;
  5343.       for(x = 0; x < width; x += 1) {
  5344.          union util_format_r32g32b32_uscaled pixel;
  5345.          memcpy(&pixel, src, sizeof pixel);
  5346.          dst[0] = (float)pixel.chan.r; /* r */
  5347.          dst[1] = (float)pixel.chan.g; /* g */
  5348.          dst[2] = (float)pixel.chan.b; /* b */
  5349.          dst[3] = 1; /* a */
  5350.          src += 12;
  5351.          dst += 4;
  5352.       }
  5353.       src_row += src_stride;
  5354.       dst_row += dst_stride/sizeof(*dst_row);
  5355.    }
  5356. }
  5357.  
  5358. static INLINE void
  5359. util_format_r32g32b32_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5360. {
  5361.    unsigned x, y;
  5362.    for(y = 0; y < height; y += 1) {
  5363.       const float *src = src_row;
  5364.       uint8_t *dst = dst_row;
  5365.       for(x = 0; x < width; x += 1) {
  5366.          union util_format_r32g32b32_uscaled pixel;
  5367.          pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
  5368.          pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
  5369.          pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295);
  5370.          memcpy(dst, &pixel, sizeof pixel);
  5371.          src += 4;
  5372.          dst += 12;
  5373.       }
  5374.       dst_row += dst_stride;
  5375.       src_row += src_stride/sizeof(*src_row);
  5376.    }
  5377. }
  5378.  
  5379. static INLINE void
  5380. util_format_r32g32b32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5381. {
  5382.          union util_format_r32g32b32_uscaled pixel;
  5383.          memcpy(&pixel, src, sizeof pixel);
  5384.          dst[0] = (float)pixel.chan.r; /* r */
  5385.          dst[1] = (float)pixel.chan.g; /* g */
  5386.          dst[2] = (float)pixel.chan.b; /* b */
  5387.          dst[3] = 1; /* a */
  5388. }
  5389.  
  5390. static INLINE void
  5391. util_format_r32g32b32_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5392. {
  5393.    unsigned x, y;
  5394.    for(y = 0; y < height; y += 1) {
  5395.       uint8_t *dst = dst_row;
  5396.       const uint8_t *src = src_row;
  5397.       for(x = 0; x < width; x += 1) {
  5398.          union util_format_r32g32b32_uscaled pixel;
  5399.          memcpy(&pixel, src, sizeof pixel);
  5400.          dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  5401.          dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  5402.          dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
  5403.          dst[3] = 255; /* a */
  5404.          src += 12;
  5405.          dst += 4;
  5406.       }
  5407.       src_row += src_stride;
  5408.       dst_row += dst_stride/sizeof(*dst_row);
  5409.    }
  5410. }
  5411.  
  5412. static INLINE void
  5413. util_format_r32g32b32_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5414. {
  5415.    unsigned x, y;
  5416.    for(y = 0; y < height; y += 1) {
  5417.       const uint8_t *src = src_row;
  5418.       uint8_t *dst = dst_row;
  5419.       for(x = 0; x < width; x += 1) {
  5420.          union util_format_r32g32b32_uscaled pixel;
  5421.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  5422.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  5423.          pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
  5424.          memcpy(dst, &pixel, sizeof pixel);
  5425.          src += 4;
  5426.          dst += 12;
  5427.       }
  5428.       dst_row += dst_stride;
  5429.       src_row += src_stride/sizeof(*src_row);
  5430.    }
  5431. }
  5432.  
  5433. union util_format_r32g32b32a32_uscaled {
  5434.    struct {
  5435.       uint32_t r;
  5436.       uint32_t g;
  5437.       uint32_t b;
  5438.       uint32_t a;
  5439.    } chan;
  5440. };
  5441.  
  5442. static INLINE void
  5443. util_format_r32g32b32a32_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5444. {
  5445.    unsigned x, y;
  5446.    for(y = 0; y < height; y += 1) {
  5447.       float *dst = dst_row;
  5448.       const uint8_t *src = src_row;
  5449.       for(x = 0; x < width; x += 1) {
  5450.          union util_format_r32g32b32a32_uscaled pixel;
  5451.          memcpy(&pixel, src, sizeof pixel);
  5452.          dst[0] = (float)pixel.chan.r; /* r */
  5453.          dst[1] = (float)pixel.chan.g; /* g */
  5454.          dst[2] = (float)pixel.chan.b; /* b */
  5455.          dst[3] = (float)pixel.chan.a; /* a */
  5456.          src += 16;
  5457.          dst += 4;
  5458.       }
  5459.       src_row += src_stride;
  5460.       dst_row += dst_stride/sizeof(*dst_row);
  5461.    }
  5462. }
  5463.  
  5464. static INLINE void
  5465. util_format_r32g32b32a32_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5466. {
  5467.    unsigned x, y;
  5468.    for(y = 0; y < height; y += 1) {
  5469.       const float *src = src_row;
  5470.       uint8_t *dst = dst_row;
  5471.       for(x = 0; x < width; x += 1) {
  5472.          union util_format_r32g32b32a32_uscaled pixel;
  5473.          pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295);
  5474.          pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295);
  5475.          pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295);
  5476.          pixel.chan.a = (uint32_t)CLAMP(src[3], 0, 4294967295);
  5477.          memcpy(dst, &pixel, sizeof pixel);
  5478.          src += 4;
  5479.          dst += 16;
  5480.       }
  5481.       dst_row += dst_stride;
  5482.       src_row += src_stride/sizeof(*src_row);
  5483.    }
  5484. }
  5485.  
  5486. static INLINE void
  5487. util_format_r32g32b32a32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5488. {
  5489.          union util_format_r32g32b32a32_uscaled pixel;
  5490.          memcpy(&pixel, src, sizeof pixel);
  5491.          dst[0] = (float)pixel.chan.r; /* r */
  5492.          dst[1] = (float)pixel.chan.g; /* g */
  5493.          dst[2] = (float)pixel.chan.b; /* b */
  5494.          dst[3] = (float)pixel.chan.a; /* a */
  5495. }
  5496.  
  5497. static INLINE void
  5498. util_format_r32g32b32a32_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5499. {
  5500.    unsigned x, y;
  5501.    for(y = 0; y < height; y += 1) {
  5502.       uint8_t *dst = dst_row;
  5503.       const uint8_t *src = src_row;
  5504.       for(x = 0; x < width; x += 1) {
  5505.          union util_format_r32g32b32a32_uscaled pixel;
  5506.          memcpy(&pixel, src, sizeof pixel);
  5507.          dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  5508.          dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  5509.          dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
  5510.          dst[3] = (uint8_t)(((uint64_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */
  5511.          src += 16;
  5512.          dst += 4;
  5513.       }
  5514.       src_row += src_stride;
  5515.       dst_row += dst_stride/sizeof(*dst_row);
  5516.    }
  5517. }
  5518.  
  5519. static INLINE void
  5520. util_format_r32g32b32a32_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5521. {
  5522.    unsigned x, y;
  5523.    for(y = 0; y < height; y += 1) {
  5524.       const uint8_t *src = src_row;
  5525.       uint8_t *dst = dst_row;
  5526.       for(x = 0; x < width; x += 1) {
  5527.          union util_format_r32g32b32a32_uscaled pixel;
  5528.          pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  5529.          pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  5530.          pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
  5531.          pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0x1 / 0xff);
  5532.          memcpy(dst, &pixel, sizeof pixel);
  5533.          src += 4;
  5534.          dst += 16;
  5535.       }
  5536.       dst_row += dst_stride;
  5537.       src_row += src_stride/sizeof(*src_row);
  5538.    }
  5539. }
  5540.  
  5541. union util_format_r32_snorm {
  5542.    uint32_t value;
  5543.    struct {
  5544.       int32_t r;
  5545.    } chan;
  5546. };
  5547.  
  5548. static INLINE void
  5549. util_format_r32_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5550. {
  5551.    unsigned x, y;
  5552.    for(y = 0; y < height; y += 1) {
  5553.       float *dst = dst_row;
  5554.       const uint8_t *src = src_row;
  5555.       for(x = 0; x < width; x += 1) {
  5556.          uint32_t value = *(const uint32_t *)src;
  5557.          int32_t r;
  5558.          r = (int32_t)(value) ;
  5559.          dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */
  5560.          dst[1] = 0; /* g */
  5561.          dst[2] = 0; /* b */
  5562.          dst[3] = 1; /* a */
  5563.          src += 4;
  5564.          dst += 4;
  5565.       }
  5566.       src_row += src_stride;
  5567.       dst_row += dst_stride/sizeof(*dst_row);
  5568.    }
  5569. }
  5570.  
  5571. static INLINE void
  5572. util_format_r32_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5573. {
  5574.    unsigned x, y;
  5575.    for(y = 0; y < height; y += 1) {
  5576.       const float *src = src_row;
  5577.       uint8_t *dst = dst_row;
  5578.       for(x = 0; x < width; x += 1) {
  5579.          uint32_t value = 0;
  5580.          value |= (uint32_t)((int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff)) ;
  5581.          *(uint32_t *)dst = value;
  5582.          src += 4;
  5583.          dst += 4;
  5584.       }
  5585.       dst_row += dst_stride;
  5586.       src_row += src_stride/sizeof(*src_row);
  5587.    }
  5588. }
  5589.  
  5590. static INLINE void
  5591. util_format_r32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5592. {
  5593.          uint32_t value = *(const uint32_t *)src;
  5594.          int32_t r;
  5595.          r = (int32_t)(value) ;
  5596.          dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */
  5597.          dst[1] = 0; /* g */
  5598.          dst[2] = 0; /* b */
  5599.          dst[3] = 1; /* a */
  5600. }
  5601.  
  5602. static INLINE void
  5603. util_format_r32_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5604. {
  5605.    unsigned x, y;
  5606.    for(y = 0; y < height; y += 1) {
  5607.       uint8_t *dst = dst_row;
  5608.       const uint8_t *src = src_row;
  5609.       for(x = 0; x < width; x += 1) {
  5610.          uint32_t value = *(const uint32_t *)src;
  5611.          int32_t r;
  5612.          r = (int32_t)(value) ;
  5613.          dst[0] = (uint8_t)(MAX2(r, 0) >> 23); /* r */
  5614.          dst[1] = 0; /* g */
  5615.          dst[2] = 0; /* b */
  5616.          dst[3] = 255; /* a */
  5617.          src += 4;
  5618.          dst += 4;
  5619.       }
  5620.       src_row += src_stride;
  5621.       dst_row += dst_stride/sizeof(*dst_row);
  5622.    }
  5623. }
  5624.  
  5625. static INLINE void
  5626. util_format_r32_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5627. {
  5628.    unsigned x, y;
  5629.    for(y = 0; y < height; y += 1) {
  5630.       const uint8_t *src = src_row;
  5631.       uint8_t *dst = dst_row;
  5632.       for(x = 0; x < width; x += 1) {
  5633.          uint32_t value = 0;
  5634.          value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff)) ;
  5635.          *(uint32_t *)dst = value;
  5636.          src += 4;
  5637.          dst += 4;
  5638.       }
  5639.       dst_row += dst_stride;
  5640.       src_row += src_stride/sizeof(*src_row);
  5641.    }
  5642. }
  5643.  
  5644. union util_format_r32g32_snorm {
  5645.    uint64_t value;
  5646.    struct {
  5647.       int32_t r;
  5648.       int32_t g;
  5649.    } chan;
  5650. };
  5651.  
  5652. static INLINE void
  5653. util_format_r32g32_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5654. {
  5655.    unsigned x, y;
  5656.    for(y = 0; y < height; y += 1) {
  5657.       float *dst = dst_row;
  5658.       const uint8_t *src = src_row;
  5659.       for(x = 0; x < width; x += 1) {
  5660.          union util_format_r32g32_snorm pixel;
  5661.          memcpy(&pixel, src, sizeof pixel);
  5662.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5663.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5664.          dst[2] = 0; /* b */
  5665.          dst[3] = 1; /* a */
  5666.          src += 8;
  5667.          dst += 4;
  5668.       }
  5669.       src_row += src_stride;
  5670.       dst_row += dst_stride/sizeof(*dst_row);
  5671.    }
  5672. }
  5673.  
  5674. static INLINE void
  5675. util_format_r32g32_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5676. {
  5677.    unsigned x, y;
  5678.    for(y = 0; y < height; y += 1) {
  5679.       const float *src = src_row;
  5680.       uint8_t *dst = dst_row;
  5681.       for(x = 0; x < width; x += 1) {
  5682.          union util_format_r32g32_snorm pixel;
  5683.          pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
  5684.          pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
  5685.          memcpy(dst, &pixel, sizeof pixel);
  5686.          src += 4;
  5687.          dst += 8;
  5688.       }
  5689.       dst_row += dst_stride;
  5690.       src_row += src_stride/sizeof(*src_row);
  5691.    }
  5692. }
  5693.  
  5694. static INLINE void
  5695. util_format_r32g32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5696. {
  5697.          union util_format_r32g32_snorm pixel;
  5698.          memcpy(&pixel, src, sizeof pixel);
  5699.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5700.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5701.          dst[2] = 0; /* b */
  5702.          dst[3] = 1; /* a */
  5703. }
  5704.  
  5705. static INLINE void
  5706. util_format_r32g32_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5707. {
  5708.    unsigned x, y;
  5709.    for(y = 0; y < height; y += 1) {
  5710.       uint8_t *dst = dst_row;
  5711.       const uint8_t *src = src_row;
  5712.       for(x = 0; x < width; x += 1) {
  5713.          union util_format_r32g32_snorm pixel;
  5714.          memcpy(&pixel, src, sizeof pixel);
  5715.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
  5716.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
  5717.          dst[2] = 0; /* b */
  5718.          dst[3] = 255; /* a */
  5719.          src += 8;
  5720.          dst += 4;
  5721.       }
  5722.       src_row += src_stride;
  5723.       dst_row += dst_stride/sizeof(*dst_row);
  5724.    }
  5725. }
  5726.  
  5727. static INLINE void
  5728. util_format_r32g32_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5729. {
  5730.    unsigned x, y;
  5731.    for(y = 0; y < height; y += 1) {
  5732.       const uint8_t *src = src_row;
  5733.       uint8_t *dst = dst_row;
  5734.       for(x = 0; x < width; x += 1) {
  5735.          union util_format_r32g32_snorm pixel;
  5736.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
  5737.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
  5738.          memcpy(dst, &pixel, sizeof pixel);
  5739.          src += 4;
  5740.          dst += 8;
  5741.       }
  5742.       dst_row += dst_stride;
  5743.       src_row += src_stride/sizeof(*src_row);
  5744.    }
  5745. }
  5746.  
  5747. union util_format_r32g32b32_snorm {
  5748.    struct {
  5749.       int32_t r;
  5750.       int32_t g;
  5751.       int32_t b;
  5752.    } chan;
  5753. };
  5754.  
  5755. static INLINE void
  5756. util_format_r32g32b32_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5757. {
  5758.    unsigned x, y;
  5759.    for(y = 0; y < height; y += 1) {
  5760.       float *dst = dst_row;
  5761.       const uint8_t *src = src_row;
  5762.       for(x = 0; x < width; x += 1) {
  5763.          union util_format_r32g32b32_snorm pixel;
  5764.          memcpy(&pixel, src, sizeof pixel);
  5765.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5766.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5767.          dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
  5768.          dst[3] = 1; /* a */
  5769.          src += 12;
  5770.          dst += 4;
  5771.       }
  5772.       src_row += src_stride;
  5773.       dst_row += dst_stride/sizeof(*dst_row);
  5774.    }
  5775. }
  5776.  
  5777. static INLINE void
  5778. util_format_r32g32b32_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5779. {
  5780.    unsigned x, y;
  5781.    for(y = 0; y < height; y += 1) {
  5782.       const float *src = src_row;
  5783.       uint8_t *dst = dst_row;
  5784.       for(x = 0; x < width; x += 1) {
  5785.          union util_format_r32g32b32_snorm pixel;
  5786.          pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
  5787.          pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
  5788.          pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff);
  5789.          memcpy(dst, &pixel, sizeof pixel);
  5790.          src += 4;
  5791.          dst += 12;
  5792.       }
  5793.       dst_row += dst_stride;
  5794.       src_row += src_stride/sizeof(*src_row);
  5795.    }
  5796. }
  5797.  
  5798. static INLINE void
  5799. util_format_r32g32b32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5800. {
  5801.          union util_format_r32g32b32_snorm pixel;
  5802.          memcpy(&pixel, src, sizeof pixel);
  5803.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5804.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5805.          dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
  5806.          dst[3] = 1; /* a */
  5807. }
  5808.  
  5809. static INLINE void
  5810. util_format_r32g32b32_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5811. {
  5812.    unsigned x, y;
  5813.    for(y = 0; y < height; y += 1) {
  5814.       uint8_t *dst = dst_row;
  5815.       const uint8_t *src = src_row;
  5816.       for(x = 0; x < width; x += 1) {
  5817.          union util_format_r32g32b32_snorm pixel;
  5818.          memcpy(&pixel, src, sizeof pixel);
  5819.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
  5820.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
  5821.          dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */
  5822.          dst[3] = 255; /* a */
  5823.          src += 12;
  5824.          dst += 4;
  5825.       }
  5826.       src_row += src_stride;
  5827.       dst_row += dst_stride/sizeof(*dst_row);
  5828.    }
  5829. }
  5830.  
  5831. static INLINE void
  5832. util_format_r32g32b32_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5833. {
  5834.    unsigned x, y;
  5835.    for(y = 0; y < height; y += 1) {
  5836.       const uint8_t *src = src_row;
  5837.       uint8_t *dst = dst_row;
  5838.       for(x = 0; x < width; x += 1) {
  5839.          union util_format_r32g32b32_snorm pixel;
  5840.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
  5841.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
  5842.          pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff);
  5843.          memcpy(dst, &pixel, sizeof pixel);
  5844.          src += 4;
  5845.          dst += 12;
  5846.       }
  5847.       dst_row += dst_stride;
  5848.       src_row += src_stride/sizeof(*src_row);
  5849.    }
  5850. }
  5851.  
  5852. union util_format_r32g32b32a32_snorm {
  5853.    struct {
  5854.       int32_t r;
  5855.       int32_t g;
  5856.       int32_t b;
  5857.       int32_t a;
  5858.    } chan;
  5859. };
  5860.  
  5861. static INLINE void
  5862. util_format_r32g32b32a32_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5863. {
  5864.    unsigned x, y;
  5865.    for(y = 0; y < height; y += 1) {
  5866.       float *dst = dst_row;
  5867.       const uint8_t *src = src_row;
  5868.       for(x = 0; x < width; x += 1) {
  5869.          union util_format_r32g32b32a32_snorm pixel;
  5870.          memcpy(&pixel, src, sizeof pixel);
  5871.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5872.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5873.          dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
  5874.          dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */
  5875.          src += 16;
  5876.          dst += 4;
  5877.       }
  5878.       src_row += src_stride;
  5879.       dst_row += dst_stride/sizeof(*dst_row);
  5880.    }
  5881. }
  5882.  
  5883. static INLINE void
  5884. util_format_r32g32b32a32_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5885. {
  5886.    unsigned x, y;
  5887.    for(y = 0; y < height; y += 1) {
  5888.       const float *src = src_row;
  5889.       uint8_t *dst = dst_row;
  5890.       for(x = 0; x < width; x += 1) {
  5891.          union util_format_r32g32b32a32_snorm pixel;
  5892.          pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff);
  5893.          pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff);
  5894.          pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff);
  5895.          pixel.chan.a = (int32_t)(CLAMP(src[3], -1, 1) * (double)0x7fffffff);
  5896.          memcpy(dst, &pixel, sizeof pixel);
  5897.          src += 4;
  5898.          dst += 16;
  5899.       }
  5900.       dst_row += dst_stride;
  5901.       src_row += src_stride/sizeof(*src_row);
  5902.    }
  5903. }
  5904.  
  5905. static INLINE void
  5906. util_format_r32g32b32a32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  5907. {
  5908.          union util_format_r32g32b32a32_snorm pixel;
  5909.          memcpy(&pixel, src, sizeof pixel);
  5910.          dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */
  5911.          dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */
  5912.          dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */
  5913.          dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */
  5914. }
  5915.  
  5916. static INLINE void
  5917. util_format_r32g32b32a32_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5918. {
  5919.    unsigned x, y;
  5920.    for(y = 0; y < height; y += 1) {
  5921.       uint8_t *dst = dst_row;
  5922.       const uint8_t *src = src_row;
  5923.       for(x = 0; x < width; x += 1) {
  5924.          union util_format_r32g32b32a32_snorm pixel;
  5925.          memcpy(&pixel, src, sizeof pixel);
  5926.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */
  5927.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */
  5928.          dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */
  5929.          dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 23); /* a */
  5930.          src += 16;
  5931.          dst += 4;
  5932.       }
  5933.       src_row += src_stride;
  5934.       dst_row += dst_stride/sizeof(*dst_row);
  5935.    }
  5936. }
  5937.  
  5938. static INLINE void
  5939. util_format_r32g32b32a32_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5940. {
  5941.    unsigned x, y;
  5942.    for(y = 0; y < height; y += 1) {
  5943.       const uint8_t *src = src_row;
  5944.       uint8_t *dst = dst_row;
  5945.       for(x = 0; x < width; x += 1) {
  5946.          union util_format_r32g32b32a32_snorm pixel;
  5947.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff);
  5948.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff);
  5949.          pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff);
  5950.          pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x7fffffff / 0xff);
  5951.          memcpy(dst, &pixel, sizeof pixel);
  5952.          src += 4;
  5953.          dst += 16;
  5954.       }
  5955.       dst_row += dst_stride;
  5956.       src_row += src_stride/sizeof(*src_row);
  5957.    }
  5958. }
  5959.  
  5960. union util_format_r32_sscaled {
  5961.    uint32_t value;
  5962.    struct {
  5963.       int32_t r;
  5964.    } chan;
  5965. };
  5966.  
  5967. static INLINE void
  5968. util_format_r32_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  5969. {
  5970.    unsigned x, y;
  5971.    for(y = 0; y < height; y += 1) {
  5972.       float *dst = dst_row;
  5973.       const uint8_t *src = src_row;
  5974.       for(x = 0; x < width; x += 1) {
  5975.          uint32_t value = *(const uint32_t *)src;
  5976.          int32_t r;
  5977.          r = (int32_t)(value) ;
  5978.          dst[0] = (float)r; /* r */
  5979.          dst[1] = 0; /* g */
  5980.          dst[2] = 0; /* b */
  5981.          dst[3] = 1; /* a */
  5982.          src += 4;
  5983.          dst += 4;
  5984.       }
  5985.       src_row += src_stride;
  5986.       dst_row += dst_stride/sizeof(*dst_row);
  5987.    }
  5988. }
  5989.  
  5990. static INLINE void
  5991. util_format_r32_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  5992. {
  5993.    unsigned x, y;
  5994.    for(y = 0; y < height; y += 1) {
  5995.       const float *src = src_row;
  5996.       uint8_t *dst = dst_row;
  5997.       for(x = 0; x < width; x += 1) {
  5998.          uint32_t value = 0;
  5999.          value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648, 2147483647)) ;
  6000.          *(uint32_t *)dst = value;
  6001.          src += 4;
  6002.          dst += 4;
  6003.       }
  6004.       dst_row += dst_stride;
  6005.       src_row += src_stride/sizeof(*src_row);
  6006.    }
  6007. }
  6008.  
  6009. static INLINE void
  6010. util_format_r32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6011. {
  6012.          uint32_t value = *(const uint32_t *)src;
  6013.          int32_t r;
  6014.          r = (int32_t)(value) ;
  6015.          dst[0] = (float)r; /* r */
  6016.          dst[1] = 0; /* g */
  6017.          dst[2] = 0; /* b */
  6018.          dst[3] = 1; /* a */
  6019. }
  6020.  
  6021. static INLINE void
  6022. util_format_r32_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6023. {
  6024.    unsigned x, y;
  6025.    for(y = 0; y < height; y += 1) {
  6026.       uint8_t *dst = dst_row;
  6027.       const uint8_t *src = src_row;
  6028.       for(x = 0; x < width; x += 1) {
  6029.          uint32_t value = *(const uint32_t *)src;
  6030.          int32_t r;
  6031.          r = (int32_t)(value) ;
  6032.          dst[0] = (uint8_t)(((uint64_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  6033.          dst[1] = 0; /* g */
  6034.          dst[2] = 0; /* b */
  6035.          dst[3] = 255; /* a */
  6036.          src += 4;
  6037.          dst += 4;
  6038.       }
  6039.       src_row += src_stride;
  6040.       dst_row += dst_stride/sizeof(*dst_row);
  6041.    }
  6042. }
  6043.  
  6044. static INLINE void
  6045. util_format_r32_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6046. {
  6047.    unsigned x, y;
  6048.    for(y = 0; y < height; y += 1) {
  6049.       const uint8_t *src = src_row;
  6050.       uint8_t *dst = dst_row;
  6051.       for(x = 0; x < width; x += 1) {
  6052.          uint32_t value = 0;
  6053.          value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x1 / 0xff)) ;
  6054.          *(uint32_t *)dst = value;
  6055.          src += 4;
  6056.          dst += 4;
  6057.       }
  6058.       dst_row += dst_stride;
  6059.       src_row += src_stride/sizeof(*src_row);
  6060.    }
  6061. }
  6062.  
  6063. union util_format_r32g32_sscaled {
  6064.    uint64_t value;
  6065.    struct {
  6066.       int32_t r;
  6067.       int32_t g;
  6068.    } chan;
  6069. };
  6070.  
  6071. static INLINE void
  6072. util_format_r32g32_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6073. {
  6074.    unsigned x, y;
  6075.    for(y = 0; y < height; y += 1) {
  6076.       float *dst = dst_row;
  6077.       const uint8_t *src = src_row;
  6078.       for(x = 0; x < width; x += 1) {
  6079.          union util_format_r32g32_sscaled pixel;
  6080.          memcpy(&pixel, src, sizeof pixel);
  6081.          dst[0] = (float)pixel.chan.r; /* r */
  6082.          dst[1] = (float)pixel.chan.g; /* g */
  6083.          dst[2] = 0; /* b */
  6084.          dst[3] = 1; /* a */
  6085.          src += 8;
  6086.          dst += 4;
  6087.       }
  6088.       src_row += src_stride;
  6089.       dst_row += dst_stride/sizeof(*dst_row);
  6090.    }
  6091. }
  6092.  
  6093. static INLINE void
  6094. util_format_r32g32_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6095. {
  6096.    unsigned x, y;
  6097.    for(y = 0; y < height; y += 1) {
  6098.       const float *src = src_row;
  6099.       uint8_t *dst = dst_row;
  6100.       for(x = 0; x < width; x += 1) {
  6101.          union util_format_r32g32_sscaled pixel;
  6102.          pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
  6103.          pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
  6104.          memcpy(dst, &pixel, sizeof pixel);
  6105.          src += 4;
  6106.          dst += 8;
  6107.       }
  6108.       dst_row += dst_stride;
  6109.       src_row += src_stride/sizeof(*src_row);
  6110.    }
  6111. }
  6112.  
  6113. static INLINE void
  6114. util_format_r32g32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6115. {
  6116.          union util_format_r32g32_sscaled pixel;
  6117.          memcpy(&pixel, src, sizeof pixel);
  6118.          dst[0] = (float)pixel.chan.r; /* r */
  6119.          dst[1] = (float)pixel.chan.g; /* g */
  6120.          dst[2] = 0; /* b */
  6121.          dst[3] = 1; /* a */
  6122. }
  6123.  
  6124. static INLINE void
  6125. util_format_r32g32_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6126. {
  6127.    unsigned x, y;
  6128.    for(y = 0; y < height; y += 1) {
  6129.       uint8_t *dst = dst_row;
  6130.       const uint8_t *src = src_row;
  6131.       for(x = 0; x < width; x += 1) {
  6132.          union util_format_r32g32_sscaled pixel;
  6133.          memcpy(&pixel, src, sizeof pixel);
  6134.          dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  6135.          dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  6136.          dst[2] = 0; /* b */
  6137.          dst[3] = 255; /* a */
  6138.          src += 8;
  6139.          dst += 4;
  6140.       }
  6141.       src_row += src_stride;
  6142.       dst_row += dst_stride/sizeof(*dst_row);
  6143.    }
  6144. }
  6145.  
  6146. static INLINE void
  6147. util_format_r32g32_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6148. {
  6149.    unsigned x, y;
  6150.    for(y = 0; y < height; y += 1) {
  6151.       const uint8_t *src = src_row;
  6152.       uint8_t *dst = dst_row;
  6153.       for(x = 0; x < width; x += 1) {
  6154.          union util_format_r32g32_sscaled pixel;
  6155.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  6156.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  6157.          memcpy(dst, &pixel, sizeof pixel);
  6158.          src += 4;
  6159.          dst += 8;
  6160.       }
  6161.       dst_row += dst_stride;
  6162.       src_row += src_stride/sizeof(*src_row);
  6163.    }
  6164. }
  6165.  
  6166. union util_format_r32g32b32_sscaled {
  6167.    struct {
  6168.       int32_t r;
  6169.       int32_t g;
  6170.       int32_t b;
  6171.    } chan;
  6172. };
  6173.  
  6174. static INLINE void
  6175. util_format_r32g32b32_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6176. {
  6177.    unsigned x, y;
  6178.    for(y = 0; y < height; y += 1) {
  6179.       float *dst = dst_row;
  6180.       const uint8_t *src = src_row;
  6181.       for(x = 0; x < width; x += 1) {
  6182.          union util_format_r32g32b32_sscaled pixel;
  6183.          memcpy(&pixel, src, sizeof pixel);
  6184.          dst[0] = (float)pixel.chan.r; /* r */
  6185.          dst[1] = (float)pixel.chan.g; /* g */
  6186.          dst[2] = (float)pixel.chan.b; /* b */
  6187.          dst[3] = 1; /* a */
  6188.          src += 12;
  6189.          dst += 4;
  6190.       }
  6191.       src_row += src_stride;
  6192.       dst_row += dst_stride/sizeof(*dst_row);
  6193.    }
  6194. }
  6195.  
  6196. static INLINE void
  6197. util_format_r32g32b32_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6198. {
  6199.    unsigned x, y;
  6200.    for(y = 0; y < height; y += 1) {
  6201.       const float *src = src_row;
  6202.       uint8_t *dst = dst_row;
  6203.       for(x = 0; x < width; x += 1) {
  6204.          union util_format_r32g32b32_sscaled pixel;
  6205.          pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
  6206.          pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
  6207.          pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647);
  6208.          memcpy(dst, &pixel, sizeof pixel);
  6209.          src += 4;
  6210.          dst += 12;
  6211.       }
  6212.       dst_row += dst_stride;
  6213.       src_row += src_stride/sizeof(*src_row);
  6214.    }
  6215. }
  6216.  
  6217. static INLINE void
  6218. util_format_r32g32b32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6219. {
  6220.          union util_format_r32g32b32_sscaled pixel;
  6221.          memcpy(&pixel, src, sizeof pixel);
  6222.          dst[0] = (float)pixel.chan.r; /* r */
  6223.          dst[1] = (float)pixel.chan.g; /* g */
  6224.          dst[2] = (float)pixel.chan.b; /* b */
  6225.          dst[3] = 1; /* a */
  6226. }
  6227.  
  6228. static INLINE void
  6229. util_format_r32g32b32_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6230. {
  6231.    unsigned x, y;
  6232.    for(y = 0; y < height; y += 1) {
  6233.       uint8_t *dst = dst_row;
  6234.       const uint8_t *src = src_row;
  6235.       for(x = 0; x < width; x += 1) {
  6236.          union util_format_r32g32b32_sscaled pixel;
  6237.          memcpy(&pixel, src, sizeof pixel);
  6238.          dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  6239.          dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  6240.          dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
  6241.          dst[3] = 255; /* a */
  6242.          src += 12;
  6243.          dst += 4;
  6244.       }
  6245.       src_row += src_stride;
  6246.       dst_row += dst_stride/sizeof(*dst_row);
  6247.    }
  6248. }
  6249.  
  6250. static INLINE void
  6251. util_format_r32g32b32_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6252. {
  6253.    unsigned x, y;
  6254.    for(y = 0; y < height; y += 1) {
  6255.       const uint8_t *src = src_row;
  6256.       uint8_t *dst = dst_row;
  6257.       for(x = 0; x < width; x += 1) {
  6258.          union util_format_r32g32b32_sscaled pixel;
  6259.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  6260.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  6261.          pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
  6262.          memcpy(dst, &pixel, sizeof pixel);
  6263.          src += 4;
  6264.          dst += 12;
  6265.       }
  6266.       dst_row += dst_stride;
  6267.       src_row += src_stride/sizeof(*src_row);
  6268.    }
  6269. }
  6270.  
  6271. union util_format_r32g32b32a32_sscaled {
  6272.    struct {
  6273.       int32_t r;
  6274.       int32_t g;
  6275.       int32_t b;
  6276.       int32_t a;
  6277.    } chan;
  6278. };
  6279.  
  6280. static INLINE void
  6281. util_format_r32g32b32a32_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6282. {
  6283.    unsigned x, y;
  6284.    for(y = 0; y < height; y += 1) {
  6285.       float *dst = dst_row;
  6286.       const uint8_t *src = src_row;
  6287.       for(x = 0; x < width; x += 1) {
  6288.          union util_format_r32g32b32a32_sscaled pixel;
  6289.          memcpy(&pixel, src, sizeof pixel);
  6290.          dst[0] = (float)pixel.chan.r; /* r */
  6291.          dst[1] = (float)pixel.chan.g; /* g */
  6292.          dst[2] = (float)pixel.chan.b; /* b */
  6293.          dst[3] = (float)pixel.chan.a; /* a */
  6294.          src += 16;
  6295.          dst += 4;
  6296.       }
  6297.       src_row += src_stride;
  6298.       dst_row += dst_stride/sizeof(*dst_row);
  6299.    }
  6300. }
  6301.  
  6302. static INLINE void
  6303. util_format_r32g32b32a32_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6304. {
  6305.    unsigned x, y;
  6306.    for(y = 0; y < height; y += 1) {
  6307.       const float *src = src_row;
  6308.       uint8_t *dst = dst_row;
  6309.       for(x = 0; x < width; x += 1) {
  6310.          union util_format_r32g32b32a32_sscaled pixel;
  6311.          pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647);
  6312.          pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647);
  6313.          pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647);
  6314.          pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648, 2147483647);
  6315.          memcpy(dst, &pixel, sizeof pixel);
  6316.          src += 4;
  6317.          dst += 16;
  6318.       }
  6319.       dst_row += dst_stride;
  6320.       src_row += src_stride/sizeof(*src_row);
  6321.    }
  6322. }
  6323.  
  6324. static INLINE void
  6325. util_format_r32g32b32a32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6326. {
  6327.          union util_format_r32g32b32a32_sscaled pixel;
  6328.          memcpy(&pixel, src, sizeof pixel);
  6329.          dst[0] = (float)pixel.chan.r; /* r */
  6330.          dst[1] = (float)pixel.chan.g; /* g */
  6331.          dst[2] = (float)pixel.chan.b; /* b */
  6332.          dst[3] = (float)pixel.chan.a; /* a */
  6333. }
  6334.  
  6335. static INLINE void
  6336. util_format_r32g32b32a32_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6337. {
  6338.    unsigned x, y;
  6339.    for(y = 0; y < height; y += 1) {
  6340.       uint8_t *dst = dst_row;
  6341.       const uint8_t *src = src_row;
  6342.       for(x = 0; x < width; x += 1) {
  6343.          union util_format_r32g32b32a32_sscaled pixel;
  6344.          memcpy(&pixel, src, sizeof pixel);
  6345.          dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  6346.          dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  6347.          dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
  6348.          dst[3] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */
  6349.          src += 16;
  6350.          dst += 4;
  6351.       }
  6352.       src_row += src_stride;
  6353.       dst_row += dst_stride/sizeof(*dst_row);
  6354.    }
  6355. }
  6356.  
  6357. static INLINE void
  6358. util_format_r32g32b32a32_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6359. {
  6360.    unsigned x, y;
  6361.    for(y = 0; y < height; y += 1) {
  6362.       const uint8_t *src = src_row;
  6363.       uint8_t *dst = dst_row;
  6364.       for(x = 0; x < width; x += 1) {
  6365.          union util_format_r32g32b32a32_sscaled pixel;
  6366.          pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff);
  6367.          pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff);
  6368.          pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff);
  6369.          pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x1 / 0xff);
  6370.          memcpy(dst, &pixel, sizeof pixel);
  6371.          src += 4;
  6372.          dst += 16;
  6373.       }
  6374.       dst_row += dst_stride;
  6375.       src_row += src_stride/sizeof(*src_row);
  6376.    }
  6377. }
  6378.  
  6379. union util_format_r16_float {
  6380.    uint16_t value;
  6381.    struct {
  6382.       uint16_t r;
  6383.    } chan;
  6384. };
  6385.  
  6386. static INLINE void
  6387. util_format_r16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6388. {
  6389.    unsigned x, y;
  6390.    for(y = 0; y < height; y += 1) {
  6391.       float *dst = dst_row;
  6392.       const uint8_t *src = src_row;
  6393.       for(x = 0; x < width; x += 1) {
  6394.          union util_format_r16_float pixel;
  6395.          memcpy(&pixel, src, sizeof pixel);
  6396.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6397.          dst[1] = 0; /* g */
  6398.          dst[2] = 0; /* b */
  6399.          dst[3] = 1; /* a */
  6400.          src += 2;
  6401.          dst += 4;
  6402.       }
  6403.       src_row += src_stride;
  6404.       dst_row += dst_stride/sizeof(*dst_row);
  6405.    }
  6406. }
  6407.  
  6408. static INLINE void
  6409. util_format_r16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6410. {
  6411.    unsigned x, y;
  6412.    for(y = 0; y < height; y += 1) {
  6413.       const float *src = src_row;
  6414.       uint8_t *dst = dst_row;
  6415.       for(x = 0; x < width; x += 1) {
  6416.          union util_format_r16_float pixel;
  6417.          pixel.chan.r = util_float_to_half(src[0]);
  6418.          memcpy(dst, &pixel, sizeof pixel);
  6419.          src += 4;
  6420.          dst += 2;
  6421.       }
  6422.       dst_row += dst_stride;
  6423.       src_row += src_stride/sizeof(*src_row);
  6424.    }
  6425. }
  6426.  
  6427. static INLINE void
  6428. util_format_r16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6429. {
  6430.          union util_format_r16_float pixel;
  6431.          memcpy(&pixel, src, sizeof pixel);
  6432.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6433.          dst[1] = 0; /* g */
  6434.          dst[2] = 0; /* b */
  6435.          dst[3] = 1; /* a */
  6436. }
  6437.  
  6438. static INLINE void
  6439. util_format_r16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6440. {
  6441.    unsigned x, y;
  6442.    for(y = 0; y < height; y += 1) {
  6443.       uint8_t *dst = dst_row;
  6444.       const uint8_t *src = src_row;
  6445.       for(x = 0; x < width; x += 1) {
  6446.          union util_format_r16_float pixel;
  6447.          memcpy(&pixel, src, sizeof pixel);
  6448.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  6449.          dst[1] = 0; /* g */
  6450.          dst[2] = 0; /* b */
  6451.          dst[3] = 255; /* a */
  6452.          src += 2;
  6453.          dst += 4;
  6454.       }
  6455.       src_row += src_stride;
  6456.       dst_row += dst_stride/sizeof(*dst_row);
  6457.    }
  6458. }
  6459.  
  6460. static INLINE void
  6461. util_format_r16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6462. {
  6463.    unsigned x, y;
  6464.    for(y = 0; y < height; y += 1) {
  6465.       const uint8_t *src = src_row;
  6466.       uint8_t *dst = dst_row;
  6467.       for(x = 0; x < width; x += 1) {
  6468.          union util_format_r16_float pixel;
  6469.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  6470.          memcpy(dst, &pixel, sizeof pixel);
  6471.          src += 4;
  6472.          dst += 2;
  6473.       }
  6474.       dst_row += dst_stride;
  6475.       src_row += src_stride/sizeof(*src_row);
  6476.    }
  6477. }
  6478.  
  6479. union util_format_r16g16_float {
  6480.    uint32_t value;
  6481.    struct {
  6482.       uint16_t r;
  6483.       uint16_t g;
  6484.    } chan;
  6485. };
  6486.  
  6487. static INLINE void
  6488. util_format_r16g16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6489. {
  6490.    unsigned x, y;
  6491.    for(y = 0; y < height; y += 1) {
  6492.       float *dst = dst_row;
  6493.       const uint8_t *src = src_row;
  6494.       for(x = 0; x < width; x += 1) {
  6495.          union util_format_r16g16_float pixel;
  6496.          memcpy(&pixel, src, sizeof pixel);
  6497.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6498.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6499.          dst[2] = 0; /* b */
  6500.          dst[3] = 1; /* a */
  6501.          src += 4;
  6502.          dst += 4;
  6503.       }
  6504.       src_row += src_stride;
  6505.       dst_row += dst_stride/sizeof(*dst_row);
  6506.    }
  6507. }
  6508.  
  6509. static INLINE void
  6510. util_format_r16g16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6511. {
  6512.    unsigned x, y;
  6513.    for(y = 0; y < height; y += 1) {
  6514.       const float *src = src_row;
  6515.       uint8_t *dst = dst_row;
  6516.       for(x = 0; x < width; x += 1) {
  6517.          union util_format_r16g16_float pixel;
  6518.          pixel.chan.r = util_float_to_half(src[0]);
  6519.          pixel.chan.g = util_float_to_half(src[1]);
  6520.          memcpy(dst, &pixel, sizeof pixel);
  6521.          src += 4;
  6522.          dst += 4;
  6523.       }
  6524.       dst_row += dst_stride;
  6525.       src_row += src_stride/sizeof(*src_row);
  6526.    }
  6527. }
  6528.  
  6529. static INLINE void
  6530. util_format_r16g16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6531. {
  6532.          union util_format_r16g16_float pixel;
  6533.          memcpy(&pixel, src, sizeof pixel);
  6534.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6535.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6536.          dst[2] = 0; /* b */
  6537.          dst[3] = 1; /* a */
  6538. }
  6539.  
  6540. static INLINE void
  6541. util_format_r16g16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6542. {
  6543.    unsigned x, y;
  6544.    for(y = 0; y < height; y += 1) {
  6545.       uint8_t *dst = dst_row;
  6546.       const uint8_t *src = src_row;
  6547.       for(x = 0; x < width; x += 1) {
  6548.          union util_format_r16g16_float pixel;
  6549.          memcpy(&pixel, src, sizeof pixel);
  6550.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  6551.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
  6552.          dst[2] = 0; /* b */
  6553.          dst[3] = 255; /* a */
  6554.          src += 4;
  6555.          dst += 4;
  6556.       }
  6557.       src_row += src_stride;
  6558.       dst_row += dst_stride/sizeof(*dst_row);
  6559.    }
  6560. }
  6561.  
  6562. static INLINE void
  6563. util_format_r16g16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6564. {
  6565.    unsigned x, y;
  6566.    for(y = 0; y < height; y += 1) {
  6567.       const uint8_t *src = src_row;
  6568.       uint8_t *dst = dst_row;
  6569.       for(x = 0; x < width; x += 1) {
  6570.          union util_format_r16g16_float pixel;
  6571.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  6572.          pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
  6573.          memcpy(dst, &pixel, sizeof pixel);
  6574.          src += 4;
  6575.          dst += 4;
  6576.       }
  6577.       dst_row += dst_stride;
  6578.       src_row += src_stride/sizeof(*src_row);
  6579.    }
  6580. }
  6581.  
  6582. union util_format_r16g16b16_float {
  6583.    struct {
  6584.       uint16_t r;
  6585.       uint16_t g;
  6586.       uint16_t b;
  6587.    } chan;
  6588. };
  6589.  
  6590. static INLINE void
  6591. util_format_r16g16b16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6592. {
  6593.    unsigned x, y;
  6594.    for(y = 0; y < height; y += 1) {
  6595.       float *dst = dst_row;
  6596.       const uint8_t *src = src_row;
  6597.       for(x = 0; x < width; x += 1) {
  6598.          union util_format_r16g16b16_float pixel;
  6599.          memcpy(&pixel, src, sizeof pixel);
  6600.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6601.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6602.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  6603.          dst[3] = 1; /* a */
  6604.          src += 6;
  6605.          dst += 4;
  6606.       }
  6607.       src_row += src_stride;
  6608.       dst_row += dst_stride/sizeof(*dst_row);
  6609.    }
  6610. }
  6611.  
  6612. static INLINE void
  6613. util_format_r16g16b16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6614. {
  6615.    unsigned x, y;
  6616.    for(y = 0; y < height; y += 1) {
  6617.       const float *src = src_row;
  6618.       uint8_t *dst = dst_row;
  6619.       for(x = 0; x < width; x += 1) {
  6620.          union util_format_r16g16b16_float pixel;
  6621.          pixel.chan.r = util_float_to_half(src[0]);
  6622.          pixel.chan.g = util_float_to_half(src[1]);
  6623.          pixel.chan.b = util_float_to_half(src[2]);
  6624.          memcpy(dst, &pixel, sizeof pixel);
  6625.          src += 4;
  6626.          dst += 6;
  6627.       }
  6628.       dst_row += dst_stride;
  6629.       src_row += src_stride/sizeof(*src_row);
  6630.    }
  6631. }
  6632.  
  6633. static INLINE void
  6634. util_format_r16g16b16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6635. {
  6636.          union util_format_r16g16b16_float pixel;
  6637.          memcpy(&pixel, src, sizeof pixel);
  6638.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6639.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6640.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  6641.          dst[3] = 1; /* a */
  6642. }
  6643.  
  6644. static INLINE void
  6645. util_format_r16g16b16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6646. {
  6647.    unsigned x, y;
  6648.    for(y = 0; y < height; y += 1) {
  6649.       uint8_t *dst = dst_row;
  6650.       const uint8_t *src = src_row;
  6651.       for(x = 0; x < width; x += 1) {
  6652.          union util_format_r16g16b16_float pixel;
  6653.          memcpy(&pixel, src, sizeof pixel);
  6654.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  6655.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
  6656.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
  6657.          dst[3] = 255; /* a */
  6658.          src += 6;
  6659.          dst += 4;
  6660.       }
  6661.       src_row += src_stride;
  6662.       dst_row += dst_stride/sizeof(*dst_row);
  6663.    }
  6664. }
  6665.  
  6666. static INLINE void
  6667. util_format_r16g16b16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6668. {
  6669.    unsigned x, y;
  6670.    for(y = 0; y < height; y += 1) {
  6671.       const uint8_t *src = src_row;
  6672.       uint8_t *dst = dst_row;
  6673.       for(x = 0; x < width; x += 1) {
  6674.          union util_format_r16g16b16_float pixel;
  6675.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  6676.          pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
  6677.          pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
  6678.          memcpy(dst, &pixel, sizeof pixel);
  6679.          src += 4;
  6680.          dst += 6;
  6681.       }
  6682.       dst_row += dst_stride;
  6683.       src_row += src_stride/sizeof(*src_row);
  6684.    }
  6685. }
  6686.  
  6687. union util_format_r16g16b16a16_float {
  6688.    uint64_t value;
  6689.    struct {
  6690.       uint16_t r;
  6691.       uint16_t g;
  6692.       uint16_t b;
  6693.       uint16_t a;
  6694.    } chan;
  6695. };
  6696.  
  6697. static INLINE void
  6698. util_format_r16g16b16a16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6699. {
  6700.    unsigned x, y;
  6701.    for(y = 0; y < height; y += 1) {
  6702.       float *dst = dst_row;
  6703.       const uint8_t *src = src_row;
  6704.       for(x = 0; x < width; x += 1) {
  6705.          union util_format_r16g16b16a16_float pixel;
  6706.          memcpy(&pixel, src, sizeof pixel);
  6707.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6708.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6709.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  6710.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  6711.          src += 8;
  6712.          dst += 4;
  6713.       }
  6714.       src_row += src_stride;
  6715.       dst_row += dst_stride/sizeof(*dst_row);
  6716.    }
  6717. }
  6718.  
  6719. static INLINE void
  6720. util_format_r16g16b16a16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6721. {
  6722.    unsigned x, y;
  6723.    for(y = 0; y < height; y += 1) {
  6724.       const float *src = src_row;
  6725.       uint8_t *dst = dst_row;
  6726.       for(x = 0; x < width; x += 1) {
  6727.          union util_format_r16g16b16a16_float pixel;
  6728.          pixel.chan.r = util_float_to_half(src[0]);
  6729.          pixel.chan.g = util_float_to_half(src[1]);
  6730.          pixel.chan.b = util_float_to_half(src[2]);
  6731.          pixel.chan.a = util_float_to_half(src[3]);
  6732.          memcpy(dst, &pixel, sizeof pixel);
  6733.          src += 4;
  6734.          dst += 8;
  6735.       }
  6736.       dst_row += dst_stride;
  6737.       src_row += src_stride/sizeof(*src_row);
  6738.    }
  6739. }
  6740.  
  6741. static INLINE void
  6742. util_format_r16g16b16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6743. {
  6744.          union util_format_r16g16b16a16_float pixel;
  6745.          memcpy(&pixel, src, sizeof pixel);
  6746.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  6747.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  6748.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  6749.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  6750. }
  6751.  
  6752. static INLINE void
  6753. util_format_r16g16b16a16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6754. {
  6755.    unsigned x, y;
  6756.    for(y = 0; y < height; y += 1) {
  6757.       uint8_t *dst = dst_row;
  6758.       const uint8_t *src = src_row;
  6759.       for(x = 0; x < width; x += 1) {
  6760.          union util_format_r16g16b16a16_float pixel;
  6761.          memcpy(&pixel, src, sizeof pixel);
  6762.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  6763.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
  6764.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
  6765.          dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
  6766.          src += 8;
  6767.          dst += 4;
  6768.       }
  6769.       src_row += src_stride;
  6770.       dst_row += dst_stride/sizeof(*dst_row);
  6771.    }
  6772. }
  6773.  
  6774. static INLINE void
  6775. util_format_r16g16b16a16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6776. {
  6777.    unsigned x, y;
  6778.    for(y = 0; y < height; y += 1) {
  6779.       const uint8_t *src = src_row;
  6780.       uint8_t *dst = dst_row;
  6781.       for(x = 0; x < width; x += 1) {
  6782.          union util_format_r16g16b16a16_float pixel;
  6783.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  6784.          pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
  6785.          pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
  6786.          pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
  6787.          memcpy(dst, &pixel, sizeof pixel);
  6788.          src += 4;
  6789.          dst += 8;
  6790.       }
  6791.       dst_row += dst_stride;
  6792.       src_row += src_stride/sizeof(*src_row);
  6793.    }
  6794. }
  6795.  
  6796. union util_format_r16_unorm {
  6797.    uint16_t value;
  6798.    struct {
  6799.       uint16_t r;
  6800.    } chan;
  6801. };
  6802.  
  6803. static INLINE void
  6804. util_format_r16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6805. {
  6806.    unsigned x, y;
  6807.    for(y = 0; y < height; y += 1) {
  6808.       float *dst = dst_row;
  6809.       const uint8_t *src = src_row;
  6810.       for(x = 0; x < width; x += 1) {
  6811.          uint16_t value = *(const uint16_t *)src;
  6812.          uint16_t r;
  6813.          r = value;
  6814.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  6815.          dst[1] = 0; /* g */
  6816.          dst[2] = 0; /* b */
  6817.          dst[3] = 1; /* a */
  6818.          src += 2;
  6819.          dst += 4;
  6820.       }
  6821.       src_row += src_stride;
  6822.       dst_row += dst_stride/sizeof(*dst_row);
  6823.    }
  6824. }
  6825.  
  6826. static INLINE void
  6827. util_format_r16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6828. {
  6829.    unsigned x, y;
  6830.    for(y = 0; y < height; y += 1) {
  6831.       const float *src = src_row;
  6832.       uint8_t *dst = dst_row;
  6833.       for(x = 0; x < width; x += 1) {
  6834.          uint16_t value = 0;
  6835.          value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  6836.          *(uint16_t *)dst = value;
  6837.          src += 4;
  6838.          dst += 2;
  6839.       }
  6840.       dst_row += dst_stride;
  6841.       src_row += src_stride/sizeof(*src_row);
  6842.    }
  6843. }
  6844.  
  6845. static INLINE void
  6846. util_format_r16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6847. {
  6848.          uint16_t value = *(const uint16_t *)src;
  6849.          uint16_t r;
  6850.          r = value;
  6851.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  6852.          dst[1] = 0; /* g */
  6853.          dst[2] = 0; /* b */
  6854.          dst[3] = 1; /* a */
  6855. }
  6856.  
  6857. static INLINE void
  6858. util_format_r16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6859. {
  6860.    unsigned x, y;
  6861.    for(y = 0; y < height; y += 1) {
  6862.       uint8_t *dst = dst_row;
  6863.       const uint8_t *src = src_row;
  6864.       for(x = 0; x < width; x += 1) {
  6865.          uint16_t value = *(const uint16_t *)src;
  6866.          uint16_t r;
  6867.          r = value;
  6868.          dst[0] = (uint8_t)(r >> 8); /* r */
  6869.          dst[1] = 0; /* g */
  6870.          dst[2] = 0; /* b */
  6871.          dst[3] = 255; /* a */
  6872.          src += 2;
  6873.          dst += 4;
  6874.       }
  6875.       src_row += src_stride;
  6876.       dst_row += dst_stride/sizeof(*dst_row);
  6877.    }
  6878. }
  6879.  
  6880. static INLINE void
  6881. util_format_r16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6882. {
  6883.    unsigned x, y;
  6884.    for(y = 0; y < height; y += 1) {
  6885.       const uint8_t *src = src_row;
  6886.       uint8_t *dst = dst_row;
  6887.       for(x = 0; x < width; x += 1) {
  6888.          uint16_t value = 0;
  6889.          value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  6890.          *(uint16_t *)dst = value;
  6891.          src += 4;
  6892.          dst += 2;
  6893.       }
  6894.       dst_row += dst_stride;
  6895.       src_row += src_stride/sizeof(*src_row);
  6896.    }
  6897. }
  6898.  
  6899. union util_format_r16g16_unorm {
  6900.    uint32_t value;
  6901.    struct {
  6902.       uint16_t r;
  6903.       uint16_t g;
  6904.    } chan;
  6905. };
  6906.  
  6907. static INLINE void
  6908. util_format_r16g16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6909. {
  6910.    unsigned x, y;
  6911.    for(y = 0; y < height; y += 1) {
  6912.       float *dst = dst_row;
  6913.       const uint8_t *src = src_row;
  6914.       for(x = 0; x < width; x += 1) {
  6915.          uint32_t value = *(const uint32_t *)src;
  6916.          uint32_t r;
  6917.          uint32_t g;
  6918.          r = (value) & 0xffff;
  6919.          g = value >> 16;
  6920.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  6921.          dst[1] = (float)(g * (1.0f/0xffff)); /* g */
  6922.          dst[2] = 0; /* b */
  6923.          dst[3] = 1; /* a */
  6924.          src += 4;
  6925.          dst += 4;
  6926.       }
  6927.       src_row += src_stride;
  6928.       dst_row += dst_stride/sizeof(*dst_row);
  6929.    }
  6930. }
  6931.  
  6932. static INLINE void
  6933. util_format_r16g16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  6934. {
  6935.    unsigned x, y;
  6936.    for(y = 0; y < height; y += 1) {
  6937.       const float *src = src_row;
  6938.       uint8_t *dst = dst_row;
  6939.       for(x = 0; x < width; x += 1) {
  6940.          uint32_t value = 0;
  6941.          value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
  6942.          value |= ((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff)) << 16;
  6943.          *(uint32_t *)dst = value;
  6944.          src += 4;
  6945.          dst += 4;
  6946.       }
  6947.       dst_row += dst_stride;
  6948.       src_row += src_stride/sizeof(*src_row);
  6949.    }
  6950. }
  6951.  
  6952. static INLINE void
  6953. util_format_r16g16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  6954. {
  6955.          uint32_t value = *(const uint32_t *)src;
  6956.          uint32_t r;
  6957.          uint32_t g;
  6958.          r = (value) & 0xffff;
  6959.          g = value >> 16;
  6960.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  6961.          dst[1] = (float)(g * (1.0f/0xffff)); /* g */
  6962.          dst[2] = 0; /* b */
  6963.          dst[3] = 1; /* a */
  6964. }
  6965.  
  6966. static INLINE void
  6967. util_format_r16g16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6968. {
  6969.    unsigned x, y;
  6970.    for(y = 0; y < height; y += 1) {
  6971.       uint8_t *dst = dst_row;
  6972.       const uint8_t *src = src_row;
  6973.       for(x = 0; x < width; x += 1) {
  6974.          uint32_t value = *(const uint32_t *)src;
  6975.          uint32_t r;
  6976.          uint32_t g;
  6977.          r = (value) & 0xffff;
  6978.          g = value >> 16;
  6979.          dst[0] = (uint8_t)(r >> 8); /* r */
  6980.          dst[1] = (uint8_t)(g >> 8); /* g */
  6981.          dst[2] = 0; /* b */
  6982.          dst[3] = 255; /* a */
  6983.          src += 4;
  6984.          dst += 4;
  6985.       }
  6986.       src_row += src_stride;
  6987.       dst_row += dst_stride/sizeof(*dst_row);
  6988.    }
  6989. }
  6990.  
  6991. static INLINE void
  6992. util_format_r16g16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  6993. {
  6994.    unsigned x, y;
  6995.    for(y = 0; y < height; y += 1) {
  6996.       const uint8_t *src = src_row;
  6997.       uint8_t *dst = dst_row;
  6998.       for(x = 0; x < width; x += 1) {
  6999.          uint32_t value = 0;
  7000.          value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
  7001.          value |= ((uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff)) << 16;
  7002.          *(uint32_t *)dst = value;
  7003.          src += 4;
  7004.          dst += 4;
  7005.       }
  7006.       dst_row += dst_stride;
  7007.       src_row += src_stride/sizeof(*src_row);
  7008.    }
  7009. }
  7010.  
  7011. union util_format_r16g16b16_unorm {
  7012.    struct {
  7013.       uint16_t r;
  7014.       uint16_t g;
  7015.       uint16_t b;
  7016.    } chan;
  7017. };
  7018.  
  7019. static INLINE void
  7020. util_format_r16g16b16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7021. {
  7022.    unsigned x, y;
  7023.    for(y = 0; y < height; y += 1) {
  7024.       float *dst = dst_row;
  7025.       const uint8_t *src = src_row;
  7026.       for(x = 0; x < width; x += 1) {
  7027.          union util_format_r16g16b16_unorm pixel;
  7028.          memcpy(&pixel, src, sizeof pixel);
  7029.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  7030.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  7031.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  7032.          dst[3] = 1; /* a */
  7033.          src += 6;
  7034.          dst += 4;
  7035.       }
  7036.       src_row += src_stride;
  7037.       dst_row += dst_stride/sizeof(*dst_row);
  7038.    }
  7039. }
  7040.  
  7041. static INLINE void
  7042. util_format_r16g16b16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7043. {
  7044.    unsigned x, y;
  7045.    for(y = 0; y < height; y += 1) {
  7046.       const float *src = src_row;
  7047.       uint8_t *dst = dst_row;
  7048.       for(x = 0; x < width; x += 1) {
  7049.          union util_format_r16g16b16_unorm pixel;
  7050.          pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  7051.          pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
  7052.          pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
  7053.          memcpy(dst, &pixel, sizeof pixel);
  7054.          src += 4;
  7055.          dst += 6;
  7056.       }
  7057.       dst_row += dst_stride;
  7058.       src_row += src_stride/sizeof(*src_row);
  7059.    }
  7060. }
  7061.  
  7062. static INLINE void
  7063. util_format_r16g16b16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7064. {
  7065.          union util_format_r16g16b16_unorm pixel;
  7066.          memcpy(&pixel, src, sizeof pixel);
  7067.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  7068.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  7069.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  7070.          dst[3] = 1; /* a */
  7071. }
  7072.  
  7073. static INLINE void
  7074. util_format_r16g16b16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7075. {
  7076.    unsigned x, y;
  7077.    for(y = 0; y < height; y += 1) {
  7078.       uint8_t *dst = dst_row;
  7079.       const uint8_t *src = src_row;
  7080.       for(x = 0; x < width; x += 1) {
  7081.          union util_format_r16g16b16_unorm pixel;
  7082.          memcpy(&pixel, src, sizeof pixel);
  7083.          dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
  7084.          dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
  7085.          dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
  7086.          dst[3] = 255; /* a */
  7087.          src += 6;
  7088.          dst += 4;
  7089.       }
  7090.       src_row += src_stride;
  7091.       dst_row += dst_stride/sizeof(*dst_row);
  7092.    }
  7093. }
  7094.  
  7095. static INLINE void
  7096. util_format_r16g16b16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7097. {
  7098.    unsigned x, y;
  7099.    for(y = 0; y < height; y += 1) {
  7100.       const uint8_t *src = src_row;
  7101.       uint8_t *dst = dst_row;
  7102.       for(x = 0; x < width; x += 1) {
  7103.          union util_format_r16g16b16_unorm pixel;
  7104.          pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  7105.          pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
  7106.          pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
  7107.          memcpy(dst, &pixel, sizeof pixel);
  7108.          src += 4;
  7109.          dst += 6;
  7110.       }
  7111.       dst_row += dst_stride;
  7112.       src_row += src_stride/sizeof(*src_row);
  7113.    }
  7114. }
  7115.  
  7116. union util_format_r16g16b16a16_unorm {
  7117.    uint64_t value;
  7118.    struct {
  7119.       uint16_t r;
  7120.       uint16_t g;
  7121.       uint16_t b;
  7122.       uint16_t a;
  7123.    } chan;
  7124. };
  7125.  
  7126. static INLINE void
  7127. util_format_r16g16b16a16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7128. {
  7129.    unsigned x, y;
  7130.    for(y = 0; y < height; y += 1) {
  7131.       float *dst = dst_row;
  7132.       const uint8_t *src = src_row;
  7133.       for(x = 0; x < width; x += 1) {
  7134.          union util_format_r16g16b16a16_unorm pixel;
  7135.          memcpy(&pixel, src, sizeof pixel);
  7136.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  7137.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  7138.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  7139.          dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */
  7140.          src += 8;
  7141.          dst += 4;
  7142.       }
  7143.       src_row += src_stride;
  7144.       dst_row += dst_stride/sizeof(*dst_row);
  7145.    }
  7146. }
  7147.  
  7148. static INLINE void
  7149. util_format_r16g16b16a16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7150. {
  7151.    unsigned x, y;
  7152.    for(y = 0; y < height; y += 1) {
  7153.       const float *src = src_row;
  7154.       uint8_t *dst = dst_row;
  7155.       for(x = 0; x < width; x += 1) {
  7156.          union util_format_r16g16b16a16_unorm pixel;
  7157.          pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  7158.          pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
  7159.          pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
  7160.          pixel.chan.a = (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff);
  7161.          memcpy(dst, &pixel, sizeof pixel);
  7162.          src += 4;
  7163.          dst += 8;
  7164.       }
  7165.       dst_row += dst_stride;
  7166.       src_row += src_stride/sizeof(*src_row);
  7167.    }
  7168. }
  7169.  
  7170. static INLINE void
  7171. util_format_r16g16b16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7172. {
  7173.          union util_format_r16g16b16a16_unorm pixel;
  7174.          memcpy(&pixel, src, sizeof pixel);
  7175.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  7176.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  7177.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  7178.          dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */
  7179. }
  7180.  
  7181. static INLINE void
  7182. util_format_r16g16b16a16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7183. {
  7184.    unsigned x, y;
  7185.    for(y = 0; y < height; y += 1) {
  7186.       uint8_t *dst = dst_row;
  7187.       const uint8_t *src = src_row;
  7188.       for(x = 0; x < width; x += 1) {
  7189.          union util_format_r16g16b16a16_unorm pixel;
  7190.          memcpy(&pixel, src, sizeof pixel);
  7191.          dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
  7192.          dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
  7193.          dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
  7194.          dst[3] = (uint8_t)(pixel.chan.a >> 8); /* a */
  7195.          src += 8;
  7196.          dst += 4;
  7197.       }
  7198.       src_row += src_stride;
  7199.       dst_row += dst_stride/sizeof(*dst_row);
  7200.    }
  7201. }
  7202.  
  7203. static INLINE void
  7204. util_format_r16g16b16a16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7205. {
  7206.    unsigned x, y;
  7207.    for(y = 0; y < height; y += 1) {
  7208.       const uint8_t *src = src_row;
  7209.       uint8_t *dst = dst_row;
  7210.       for(x = 0; x < width; x += 1) {
  7211.          union util_format_r16g16b16a16_unorm pixel;
  7212.          pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  7213.          pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
  7214.          pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
  7215.          pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff);
  7216.          memcpy(dst, &pixel, sizeof pixel);
  7217.          src += 4;
  7218.          dst += 8;
  7219.       }
  7220.       dst_row += dst_stride;
  7221.       src_row += src_stride/sizeof(*src_row);
  7222.    }
  7223. }
  7224.  
  7225. union util_format_r16_uscaled {
  7226.    uint16_t value;
  7227.    struct {
  7228.       uint16_t r;
  7229.    } chan;
  7230. };
  7231.  
  7232. static INLINE void
  7233. util_format_r16_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7234. {
  7235.    unsigned x, y;
  7236.    for(y = 0; y < height; y += 1) {
  7237.       float *dst = dst_row;
  7238.       const uint8_t *src = src_row;
  7239.       for(x = 0; x < width; x += 1) {
  7240.          uint16_t value = *(const uint16_t *)src;
  7241.          uint16_t r;
  7242.          r = value;
  7243.          dst[0] = (float)r; /* r */
  7244.          dst[1] = 0; /* g */
  7245.          dst[2] = 0; /* b */
  7246.          dst[3] = 1; /* a */
  7247.          src += 2;
  7248.          dst += 4;
  7249.       }
  7250.       src_row += src_stride;
  7251.       dst_row += dst_stride/sizeof(*dst_row);
  7252.    }
  7253. }
  7254.  
  7255. static INLINE void
  7256. util_format_r16_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7257. {
  7258.    unsigned x, y;
  7259.    for(y = 0; y < height; y += 1) {
  7260.       const float *src = src_row;
  7261.       uint8_t *dst = dst_row;
  7262.       for(x = 0; x < width; x += 1) {
  7263.          uint16_t value = 0;
  7264.          value |= (uint16_t)CLAMP(src[0], 0, 65535);
  7265.          *(uint16_t *)dst = value;
  7266.          src += 4;
  7267.          dst += 2;
  7268.       }
  7269.       dst_row += dst_stride;
  7270.       src_row += src_stride/sizeof(*src_row);
  7271.    }
  7272. }
  7273.  
  7274. static INLINE void
  7275. util_format_r16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7276. {
  7277.          uint16_t value = *(const uint16_t *)src;
  7278.          uint16_t r;
  7279.          r = value;
  7280.          dst[0] = (float)r; /* r */
  7281.          dst[1] = 0; /* g */
  7282.          dst[2] = 0; /* b */
  7283.          dst[3] = 1; /* a */
  7284. }
  7285.  
  7286. static INLINE void
  7287. util_format_r16_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7288. {
  7289.    unsigned x, y;
  7290.    for(y = 0; y < height; y += 1) {
  7291.       uint8_t *dst = dst_row;
  7292.       const uint8_t *src = src_row;
  7293.       for(x = 0; x < width; x += 1) {
  7294.          uint16_t value = *(const uint16_t *)src;
  7295.          uint16_t r;
  7296.          r = value;
  7297.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  7298.          dst[1] = 0; /* g */
  7299.          dst[2] = 0; /* b */
  7300.          dst[3] = 255; /* a */
  7301.          src += 2;
  7302.          dst += 4;
  7303.       }
  7304.       src_row += src_stride;
  7305.       dst_row += dst_stride/sizeof(*dst_row);
  7306.    }
  7307. }
  7308.  
  7309. static INLINE void
  7310. util_format_r16_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7311. {
  7312.    unsigned x, y;
  7313.    for(y = 0; y < height; y += 1) {
  7314.       const uint8_t *src = src_row;
  7315.       uint8_t *dst = dst_row;
  7316.       for(x = 0; x < width; x += 1) {
  7317.          uint16_t value = 0;
  7318.          value |= (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  7319.          *(uint16_t *)dst = value;
  7320.          src += 4;
  7321.          dst += 2;
  7322.       }
  7323.       dst_row += dst_stride;
  7324.       src_row += src_stride/sizeof(*src_row);
  7325.    }
  7326. }
  7327.  
  7328. union util_format_r16g16_uscaled {
  7329.    uint32_t value;
  7330.    struct {
  7331.       uint16_t r;
  7332.       uint16_t g;
  7333.    } chan;
  7334. };
  7335.  
  7336. static INLINE void
  7337. util_format_r16g16_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7338. {
  7339.    unsigned x, y;
  7340.    for(y = 0; y < height; y += 1) {
  7341.       float *dst = dst_row;
  7342.       const uint8_t *src = src_row;
  7343.       for(x = 0; x < width; x += 1) {
  7344.          uint32_t value = *(const uint32_t *)src;
  7345.          uint32_t r;
  7346.          uint32_t g;
  7347.          r = (value) & 0xffff;
  7348.          g = value >> 16;
  7349.          dst[0] = (float)r; /* r */
  7350.          dst[1] = (float)g; /* g */
  7351.          dst[2] = 0; /* b */
  7352.          dst[3] = 1; /* a */
  7353.          src += 4;
  7354.          dst += 4;
  7355.       }
  7356.       src_row += src_stride;
  7357.       dst_row += dst_stride/sizeof(*dst_row);
  7358.    }
  7359. }
  7360.  
  7361. static INLINE void
  7362. util_format_r16g16_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7363. {
  7364.    unsigned x, y;
  7365.    for(y = 0; y < height; y += 1) {
  7366.       const float *src = src_row;
  7367.       uint8_t *dst = dst_row;
  7368.       for(x = 0; x < width; x += 1) {
  7369.          uint32_t value = 0;
  7370.          value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
  7371.          value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16;
  7372.          *(uint32_t *)dst = value;
  7373.          src += 4;
  7374.          dst += 4;
  7375.       }
  7376.       dst_row += dst_stride;
  7377.       src_row += src_stride/sizeof(*src_row);
  7378.    }
  7379. }
  7380.  
  7381. static INLINE void
  7382. util_format_r16g16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7383. {
  7384.          uint32_t value = *(const uint32_t *)src;
  7385.          uint32_t r;
  7386.          uint32_t g;
  7387.          r = (value) & 0xffff;
  7388.          g = value >> 16;
  7389.          dst[0] = (float)r; /* r */
  7390.          dst[1] = (float)g; /* g */
  7391.          dst[2] = 0; /* b */
  7392.          dst[3] = 1; /* a */
  7393. }
  7394.  
  7395. static INLINE void
  7396. util_format_r16g16_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7397. {
  7398.    unsigned x, y;
  7399.    for(y = 0; y < height; y += 1) {
  7400.       uint8_t *dst = dst_row;
  7401.       const uint8_t *src = src_row;
  7402.       for(x = 0; x < width; x += 1) {
  7403.          uint32_t value = *(const uint32_t *)src;
  7404.          uint32_t r;
  7405.          uint32_t g;
  7406.          r = (value) & 0xffff;
  7407.          g = value >> 16;
  7408.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  7409.          dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
  7410.          dst[2] = 0; /* b */
  7411.          dst[3] = 255; /* a */
  7412.          src += 4;
  7413.          dst += 4;
  7414.       }
  7415.       src_row += src_stride;
  7416.       dst_row += dst_stride/sizeof(*dst_row);
  7417.    }
  7418. }
  7419.  
  7420. static INLINE void
  7421. util_format_r16g16_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7422. {
  7423.    unsigned x, y;
  7424.    for(y = 0; y < height; y += 1) {
  7425.       const uint8_t *src = src_row;
  7426.       uint8_t *dst = dst_row;
  7427.       for(x = 0; x < width; x += 1) {
  7428.          uint32_t value = 0;
  7429.          value |= ((uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff;
  7430.          value |= ((uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16;
  7431.          *(uint32_t *)dst = value;
  7432.          src += 4;
  7433.          dst += 4;
  7434.       }
  7435.       dst_row += dst_stride;
  7436.       src_row += src_stride/sizeof(*src_row);
  7437.    }
  7438. }
  7439.  
  7440. union util_format_r16g16b16_uscaled {
  7441.    struct {
  7442.       uint16_t r;
  7443.       uint16_t g;
  7444.       uint16_t b;
  7445.    } chan;
  7446. };
  7447.  
  7448. static INLINE void
  7449. util_format_r16g16b16_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7450. {
  7451.    unsigned x, y;
  7452.    for(y = 0; y < height; y += 1) {
  7453.       float *dst = dst_row;
  7454.       const uint8_t *src = src_row;
  7455.       for(x = 0; x < width; x += 1) {
  7456.          union util_format_r16g16b16_uscaled pixel;
  7457.          memcpy(&pixel, src, sizeof pixel);
  7458.          dst[0] = (float)pixel.chan.r; /* r */
  7459.          dst[1] = (float)pixel.chan.g; /* g */
  7460.          dst[2] = (float)pixel.chan.b; /* b */
  7461.          dst[3] = 1; /* a */
  7462.          src += 6;
  7463.          dst += 4;
  7464.       }
  7465.       src_row += src_stride;
  7466.       dst_row += dst_stride/sizeof(*dst_row);
  7467.    }
  7468. }
  7469.  
  7470. static INLINE void
  7471. util_format_r16g16b16_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7472. {
  7473.    unsigned x, y;
  7474.    for(y = 0; y < height; y += 1) {
  7475.       const float *src = src_row;
  7476.       uint8_t *dst = dst_row;
  7477.       for(x = 0; x < width; x += 1) {
  7478.          union util_format_r16g16b16_uscaled pixel;
  7479.          pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
  7480.          pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
  7481.          pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
  7482.          memcpy(dst, &pixel, sizeof pixel);
  7483.          src += 4;
  7484.          dst += 6;
  7485.       }
  7486.       dst_row += dst_stride;
  7487.       src_row += src_stride/sizeof(*src_row);
  7488.    }
  7489. }
  7490.  
  7491. static INLINE void
  7492. util_format_r16g16b16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7493. {
  7494.          union util_format_r16g16b16_uscaled pixel;
  7495.          memcpy(&pixel, src, sizeof pixel);
  7496.          dst[0] = (float)pixel.chan.r; /* r */
  7497.          dst[1] = (float)pixel.chan.g; /* g */
  7498.          dst[2] = (float)pixel.chan.b; /* b */
  7499.          dst[3] = 1; /* a */
  7500. }
  7501.  
  7502. static INLINE void
  7503. util_format_r16g16b16_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7504. {
  7505.    unsigned x, y;
  7506.    for(y = 0; y < height; y += 1) {
  7507.       uint8_t *dst = dst_row;
  7508.       const uint8_t *src = src_row;
  7509.       for(x = 0; x < width; x += 1) {
  7510.          union util_format_r16g16b16_uscaled pixel;
  7511.          memcpy(&pixel, src, sizeof pixel);
  7512.          dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  7513.          dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  7514.          dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
  7515.          dst[3] = 255; /* a */
  7516.          src += 6;
  7517.          dst += 4;
  7518.       }
  7519.       src_row += src_stride;
  7520.       dst_row += dst_stride/sizeof(*dst_row);
  7521.    }
  7522. }
  7523.  
  7524. static INLINE void
  7525. util_format_r16g16b16_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7526. {
  7527.    unsigned x, y;
  7528.    for(y = 0; y < height; y += 1) {
  7529.       const uint8_t *src = src_row;
  7530.       uint8_t *dst = dst_row;
  7531.       for(x = 0; x < width; x += 1) {
  7532.          union util_format_r16g16b16_uscaled pixel;
  7533.          pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  7534.          pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  7535.          pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  7536.          memcpy(dst, &pixel, sizeof pixel);
  7537.          src += 4;
  7538.          dst += 6;
  7539.       }
  7540.       dst_row += dst_stride;
  7541.       src_row += src_stride/sizeof(*src_row);
  7542.    }
  7543. }
  7544.  
  7545. union util_format_r16g16b16a16_uscaled {
  7546.    uint64_t value;
  7547.    struct {
  7548.       uint16_t r;
  7549.       uint16_t g;
  7550.       uint16_t b;
  7551.       uint16_t a;
  7552.    } chan;
  7553. };
  7554.  
  7555. static INLINE void
  7556. util_format_r16g16b16a16_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7557. {
  7558.    unsigned x, y;
  7559.    for(y = 0; y < height; y += 1) {
  7560.       float *dst = dst_row;
  7561.       const uint8_t *src = src_row;
  7562.       for(x = 0; x < width; x += 1) {
  7563.          union util_format_r16g16b16a16_uscaled pixel;
  7564.          memcpy(&pixel, src, sizeof pixel);
  7565.          dst[0] = (float)pixel.chan.r; /* r */
  7566.          dst[1] = (float)pixel.chan.g; /* g */
  7567.          dst[2] = (float)pixel.chan.b; /* b */
  7568.          dst[3] = (float)pixel.chan.a; /* a */
  7569.          src += 8;
  7570.          dst += 4;
  7571.       }
  7572.       src_row += src_stride;
  7573.       dst_row += dst_stride/sizeof(*dst_row);
  7574.    }
  7575. }
  7576.  
  7577. static INLINE void
  7578. util_format_r16g16b16a16_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7579. {
  7580.    unsigned x, y;
  7581.    for(y = 0; y < height; y += 1) {
  7582.       const float *src = src_row;
  7583.       uint8_t *dst = dst_row;
  7584.       for(x = 0; x < width; x += 1) {
  7585.          union util_format_r16g16b16a16_uscaled pixel;
  7586.          pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
  7587.          pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
  7588.          pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
  7589.          pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535);
  7590.          memcpy(dst, &pixel, sizeof pixel);
  7591.          src += 4;
  7592.          dst += 8;
  7593.       }
  7594.       dst_row += dst_stride;
  7595.       src_row += src_stride/sizeof(*src_row);
  7596.    }
  7597. }
  7598.  
  7599. static INLINE void
  7600. util_format_r16g16b16a16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7601. {
  7602.          union util_format_r16g16b16a16_uscaled pixel;
  7603.          memcpy(&pixel, src, sizeof pixel);
  7604.          dst[0] = (float)pixel.chan.r; /* r */
  7605.          dst[1] = (float)pixel.chan.g; /* g */
  7606.          dst[2] = (float)pixel.chan.b; /* b */
  7607.          dst[3] = (float)pixel.chan.a; /* a */
  7608. }
  7609.  
  7610. static INLINE void
  7611. util_format_r16g16b16a16_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7612. {
  7613.    unsigned x, y;
  7614.    for(y = 0; y < height; y += 1) {
  7615.       uint8_t *dst = dst_row;
  7616.       const uint8_t *src = src_row;
  7617.       for(x = 0; x < width; x += 1) {
  7618.          union util_format_r16g16b16a16_uscaled pixel;
  7619.          memcpy(&pixel, src, sizeof pixel);
  7620.          dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  7621.          dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  7622.          dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
  7623.          dst[3] = (uint8_t)(((uint32_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */
  7624.          src += 8;
  7625.          dst += 4;
  7626.       }
  7627.       src_row += src_stride;
  7628.       dst_row += dst_stride/sizeof(*dst_row);
  7629.    }
  7630. }
  7631.  
  7632. static INLINE void
  7633. util_format_r16g16b16a16_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7634. {
  7635.    unsigned x, y;
  7636.    for(y = 0; y < height; y += 1) {
  7637.       const uint8_t *src = src_row;
  7638.       uint8_t *dst = dst_row;
  7639.       for(x = 0; x < width; x += 1) {
  7640.          union util_format_r16g16b16a16_uscaled pixel;
  7641.          pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  7642.          pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  7643.          pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  7644.          pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0x1 / 0xff);
  7645.          memcpy(dst, &pixel, sizeof pixel);
  7646.          src += 4;
  7647.          dst += 8;
  7648.       }
  7649.       dst_row += dst_stride;
  7650.       src_row += src_stride/sizeof(*src_row);
  7651.    }
  7652. }
  7653.  
  7654. union util_format_r16_snorm {
  7655.    uint16_t value;
  7656.    struct {
  7657.       int16_t r;
  7658.    } chan;
  7659. };
  7660.  
  7661. static INLINE void
  7662. util_format_r16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7663. {
  7664.    unsigned x, y;
  7665.    for(y = 0; y < height; y += 1) {
  7666.       float *dst = dst_row;
  7667.       const uint8_t *src = src_row;
  7668.       for(x = 0; x < width; x += 1) {
  7669.          uint16_t value = *(const uint16_t *)src;
  7670.          int16_t r;
  7671.          r = (int16_t)(value) ;
  7672.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  7673.          dst[1] = 0; /* g */
  7674.          dst[2] = 0; /* b */
  7675.          dst[3] = 1; /* a */
  7676.          src += 2;
  7677.          dst += 4;
  7678.       }
  7679.       src_row += src_stride;
  7680.       dst_row += dst_stride/sizeof(*dst_row);
  7681.    }
  7682. }
  7683.  
  7684. static INLINE void
  7685. util_format_r16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7686. {
  7687.    unsigned x, y;
  7688.    for(y = 0; y < height; y += 1) {
  7689.       const float *src = src_row;
  7690.       uint8_t *dst = dst_row;
  7691.       for(x = 0; x < width; x += 1) {
  7692.          uint16_t value = 0;
  7693.          value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ;
  7694.          *(uint16_t *)dst = value;
  7695.          src += 4;
  7696.          dst += 2;
  7697.       }
  7698.       dst_row += dst_stride;
  7699.       src_row += src_stride/sizeof(*src_row);
  7700.    }
  7701. }
  7702.  
  7703. static INLINE void
  7704. util_format_r16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7705. {
  7706.          uint16_t value = *(const uint16_t *)src;
  7707.          int16_t r;
  7708.          r = (int16_t)(value) ;
  7709.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  7710.          dst[1] = 0; /* g */
  7711.          dst[2] = 0; /* b */
  7712.          dst[3] = 1; /* a */
  7713. }
  7714.  
  7715. static INLINE void
  7716. util_format_r16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7717. {
  7718.    unsigned x, y;
  7719.    for(y = 0; y < height; y += 1) {
  7720.       uint8_t *dst = dst_row;
  7721.       const uint8_t *src = src_row;
  7722.       for(x = 0; x < width; x += 1) {
  7723.          uint16_t value = *(const uint16_t *)src;
  7724.          int16_t r;
  7725.          r = (int16_t)(value) ;
  7726.          dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
  7727.          dst[1] = 0; /* g */
  7728.          dst[2] = 0; /* b */
  7729.          dst[3] = 255; /* a */
  7730.          src += 2;
  7731.          dst += 4;
  7732.       }
  7733.       src_row += src_stride;
  7734.       dst_row += dst_stride/sizeof(*dst_row);
  7735.    }
  7736. }
  7737.  
  7738. static INLINE void
  7739. util_format_r16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7740. {
  7741.    unsigned x, y;
  7742.    for(y = 0; y < height; y += 1) {
  7743.       const uint8_t *src = src_row;
  7744.       uint8_t *dst = dst_row;
  7745.       for(x = 0; x < width; x += 1) {
  7746.          uint16_t value = 0;
  7747.          value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ;
  7748.          *(uint16_t *)dst = value;
  7749.          src += 4;
  7750.          dst += 2;
  7751.       }
  7752.       dst_row += dst_stride;
  7753.       src_row += src_stride/sizeof(*src_row);
  7754.    }
  7755. }
  7756.  
  7757. union util_format_r16g16_snorm {
  7758.    uint32_t value;
  7759.    struct {
  7760.       int16_t r;
  7761.       int16_t g;
  7762.    } chan;
  7763. };
  7764.  
  7765. static INLINE void
  7766. util_format_r16g16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7767. {
  7768.    unsigned x, y;
  7769.    for(y = 0; y < height; y += 1) {
  7770.       float *dst = dst_row;
  7771.       const uint8_t *src = src_row;
  7772.       for(x = 0; x < width; x += 1) {
  7773.          uint32_t value = *(const uint32_t *)src;
  7774.          int32_t r;
  7775.          int32_t g;
  7776.          r = ((int32_t)(value << 16) ) >> 16;
  7777.          g = ((int32_t)(value) ) >> 16;
  7778.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  7779.          dst[1] = (float)(g * (1.0f/0x7fff)); /* g */
  7780.          dst[2] = 0; /* b */
  7781.          dst[3] = 1; /* a */
  7782.          src += 4;
  7783.          dst += 4;
  7784.       }
  7785.       src_row += src_stride;
  7786.       dst_row += dst_stride/sizeof(*dst_row);
  7787.    }
  7788. }
  7789.  
  7790. static INLINE void
  7791. util_format_r16g16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7792. {
  7793.    unsigned x, y;
  7794.    for(y = 0; y < height; y += 1) {
  7795.       const float *src = src_row;
  7796.       uint8_t *dst = dst_row;
  7797.       for(x = 0; x < width; x += 1) {
  7798.          uint32_t value = 0;
  7799.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
  7800.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff)) << 16) ;
  7801.          *(uint32_t *)dst = value;
  7802.          src += 4;
  7803.          dst += 4;
  7804.       }
  7805.       dst_row += dst_stride;
  7806.       src_row += src_stride/sizeof(*src_row);
  7807.    }
  7808. }
  7809.  
  7810. static INLINE void
  7811. util_format_r16g16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7812. {
  7813.          uint32_t value = *(const uint32_t *)src;
  7814.          int32_t r;
  7815.          int32_t g;
  7816.          r = ((int32_t)(value << 16) ) >> 16;
  7817.          g = ((int32_t)(value) ) >> 16;
  7818.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  7819.          dst[1] = (float)(g * (1.0f/0x7fff)); /* g */
  7820.          dst[2] = 0; /* b */
  7821.          dst[3] = 1; /* a */
  7822. }
  7823.  
  7824. static INLINE void
  7825. util_format_r16g16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7826. {
  7827.    unsigned x, y;
  7828.    for(y = 0; y < height; y += 1) {
  7829.       uint8_t *dst = dst_row;
  7830.       const uint8_t *src = src_row;
  7831.       for(x = 0; x < width; x += 1) {
  7832.          uint32_t value = *(const uint32_t *)src;
  7833.          int32_t r;
  7834.          int32_t g;
  7835.          r = ((int32_t)(value << 16) ) >> 16;
  7836.          g = ((int32_t)(value) ) >> 16;
  7837.          dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
  7838.          dst[1] = (uint8_t)(MAX2(g, 0) >> 7); /* g */
  7839.          dst[2] = 0; /* b */
  7840.          dst[3] = 255; /* a */
  7841.          src += 4;
  7842.          dst += 4;
  7843.       }
  7844.       src_row += src_stride;
  7845.       dst_row += dst_stride/sizeof(*dst_row);
  7846.    }
  7847. }
  7848.  
  7849. static INLINE void
  7850. util_format_r16g16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7851. {
  7852.    unsigned x, y;
  7853.    for(y = 0; y < height; y += 1) {
  7854.       const uint8_t *src = src_row;
  7855.       uint8_t *dst = dst_row;
  7856.       for(x = 0; x < width; x += 1) {
  7857.          uint32_t value = 0;
  7858.          value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
  7859.          value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff)) << 16) ;
  7860.          *(uint32_t *)dst = value;
  7861.          src += 4;
  7862.          dst += 4;
  7863.       }
  7864.       dst_row += dst_stride;
  7865.       src_row += src_stride/sizeof(*src_row);
  7866.    }
  7867. }
  7868.  
  7869. union util_format_r16g16b16_snorm {
  7870.    struct {
  7871.       int16_t r;
  7872.       int16_t g;
  7873.       int16_t b;
  7874.    } chan;
  7875. };
  7876.  
  7877. static INLINE void
  7878. util_format_r16g16b16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7879. {
  7880.    unsigned x, y;
  7881.    for(y = 0; y < height; y += 1) {
  7882.       float *dst = dst_row;
  7883.       const uint8_t *src = src_row;
  7884.       for(x = 0; x < width; x += 1) {
  7885.          union util_format_r16g16b16_snorm pixel;
  7886.          memcpy(&pixel, src, sizeof pixel);
  7887.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  7888.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  7889.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  7890.          dst[3] = 1; /* a */
  7891.          src += 6;
  7892.          dst += 4;
  7893.       }
  7894.       src_row += src_stride;
  7895.       dst_row += dst_stride/sizeof(*dst_row);
  7896.    }
  7897. }
  7898.  
  7899. static INLINE void
  7900. util_format_r16g16b16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  7901. {
  7902.    unsigned x, y;
  7903.    for(y = 0; y < height; y += 1) {
  7904.       const float *src = src_row;
  7905.       uint8_t *dst = dst_row;
  7906.       for(x = 0; x < width; x += 1) {
  7907.          union util_format_r16g16b16_snorm pixel;
  7908.          pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
  7909.          pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
  7910.          pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
  7911.          memcpy(dst, &pixel, sizeof pixel);
  7912.          src += 4;
  7913.          dst += 6;
  7914.       }
  7915.       dst_row += dst_stride;
  7916.       src_row += src_stride/sizeof(*src_row);
  7917.    }
  7918. }
  7919.  
  7920. static INLINE void
  7921. util_format_r16g16b16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  7922. {
  7923.          union util_format_r16g16b16_snorm pixel;
  7924.          memcpy(&pixel, src, sizeof pixel);
  7925.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  7926.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  7927.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  7928.          dst[3] = 1; /* a */
  7929. }
  7930.  
  7931. static INLINE void
  7932. util_format_r16g16b16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7933. {
  7934.    unsigned x, y;
  7935.    for(y = 0; y < height; y += 1) {
  7936.       uint8_t *dst = dst_row;
  7937.       const uint8_t *src = src_row;
  7938.       for(x = 0; x < width; x += 1) {
  7939.          union util_format_r16g16b16_snorm pixel;
  7940.          memcpy(&pixel, src, sizeof pixel);
  7941.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
  7942.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
  7943.          dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
  7944.          dst[3] = 255; /* a */
  7945.          src += 6;
  7946.          dst += 4;
  7947.       }
  7948.       src_row += src_stride;
  7949.       dst_row += dst_stride/sizeof(*dst_row);
  7950.    }
  7951. }
  7952.  
  7953. static INLINE void
  7954. util_format_r16g16b16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7955. {
  7956.    unsigned x, y;
  7957.    for(y = 0; y < height; y += 1) {
  7958.       const uint8_t *src = src_row;
  7959.       uint8_t *dst = dst_row;
  7960.       for(x = 0; x < width; x += 1) {
  7961.          union util_format_r16g16b16_snorm pixel;
  7962.          pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
  7963.          pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
  7964.          pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
  7965.          memcpy(dst, &pixel, sizeof pixel);
  7966.          src += 4;
  7967.          dst += 6;
  7968.       }
  7969.       dst_row += dst_stride;
  7970.       src_row += src_stride/sizeof(*src_row);
  7971.    }
  7972. }
  7973.  
  7974. union util_format_r16g16b16a16_snorm {
  7975.    uint64_t value;
  7976.    struct {
  7977.       int16_t r;
  7978.       int16_t g;
  7979.       int16_t b;
  7980.       int16_t a;
  7981.    } chan;
  7982. };
  7983.  
  7984. static INLINE void
  7985. util_format_r16g16b16a16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  7986. {
  7987.    unsigned x, y;
  7988.    for(y = 0; y < height; y += 1) {
  7989.       float *dst = dst_row;
  7990.       const uint8_t *src = src_row;
  7991.       for(x = 0; x < width; x += 1) {
  7992.          union util_format_r16g16b16a16_snorm pixel;
  7993.          memcpy(&pixel, src, sizeof pixel);
  7994.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  7995.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  7996.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  7997.          dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */
  7998.          src += 8;
  7999.          dst += 4;
  8000.       }
  8001.       src_row += src_stride;
  8002.       dst_row += dst_stride/sizeof(*dst_row);
  8003.    }
  8004. }
  8005.  
  8006. static INLINE void
  8007. util_format_r16g16b16a16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8008. {
  8009.    unsigned x, y;
  8010.    for(y = 0; y < height; y += 1) {
  8011.       const float *src = src_row;
  8012.       uint8_t *dst = dst_row;
  8013.       for(x = 0; x < width; x += 1) {
  8014.          union util_format_r16g16b16a16_snorm pixel;
  8015.          pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
  8016.          pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
  8017.          pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
  8018.          pixel.chan.a = (int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff);
  8019.          memcpy(dst, &pixel, sizeof pixel);
  8020.          src += 4;
  8021.          dst += 8;
  8022.       }
  8023.       dst_row += dst_stride;
  8024.       src_row += src_stride/sizeof(*src_row);
  8025.    }
  8026. }
  8027.  
  8028. static INLINE void
  8029. util_format_r16g16b16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8030. {
  8031.          union util_format_r16g16b16a16_snorm pixel;
  8032.          memcpy(&pixel, src, sizeof pixel);
  8033.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  8034.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  8035.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  8036.          dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */
  8037. }
  8038.  
  8039. static INLINE void
  8040. util_format_r16g16b16a16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8041. {
  8042.    unsigned x, y;
  8043.    for(y = 0; y < height; y += 1) {
  8044.       uint8_t *dst = dst_row;
  8045.       const uint8_t *src = src_row;
  8046.       for(x = 0; x < width; x += 1) {
  8047.          union util_format_r16g16b16a16_snorm pixel;
  8048.          memcpy(&pixel, src, sizeof pixel);
  8049.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
  8050.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
  8051.          dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
  8052.          dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 7); /* a */
  8053.          src += 8;
  8054.          dst += 4;
  8055.       }
  8056.       src_row += src_stride;
  8057.       dst_row += dst_stride/sizeof(*dst_row);
  8058.    }
  8059. }
  8060.  
  8061. static INLINE void
  8062. util_format_r16g16b16a16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8063. {
  8064.    unsigned x, y;
  8065.    for(y = 0; y < height; y += 1) {
  8066.       const uint8_t *src = src_row;
  8067.       uint8_t *dst = dst_row;
  8068.       for(x = 0; x < width; x += 1) {
  8069.          union util_format_r16g16b16a16_snorm pixel;
  8070.          pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
  8071.          pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
  8072.          pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
  8073.          pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff);
  8074.          memcpy(dst, &pixel, sizeof pixel);
  8075.          src += 4;
  8076.          dst += 8;
  8077.       }
  8078.       dst_row += dst_stride;
  8079.       src_row += src_stride/sizeof(*src_row);
  8080.    }
  8081. }
  8082.  
  8083. union util_format_r16_sscaled {
  8084.    uint16_t value;
  8085.    struct {
  8086.       int16_t r;
  8087.    } chan;
  8088. };
  8089.  
  8090. static INLINE void
  8091. util_format_r16_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8092. {
  8093.    unsigned x, y;
  8094.    for(y = 0; y < height; y += 1) {
  8095.       float *dst = dst_row;
  8096.       const uint8_t *src = src_row;
  8097.       for(x = 0; x < width; x += 1) {
  8098.          uint16_t value = *(const uint16_t *)src;
  8099.          int16_t r;
  8100.          r = (int16_t)(value) ;
  8101.          dst[0] = (float)r; /* r */
  8102.          dst[1] = 0; /* g */
  8103.          dst[2] = 0; /* b */
  8104.          dst[3] = 1; /* a */
  8105.          src += 2;
  8106.          dst += 4;
  8107.       }
  8108.       src_row += src_stride;
  8109.       dst_row += dst_stride/sizeof(*dst_row);
  8110.    }
  8111. }
  8112.  
  8113. static INLINE void
  8114. util_format_r16_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8115. {
  8116.    unsigned x, y;
  8117.    for(y = 0; y < height; y += 1) {
  8118.       const float *src = src_row;
  8119.       uint8_t *dst = dst_row;
  8120.       for(x = 0; x < width; x += 1) {
  8121.          uint16_t value = 0;
  8122.          value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
  8123.          *(uint16_t *)dst = value;
  8124.          src += 4;
  8125.          dst += 2;
  8126.       }
  8127.       dst_row += dst_stride;
  8128.       src_row += src_stride/sizeof(*src_row);
  8129.    }
  8130. }
  8131.  
  8132. static INLINE void
  8133. util_format_r16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8134. {
  8135.          uint16_t value = *(const uint16_t *)src;
  8136.          int16_t r;
  8137.          r = (int16_t)(value) ;
  8138.          dst[0] = (float)r; /* r */
  8139.          dst[1] = 0; /* g */
  8140.          dst[2] = 0; /* b */
  8141.          dst[3] = 1; /* a */
  8142. }
  8143.  
  8144. static INLINE void
  8145. util_format_r16_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8146. {
  8147.    unsigned x, y;
  8148.    for(y = 0; y < height; y += 1) {
  8149.       uint8_t *dst = dst_row;
  8150.       const uint8_t *src = src_row;
  8151.       for(x = 0; x < width; x += 1) {
  8152.          uint16_t value = *(const uint16_t *)src;
  8153.          int16_t r;
  8154.          r = (int16_t)(value) ;
  8155.          dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  8156.          dst[1] = 0; /* g */
  8157.          dst[2] = 0; /* b */
  8158.          dst[3] = 255; /* a */
  8159.          src += 2;
  8160.          dst += 4;
  8161.       }
  8162.       src_row += src_stride;
  8163.       dst_row += dst_stride/sizeof(*dst_row);
  8164.    }
  8165. }
  8166.  
  8167. static INLINE void
  8168. util_format_r16_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8169. {
  8170.    unsigned x, y;
  8171.    for(y = 0; y < height; y += 1) {
  8172.       const uint8_t *src = src_row;
  8173.       uint8_t *dst = dst_row;
  8174.       for(x = 0; x < width; x += 1) {
  8175.          uint16_t value = 0;
  8176.          value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ;
  8177.          *(uint16_t *)dst = value;
  8178.          src += 4;
  8179.          dst += 2;
  8180.       }
  8181.       dst_row += dst_stride;
  8182.       src_row += src_stride/sizeof(*src_row);
  8183.    }
  8184. }
  8185.  
  8186. union util_format_r16g16_sscaled {
  8187.    uint32_t value;
  8188.    struct {
  8189.       int16_t r;
  8190.       int16_t g;
  8191.    } chan;
  8192. };
  8193.  
  8194. static INLINE void
  8195. util_format_r16g16_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8196. {
  8197.    unsigned x, y;
  8198.    for(y = 0; y < height; y += 1) {
  8199.       float *dst = dst_row;
  8200.       const uint8_t *src = src_row;
  8201.       for(x = 0; x < width; x += 1) {
  8202.          uint32_t value = *(const uint32_t *)src;
  8203.          int32_t r;
  8204.          int32_t g;
  8205.          r = ((int32_t)(value << 16) ) >> 16;
  8206.          g = ((int32_t)(value) ) >> 16;
  8207.          dst[0] = (float)r; /* r */
  8208.          dst[1] = (float)g; /* g */
  8209.          dst[2] = 0; /* b */
  8210.          dst[3] = 1; /* a */
  8211.          src += 4;
  8212.          dst += 4;
  8213.       }
  8214.       src_row += src_stride;
  8215.       dst_row += dst_stride/sizeof(*dst_row);
  8216.    }
  8217. }
  8218.  
  8219. static INLINE void
  8220. util_format_r16g16_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8221. {
  8222.    unsigned x, y;
  8223.    for(y = 0; y < height; y += 1) {
  8224.       const float *src = src_row;
  8225.       uint8_t *dst = dst_row;
  8226.       for(x = 0; x < width; x += 1) {
  8227.          uint32_t value = 0;
  8228.          value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
  8229.          value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ;
  8230.          *(uint32_t *)dst = value;
  8231.          src += 4;
  8232.          dst += 4;
  8233.       }
  8234.       dst_row += dst_stride;
  8235.       src_row += src_stride/sizeof(*src_row);
  8236.    }
  8237. }
  8238.  
  8239. static INLINE void
  8240. util_format_r16g16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8241. {
  8242.          uint32_t value = *(const uint32_t *)src;
  8243.          int32_t r;
  8244.          int32_t g;
  8245.          r = ((int32_t)(value << 16) ) >> 16;
  8246.          g = ((int32_t)(value) ) >> 16;
  8247.          dst[0] = (float)r; /* r */
  8248.          dst[1] = (float)g; /* g */
  8249.          dst[2] = 0; /* b */
  8250.          dst[3] = 1; /* a */
  8251. }
  8252.  
  8253. static INLINE void
  8254. util_format_r16g16_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8255. {
  8256.    unsigned x, y;
  8257.    for(y = 0; y < height; y += 1) {
  8258.       uint8_t *dst = dst_row;
  8259.       const uint8_t *src = src_row;
  8260.       for(x = 0; x < width; x += 1) {
  8261.          uint32_t value = *(const uint32_t *)src;
  8262.          int32_t r;
  8263.          int32_t g;
  8264.          r = ((int32_t)(value << 16) ) >> 16;
  8265.          g = ((int32_t)(value) ) >> 16;
  8266.          dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  8267.          dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
  8268.          dst[2] = 0; /* b */
  8269.          dst[3] = 255; /* a */
  8270.          src += 4;
  8271.          dst += 4;
  8272.       }
  8273.       src_row += src_stride;
  8274.       dst_row += dst_stride/sizeof(*dst_row);
  8275.    }
  8276. }
  8277.  
  8278. static INLINE void
  8279. util_format_r16g16_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8280. {
  8281.    unsigned x, y;
  8282.    for(y = 0; y < height; y += 1) {
  8283.       const uint8_t *src = src_row;
  8284.       uint8_t *dst = dst_row;
  8285.       for(x = 0; x < width; x += 1) {
  8286.          uint32_t value = 0;
  8287.          value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff) ;
  8288.          value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16) ;
  8289.          *(uint32_t *)dst = value;
  8290.          src += 4;
  8291.          dst += 4;
  8292.       }
  8293.       dst_row += dst_stride;
  8294.       src_row += src_stride/sizeof(*src_row);
  8295.    }
  8296. }
  8297.  
  8298. union util_format_r16g16b16_sscaled {
  8299.    struct {
  8300.       int16_t r;
  8301.       int16_t g;
  8302.       int16_t b;
  8303.    } chan;
  8304. };
  8305.  
  8306. static INLINE void
  8307. util_format_r16g16b16_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8308. {
  8309.    unsigned x, y;
  8310.    for(y = 0; y < height; y += 1) {
  8311.       float *dst = dst_row;
  8312.       const uint8_t *src = src_row;
  8313.       for(x = 0; x < width; x += 1) {
  8314.          union util_format_r16g16b16_sscaled pixel;
  8315.          memcpy(&pixel, src, sizeof pixel);
  8316.          dst[0] = (float)pixel.chan.r; /* r */
  8317.          dst[1] = (float)pixel.chan.g; /* g */
  8318.          dst[2] = (float)pixel.chan.b; /* b */
  8319.          dst[3] = 1; /* a */
  8320.          src += 6;
  8321.          dst += 4;
  8322.       }
  8323.       src_row += src_stride;
  8324.       dst_row += dst_stride/sizeof(*dst_row);
  8325.    }
  8326. }
  8327.  
  8328. static INLINE void
  8329. util_format_r16g16b16_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8330. {
  8331.    unsigned x, y;
  8332.    for(y = 0; y < height; y += 1) {
  8333.       const float *src = src_row;
  8334.       uint8_t *dst = dst_row;
  8335.       for(x = 0; x < width; x += 1) {
  8336.          union util_format_r16g16b16_sscaled pixel;
  8337.          pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
  8338.          pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
  8339.          pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
  8340.          memcpy(dst, &pixel, sizeof pixel);
  8341.          src += 4;
  8342.          dst += 6;
  8343.       }
  8344.       dst_row += dst_stride;
  8345.       src_row += src_stride/sizeof(*src_row);
  8346.    }
  8347. }
  8348.  
  8349. static INLINE void
  8350. util_format_r16g16b16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8351. {
  8352.          union util_format_r16g16b16_sscaled pixel;
  8353.          memcpy(&pixel, src, sizeof pixel);
  8354.          dst[0] = (float)pixel.chan.r; /* r */
  8355.          dst[1] = (float)pixel.chan.g; /* g */
  8356.          dst[2] = (float)pixel.chan.b; /* b */
  8357.          dst[3] = 1; /* a */
  8358. }
  8359.  
  8360. static INLINE void
  8361. util_format_r16g16b16_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8362. {
  8363.    unsigned x, y;
  8364.    for(y = 0; y < height; y += 1) {
  8365.       uint8_t *dst = dst_row;
  8366.       const uint8_t *src = src_row;
  8367.       for(x = 0; x < width; x += 1) {
  8368.          union util_format_r16g16b16_sscaled pixel;
  8369.          memcpy(&pixel, src, sizeof pixel);
  8370.          dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  8371.          dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  8372.          dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
  8373.          dst[3] = 255; /* a */
  8374.          src += 6;
  8375.          dst += 4;
  8376.       }
  8377.       src_row += src_stride;
  8378.       dst_row += dst_stride/sizeof(*dst_row);
  8379.    }
  8380. }
  8381.  
  8382. static INLINE void
  8383. util_format_r16g16b16_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8384. {
  8385.    unsigned x, y;
  8386.    for(y = 0; y < height; y += 1) {
  8387.       const uint8_t *src = src_row;
  8388.       uint8_t *dst = dst_row;
  8389.       for(x = 0; x < width; x += 1) {
  8390.          union util_format_r16g16b16_sscaled pixel;
  8391.          pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  8392.          pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  8393.          pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  8394.          memcpy(dst, &pixel, sizeof pixel);
  8395.          src += 4;
  8396.          dst += 6;
  8397.       }
  8398.       dst_row += dst_stride;
  8399.       src_row += src_stride/sizeof(*src_row);
  8400.    }
  8401. }
  8402.  
  8403. union util_format_r16g16b16a16_sscaled {
  8404.    uint64_t value;
  8405.    struct {
  8406.       int16_t r;
  8407.       int16_t g;
  8408.       int16_t b;
  8409.       int16_t a;
  8410.    } chan;
  8411. };
  8412.  
  8413. static INLINE void
  8414. util_format_r16g16b16a16_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8415. {
  8416.    unsigned x, y;
  8417.    for(y = 0; y < height; y += 1) {
  8418.       float *dst = dst_row;
  8419.       const uint8_t *src = src_row;
  8420.       for(x = 0; x < width; x += 1) {
  8421.          union util_format_r16g16b16a16_sscaled pixel;
  8422.          memcpy(&pixel, src, sizeof pixel);
  8423.          dst[0] = (float)pixel.chan.r; /* r */
  8424.          dst[1] = (float)pixel.chan.g; /* g */
  8425.          dst[2] = (float)pixel.chan.b; /* b */
  8426.          dst[3] = (float)pixel.chan.a; /* a */
  8427.          src += 8;
  8428.          dst += 4;
  8429.       }
  8430.       src_row += src_stride;
  8431.       dst_row += dst_stride/sizeof(*dst_row);
  8432.    }
  8433. }
  8434.  
  8435. static INLINE void
  8436. util_format_r16g16b16a16_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8437. {
  8438.    unsigned x, y;
  8439.    for(y = 0; y < height; y += 1) {
  8440.       const float *src = src_row;
  8441.       uint8_t *dst = dst_row;
  8442.       for(x = 0; x < width; x += 1) {
  8443.          union util_format_r16g16b16a16_sscaled pixel;
  8444.          pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
  8445.          pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
  8446.          pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
  8447.          pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767);
  8448.          memcpy(dst, &pixel, sizeof pixel);
  8449.          src += 4;
  8450.          dst += 8;
  8451.       }
  8452.       dst_row += dst_stride;
  8453.       src_row += src_stride/sizeof(*src_row);
  8454.    }
  8455. }
  8456.  
  8457. static INLINE void
  8458. util_format_r16g16b16a16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8459. {
  8460.          union util_format_r16g16b16a16_sscaled pixel;
  8461.          memcpy(&pixel, src, sizeof pixel);
  8462.          dst[0] = (float)pixel.chan.r; /* r */
  8463.          dst[1] = (float)pixel.chan.g; /* g */
  8464.          dst[2] = (float)pixel.chan.b; /* b */
  8465.          dst[3] = (float)pixel.chan.a; /* a */
  8466. }
  8467.  
  8468. static INLINE void
  8469. util_format_r16g16b16a16_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8470. {
  8471.    unsigned x, y;
  8472.    for(y = 0; y < height; y += 1) {
  8473.       uint8_t *dst = dst_row;
  8474.       const uint8_t *src = src_row;
  8475.       for(x = 0; x < width; x += 1) {
  8476.          union util_format_r16g16b16a16_sscaled pixel;
  8477.          memcpy(&pixel, src, sizeof pixel);
  8478.          dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  8479.          dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  8480.          dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
  8481.          dst[3] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */
  8482.          src += 8;
  8483.          dst += 4;
  8484.       }
  8485.       src_row += src_stride;
  8486.       dst_row += dst_stride/sizeof(*dst_row);
  8487.    }
  8488. }
  8489.  
  8490. static INLINE void
  8491. util_format_r16g16b16a16_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8492. {
  8493.    unsigned x, y;
  8494.    for(y = 0; y < height; y += 1) {
  8495.       const uint8_t *src = src_row;
  8496.       uint8_t *dst = dst_row;
  8497.       for(x = 0; x < width; x += 1) {
  8498.          union util_format_r16g16b16a16_sscaled pixel;
  8499.          pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  8500.          pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  8501.          pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  8502.          pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x1 / 0xff);
  8503.          memcpy(dst, &pixel, sizeof pixel);
  8504.          src += 4;
  8505.          dst += 8;
  8506.       }
  8507.       dst_row += dst_stride;
  8508.       src_row += src_stride/sizeof(*src_row);
  8509.    }
  8510. }
  8511.  
  8512. union util_format_r8_unorm {
  8513.    uint8_t value;
  8514.    struct {
  8515.       uint8_t r;
  8516.    } chan;
  8517. };
  8518.  
  8519. static INLINE void
  8520. util_format_r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8521. {
  8522.    unsigned x, y;
  8523.    for(y = 0; y < height; y += 1) {
  8524.       float *dst = dst_row;
  8525.       const uint8_t *src = src_row;
  8526.       for(x = 0; x < width; x += 1) {
  8527.          uint8_t value = *(const uint8_t *)src;
  8528.          uint8_t r;
  8529.          r = value;
  8530.          dst[0] = ubyte_to_float(r); /* r */
  8531.          dst[1] = 0; /* g */
  8532.          dst[2] = 0; /* b */
  8533.          dst[3] = 1; /* a */
  8534.          src += 1;
  8535.          dst += 4;
  8536.       }
  8537.       src_row += src_stride;
  8538.       dst_row += dst_stride/sizeof(*dst_row);
  8539.    }
  8540. }
  8541.  
  8542. static INLINE void
  8543. util_format_r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8544. {
  8545.    unsigned x, y;
  8546.    for(y = 0; y < height; y += 1) {
  8547.       const float *src = src_row;
  8548.       uint8_t *dst = dst_row;
  8549.       for(x = 0; x < width; x += 1) {
  8550.          uint8_t value = 0;
  8551.          value |= float_to_ubyte(src[0]);
  8552.          *(uint8_t *)dst = value;
  8553.          src += 4;
  8554.          dst += 1;
  8555.       }
  8556.       dst_row += dst_stride;
  8557.       src_row += src_stride/sizeof(*src_row);
  8558.    }
  8559. }
  8560.  
  8561. static INLINE void
  8562. util_format_r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8563. {
  8564.          uint8_t value = *(const uint8_t *)src;
  8565.          uint8_t r;
  8566.          r = value;
  8567.          dst[0] = ubyte_to_float(r); /* r */
  8568.          dst[1] = 0; /* g */
  8569.          dst[2] = 0; /* b */
  8570.          dst[3] = 1; /* a */
  8571. }
  8572.  
  8573. static INLINE void
  8574. util_format_r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8575. {
  8576.    unsigned x, y;
  8577.    for(y = 0; y < height; y += 1) {
  8578.       uint8_t *dst = dst_row;
  8579.       const uint8_t *src = src_row;
  8580.       for(x = 0; x < width; x += 1) {
  8581.          uint8_t value = *(const uint8_t *)src;
  8582.          uint8_t r;
  8583.          r = value;
  8584.          dst[0] = r; /* r */
  8585.          dst[1] = 0; /* g */
  8586.          dst[2] = 0; /* b */
  8587.          dst[3] = 255; /* a */
  8588.          src += 1;
  8589.          dst += 4;
  8590.       }
  8591.       src_row += src_stride;
  8592.       dst_row += dst_stride/sizeof(*dst_row);
  8593.    }
  8594. }
  8595.  
  8596. static INLINE void
  8597. util_format_r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8598. {
  8599.    unsigned x, y;
  8600.    for(y = 0; y < height; y += 1) {
  8601.       const uint8_t *src = src_row;
  8602.       uint8_t *dst = dst_row;
  8603.       for(x = 0; x < width; x += 1) {
  8604.          uint8_t value = 0;
  8605.          value |= src[0];
  8606.          *(uint8_t *)dst = value;
  8607.          src += 4;
  8608.          dst += 1;
  8609.       }
  8610.       dst_row += dst_stride;
  8611.       src_row += src_stride/sizeof(*src_row);
  8612.    }
  8613. }
  8614.  
  8615. union util_format_r8g8_unorm {
  8616.    uint16_t value;
  8617.    struct {
  8618.       uint8_t r;
  8619.       uint8_t g;
  8620.    } chan;
  8621. };
  8622.  
  8623. static INLINE void
  8624. util_format_r8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8625. {
  8626.    unsigned x, y;
  8627.    for(y = 0; y < height; y += 1) {
  8628.       float *dst = dst_row;
  8629.       const uint8_t *src = src_row;
  8630.       for(x = 0; x < width; x += 1) {
  8631.          uint16_t value = *(const uint16_t *)src;
  8632.          uint16_t r;
  8633.          uint16_t g;
  8634.          r = (value) & 0xff;
  8635.          g = value >> 8;
  8636.          dst[0] = ubyte_to_float(r); /* r */
  8637.          dst[1] = ubyte_to_float(g); /* g */
  8638.          dst[2] = 0; /* b */
  8639.          dst[3] = 1; /* a */
  8640.          src += 2;
  8641.          dst += 4;
  8642.       }
  8643.       src_row += src_stride;
  8644.       dst_row += dst_stride/sizeof(*dst_row);
  8645.    }
  8646. }
  8647.  
  8648. static INLINE void
  8649. util_format_r8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8650. {
  8651.    unsigned x, y;
  8652.    for(y = 0; y < height; y += 1) {
  8653.       const float *src = src_row;
  8654.       uint8_t *dst = dst_row;
  8655.       for(x = 0; x < width; x += 1) {
  8656.          uint16_t value = 0;
  8657.          value |= (float_to_ubyte(src[0])) & 0xff;
  8658.          value |= (float_to_ubyte(src[1])) << 8;
  8659.          *(uint16_t *)dst = value;
  8660.          src += 4;
  8661.          dst += 2;
  8662.       }
  8663.       dst_row += dst_stride;
  8664.       src_row += src_stride/sizeof(*src_row);
  8665.    }
  8666. }
  8667.  
  8668. static INLINE void
  8669. util_format_r8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8670. {
  8671.          uint16_t value = *(const uint16_t *)src;
  8672.          uint16_t r;
  8673.          uint16_t g;
  8674.          r = (value) & 0xff;
  8675.          g = value >> 8;
  8676.          dst[0] = ubyte_to_float(r); /* r */
  8677.          dst[1] = ubyte_to_float(g); /* g */
  8678.          dst[2] = 0; /* b */
  8679.          dst[3] = 1; /* a */
  8680. }
  8681.  
  8682. static INLINE void
  8683. util_format_r8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8684. {
  8685.    unsigned x, y;
  8686.    for(y = 0; y < height; y += 1) {
  8687.       uint8_t *dst = dst_row;
  8688.       const uint8_t *src = src_row;
  8689.       for(x = 0; x < width; x += 1) {
  8690.          uint16_t value = *(const uint16_t *)src;
  8691.          uint16_t r;
  8692.          uint16_t g;
  8693.          r = (value) & 0xff;
  8694.          g = value >> 8;
  8695.          dst[0] = r; /* r */
  8696.          dst[1] = g; /* g */
  8697.          dst[2] = 0; /* b */
  8698.          dst[3] = 255; /* a */
  8699.          src += 2;
  8700.          dst += 4;
  8701.       }
  8702.       src_row += src_stride;
  8703.       dst_row += dst_stride/sizeof(*dst_row);
  8704.    }
  8705. }
  8706.  
  8707. static INLINE void
  8708. util_format_r8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8709. {
  8710.    unsigned x, y;
  8711.    for(y = 0; y < height; y += 1) {
  8712.       const uint8_t *src = src_row;
  8713.       uint8_t *dst = dst_row;
  8714.       for(x = 0; x < width; x += 1) {
  8715.          uint16_t value = 0;
  8716.          value |= (src[0]) & 0xff;
  8717.          value |= (src[1]) << 8;
  8718.          *(uint16_t *)dst = value;
  8719.          src += 4;
  8720.          dst += 2;
  8721.       }
  8722.       dst_row += dst_stride;
  8723.       src_row += src_stride/sizeof(*src_row);
  8724.    }
  8725. }
  8726.  
  8727. union util_format_r8g8b8_unorm {
  8728.    struct {
  8729.       uint8_t r;
  8730.       uint8_t g;
  8731.       uint8_t b;
  8732.    } chan;
  8733. };
  8734.  
  8735. static INLINE void
  8736. util_format_r8g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8737. {
  8738.    unsigned x, y;
  8739.    for(y = 0; y < height; y += 1) {
  8740.       float *dst = dst_row;
  8741.       const uint8_t *src = src_row;
  8742.       for(x = 0; x < width; x += 1) {
  8743.          union util_format_r8g8b8_unorm pixel;
  8744.          memcpy(&pixel, src, sizeof pixel);
  8745.          dst[0] = ubyte_to_float(pixel.chan.r); /* r */
  8746.          dst[1] = ubyte_to_float(pixel.chan.g); /* g */
  8747.          dst[2] = ubyte_to_float(pixel.chan.b); /* b */
  8748.          dst[3] = 1; /* a */
  8749.          src += 3;
  8750.          dst += 4;
  8751.       }
  8752.       src_row += src_stride;
  8753.       dst_row += dst_stride/sizeof(*dst_row);
  8754.    }
  8755. }
  8756.  
  8757. static INLINE void
  8758. util_format_r8g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8759. {
  8760.    unsigned x, y;
  8761.    for(y = 0; y < height; y += 1) {
  8762.       const float *src = src_row;
  8763.       uint8_t *dst = dst_row;
  8764.       for(x = 0; x < width; x += 1) {
  8765.          union util_format_r8g8b8_unorm pixel;
  8766.          pixel.chan.r = float_to_ubyte(src[0]);
  8767.          pixel.chan.g = float_to_ubyte(src[1]);
  8768.          pixel.chan.b = float_to_ubyte(src[2]);
  8769.          memcpy(dst, &pixel, sizeof pixel);
  8770.          src += 4;
  8771.          dst += 3;
  8772.       }
  8773.       dst_row += dst_stride;
  8774.       src_row += src_stride/sizeof(*src_row);
  8775.    }
  8776. }
  8777.  
  8778. static INLINE void
  8779. util_format_r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8780. {
  8781.          union util_format_r8g8b8_unorm pixel;
  8782.          memcpy(&pixel, src, sizeof pixel);
  8783.          dst[0] = ubyte_to_float(pixel.chan.r); /* r */
  8784.          dst[1] = ubyte_to_float(pixel.chan.g); /* g */
  8785.          dst[2] = ubyte_to_float(pixel.chan.b); /* b */
  8786.          dst[3] = 1; /* a */
  8787. }
  8788.  
  8789. static INLINE void
  8790. util_format_r8g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8791. {
  8792.    unsigned x, y;
  8793.    for(y = 0; y < height; y += 1) {
  8794.       uint8_t *dst = dst_row;
  8795.       const uint8_t *src = src_row;
  8796.       for(x = 0; x < width; x += 1) {
  8797.          union util_format_r8g8b8_unorm pixel;
  8798.          memcpy(&pixel, src, sizeof pixel);
  8799.          dst[0] = pixel.chan.r; /* r */
  8800.          dst[1] = pixel.chan.g; /* g */
  8801.          dst[2] = pixel.chan.b; /* b */
  8802.          dst[3] = 255; /* a */
  8803.          src += 3;
  8804.          dst += 4;
  8805.       }
  8806.       src_row += src_stride;
  8807.       dst_row += dst_stride/sizeof(*dst_row);
  8808.    }
  8809. }
  8810.  
  8811. static INLINE void
  8812. util_format_r8g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8813. {
  8814.    unsigned x, y;
  8815.    for(y = 0; y < height; y += 1) {
  8816.       const uint8_t *src = src_row;
  8817.       uint8_t *dst = dst_row;
  8818.       for(x = 0; x < width; x += 1) {
  8819.          union util_format_r8g8b8_unorm pixel;
  8820.          pixel.chan.r = src[0];
  8821.          pixel.chan.g = src[1];
  8822.          pixel.chan.b = src[2];
  8823.          memcpy(dst, &pixel, sizeof pixel);
  8824.          src += 4;
  8825.          dst += 3;
  8826.       }
  8827.       dst_row += dst_stride;
  8828.       src_row += src_stride/sizeof(*src_row);
  8829.    }
  8830. }
  8831.  
  8832. union util_format_r8g8b8a8_unorm {
  8833.    uint32_t value;
  8834.    struct {
  8835.       uint8_t r;
  8836.       uint8_t g;
  8837.       uint8_t b;
  8838.       uint8_t a;
  8839.    } chan;
  8840. };
  8841.  
  8842. static INLINE void
  8843. util_format_r8g8b8a8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8844. {
  8845.    unsigned x, y;
  8846.    for(y = 0; y < height; y += 1) {
  8847.       float *dst = dst_row;
  8848.       const uint8_t *src = src_row;
  8849.       for(x = 0; x < width; x += 1) {
  8850.          uint32_t value = *(const uint32_t *)src;
  8851.          uint32_t r;
  8852.          uint32_t g;
  8853.          uint32_t b;
  8854.          uint32_t a;
  8855.          r = (value) & 0xff;
  8856.          g = (value >> 8) & 0xff;
  8857.          b = (value >> 16) & 0xff;
  8858.          a = value >> 24;
  8859.          dst[0] = ubyte_to_float(r); /* r */
  8860.          dst[1] = ubyte_to_float(g); /* g */
  8861.          dst[2] = ubyte_to_float(b); /* b */
  8862.          dst[3] = ubyte_to_float(a); /* a */
  8863.          src += 4;
  8864.          dst += 4;
  8865.       }
  8866.       src_row += src_stride;
  8867.       dst_row += dst_stride/sizeof(*dst_row);
  8868.    }
  8869. }
  8870.  
  8871. static INLINE void
  8872. util_format_r8g8b8a8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8873. {
  8874.    unsigned x, y;
  8875.    for(y = 0; y < height; y += 1) {
  8876.       const float *src = src_row;
  8877.       uint8_t *dst = dst_row;
  8878.       for(x = 0; x < width; x += 1) {
  8879.          uint32_t value = 0;
  8880.          value |= (float_to_ubyte(src[0])) & 0xff;
  8881.          value |= ((float_to_ubyte(src[1])) & 0xff) << 8;
  8882.          value |= ((float_to_ubyte(src[2])) & 0xff) << 16;
  8883.          value |= (float_to_ubyte(src[3])) << 24;
  8884.          *(uint32_t *)dst = value;
  8885.          src += 4;
  8886.          dst += 4;
  8887.       }
  8888.       dst_row += dst_stride;
  8889.       src_row += src_stride/sizeof(*src_row);
  8890.    }
  8891. }
  8892.  
  8893. static INLINE void
  8894. util_format_r8g8b8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  8895. {
  8896.          uint32_t value = *(const uint32_t *)src;
  8897.          uint32_t r;
  8898.          uint32_t g;
  8899.          uint32_t b;
  8900.          uint32_t a;
  8901.          r = (value) & 0xff;
  8902.          g = (value >> 8) & 0xff;
  8903.          b = (value >> 16) & 0xff;
  8904.          a = value >> 24;
  8905.          dst[0] = ubyte_to_float(r); /* r */
  8906.          dst[1] = ubyte_to_float(g); /* g */
  8907.          dst[2] = ubyte_to_float(b); /* b */
  8908.          dst[3] = ubyte_to_float(a); /* a */
  8909. }
  8910.  
  8911. static INLINE void
  8912. util_format_r8g8b8a8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8913. {
  8914.    unsigned x, y;
  8915.    for(y = 0; y < height; y += 1) {
  8916.       uint8_t *dst = dst_row;
  8917.       const uint8_t *src = src_row;
  8918.       for(x = 0; x < width; x += 1) {
  8919.          uint32_t value = *(const uint32_t *)src;
  8920.          uint32_t r;
  8921.          uint32_t g;
  8922.          uint32_t b;
  8923.          uint32_t a;
  8924.          r = (value) & 0xff;
  8925.          g = (value >> 8) & 0xff;
  8926.          b = (value >> 16) & 0xff;
  8927.          a = value >> 24;
  8928.          dst[0] = r; /* r */
  8929.          dst[1] = g; /* g */
  8930.          dst[2] = b; /* b */
  8931.          dst[3] = a; /* a */
  8932.          src += 4;
  8933.          dst += 4;
  8934.       }
  8935.       src_row += src_stride;
  8936.       dst_row += dst_stride/sizeof(*dst_row);
  8937.    }
  8938. }
  8939.  
  8940. static INLINE void
  8941. util_format_r8g8b8a8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8942. {
  8943.    unsigned x, y;
  8944.    for(y = 0; y < height; y += 1) {
  8945.       const uint8_t *src = src_row;
  8946.       uint8_t *dst = dst_row;
  8947.       for(x = 0; x < width; x += 1) {
  8948.          uint32_t value = 0;
  8949.          value |= (src[0]) & 0xff;
  8950.          value |= ((src[1]) & 0xff) << 8;
  8951.          value |= ((src[2]) & 0xff) << 16;
  8952.          value |= (src[3]) << 24;
  8953.          *(uint32_t *)dst = value;
  8954.          src += 4;
  8955.          dst += 4;
  8956.       }
  8957.       dst_row += dst_stride;
  8958.       src_row += src_stride/sizeof(*src_row);
  8959.    }
  8960. }
  8961.  
  8962. union util_format_r8_uscaled {
  8963.    uint8_t value;
  8964.    struct {
  8965.       uint8_t r;
  8966.    } chan;
  8967. };
  8968.  
  8969. static INLINE void
  8970. util_format_r8_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  8971. {
  8972.    unsigned x, y;
  8973.    for(y = 0; y < height; y += 1) {
  8974.       float *dst = dst_row;
  8975.       const uint8_t *src = src_row;
  8976.       for(x = 0; x < width; x += 1) {
  8977.          uint8_t value = *(const uint8_t *)src;
  8978.          uint8_t r;
  8979.          r = value;
  8980.          dst[0] = (float)r; /* r */
  8981.          dst[1] = 0; /* g */
  8982.          dst[2] = 0; /* b */
  8983.          dst[3] = 1; /* a */
  8984.          src += 1;
  8985.          dst += 4;
  8986.       }
  8987.       src_row += src_stride;
  8988.       dst_row += dst_stride/sizeof(*dst_row);
  8989.    }
  8990. }
  8991.  
  8992. static INLINE void
  8993. util_format_r8_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  8994. {
  8995.    unsigned x, y;
  8996.    for(y = 0; y < height; y += 1) {
  8997.       const float *src = src_row;
  8998.       uint8_t *dst = dst_row;
  8999.       for(x = 0; x < width; x += 1) {
  9000.          uint8_t value = 0;
  9001.          value |= (uint8_t)CLAMP(src[0], 0, 255);
  9002.          *(uint8_t *)dst = value;
  9003.          src += 4;
  9004.          dst += 1;
  9005.       }
  9006.       dst_row += dst_stride;
  9007.       src_row += src_stride/sizeof(*src_row);
  9008.    }
  9009. }
  9010.  
  9011. static INLINE void
  9012. util_format_r8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9013. {
  9014.          uint8_t value = *(const uint8_t *)src;
  9015.          uint8_t r;
  9016.          r = value;
  9017.          dst[0] = (float)r; /* r */
  9018.          dst[1] = 0; /* g */
  9019.          dst[2] = 0; /* b */
  9020.          dst[3] = 1; /* a */
  9021. }
  9022.  
  9023. static INLINE void
  9024. util_format_r8_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9025. {
  9026.    unsigned x, y;
  9027.    for(y = 0; y < height; y += 1) {
  9028.       uint8_t *dst = dst_row;
  9029.       const uint8_t *src = src_row;
  9030.       for(x = 0; x < width; x += 1) {
  9031.          uint8_t value = *(const uint8_t *)src;
  9032.          uint8_t r;
  9033.          r = value;
  9034.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  9035.          dst[1] = 0; /* g */
  9036.          dst[2] = 0; /* b */
  9037.          dst[3] = 255; /* a */
  9038.          src += 1;
  9039.          dst += 4;
  9040.       }
  9041.       src_row += src_stride;
  9042.       dst_row += dst_stride/sizeof(*dst_row);
  9043.    }
  9044. }
  9045.  
  9046. static INLINE void
  9047. util_format_r8_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9048. {
  9049.    unsigned x, y;
  9050.    for(y = 0; y < height; y += 1) {
  9051.       const uint8_t *src = src_row;
  9052.       uint8_t *dst = dst_row;
  9053.       for(x = 0; x < width; x += 1) {
  9054.          uint8_t value = 0;
  9055.          value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  9056.          *(uint8_t *)dst = value;
  9057.          src += 4;
  9058.          dst += 1;
  9059.       }
  9060.       dst_row += dst_stride;
  9061.       src_row += src_stride/sizeof(*src_row);
  9062.    }
  9063. }
  9064.  
  9065. union util_format_r8g8_uscaled {
  9066.    uint16_t value;
  9067.    struct {
  9068.       uint8_t r;
  9069.       uint8_t g;
  9070.    } chan;
  9071. };
  9072.  
  9073. static INLINE void
  9074. util_format_r8g8_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9075. {
  9076.    unsigned x, y;
  9077.    for(y = 0; y < height; y += 1) {
  9078.       float *dst = dst_row;
  9079.       const uint8_t *src = src_row;
  9080.       for(x = 0; x < width; x += 1) {
  9081.          uint16_t value = *(const uint16_t *)src;
  9082.          uint16_t r;
  9083.          uint16_t g;
  9084.          r = (value) & 0xff;
  9085.          g = value >> 8;
  9086.          dst[0] = (float)r; /* r */
  9087.          dst[1] = (float)g; /* g */
  9088.          dst[2] = 0; /* b */
  9089.          dst[3] = 1; /* a */
  9090.          src += 2;
  9091.          dst += 4;
  9092.       }
  9093.       src_row += src_stride;
  9094.       dst_row += dst_stride/sizeof(*dst_row);
  9095.    }
  9096. }
  9097.  
  9098. static INLINE void
  9099. util_format_r8g8_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9100. {
  9101.    unsigned x, y;
  9102.    for(y = 0; y < height; y += 1) {
  9103.       const float *src = src_row;
  9104.       uint8_t *dst = dst_row;
  9105.       for(x = 0; x < width; x += 1) {
  9106.          uint16_t value = 0;
  9107.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  9108.          value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8;
  9109.          *(uint16_t *)dst = value;
  9110.          src += 4;
  9111.          dst += 2;
  9112.       }
  9113.       dst_row += dst_stride;
  9114.       src_row += src_stride/sizeof(*src_row);
  9115.    }
  9116. }
  9117.  
  9118. static INLINE void
  9119. util_format_r8g8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9120. {
  9121.          uint16_t value = *(const uint16_t *)src;
  9122.          uint16_t r;
  9123.          uint16_t g;
  9124.          r = (value) & 0xff;
  9125.          g = value >> 8;
  9126.          dst[0] = (float)r; /* r */
  9127.          dst[1] = (float)g; /* g */
  9128.          dst[2] = 0; /* b */
  9129.          dst[3] = 1; /* a */
  9130. }
  9131.  
  9132. static INLINE void
  9133. util_format_r8g8_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9134. {
  9135.    unsigned x, y;
  9136.    for(y = 0; y < height; y += 1) {
  9137.       uint8_t *dst = dst_row;
  9138.       const uint8_t *src = src_row;
  9139.       for(x = 0; x < width; x += 1) {
  9140.          uint16_t value = *(const uint16_t *)src;
  9141.          uint16_t r;
  9142.          uint16_t g;
  9143.          r = (value) & 0xff;
  9144.          g = value >> 8;
  9145.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  9146.          dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
  9147.          dst[2] = 0; /* b */
  9148.          dst[3] = 255; /* a */
  9149.          src += 2;
  9150.          dst += 4;
  9151.       }
  9152.       src_row += src_stride;
  9153.       dst_row += dst_stride/sizeof(*dst_row);
  9154.    }
  9155. }
  9156.  
  9157. static INLINE void
  9158. util_format_r8g8_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9159. {
  9160.    unsigned x, y;
  9161.    for(y = 0; y < height; y += 1) {
  9162.       const uint8_t *src = src_row;
  9163.       uint8_t *dst = dst_row;
  9164.       for(x = 0; x < width; x += 1) {
  9165.          uint16_t value = 0;
  9166.          value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff;
  9167.          value |= ((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8;
  9168.          *(uint16_t *)dst = value;
  9169.          src += 4;
  9170.          dst += 2;
  9171.       }
  9172.       dst_row += dst_stride;
  9173.       src_row += src_stride/sizeof(*src_row);
  9174.    }
  9175. }
  9176.  
  9177. union util_format_r8g8b8_uscaled {
  9178.    struct {
  9179.       uint8_t r;
  9180.       uint8_t g;
  9181.       uint8_t b;
  9182.    } chan;
  9183. };
  9184.  
  9185. static INLINE void
  9186. util_format_r8g8b8_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9187. {
  9188.    unsigned x, y;
  9189.    for(y = 0; y < height; y += 1) {
  9190.       float *dst = dst_row;
  9191.       const uint8_t *src = src_row;
  9192.       for(x = 0; x < width; x += 1) {
  9193.          union util_format_r8g8b8_uscaled pixel;
  9194.          memcpy(&pixel, src, sizeof pixel);
  9195.          dst[0] = (float)pixel.chan.r; /* r */
  9196.          dst[1] = (float)pixel.chan.g; /* g */
  9197.          dst[2] = (float)pixel.chan.b; /* b */
  9198.          dst[3] = 1; /* a */
  9199.          src += 3;
  9200.          dst += 4;
  9201.       }
  9202.       src_row += src_stride;
  9203.       dst_row += dst_stride/sizeof(*dst_row);
  9204.    }
  9205. }
  9206.  
  9207. static INLINE void
  9208. util_format_r8g8b8_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9209. {
  9210.    unsigned x, y;
  9211.    for(y = 0; y < height; y += 1) {
  9212.       const float *src = src_row;
  9213.       uint8_t *dst = dst_row;
  9214.       for(x = 0; x < width; x += 1) {
  9215.          union util_format_r8g8b8_uscaled pixel;
  9216.          pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255);
  9217.          pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255);
  9218.          pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255);
  9219.          memcpy(dst, &pixel, sizeof pixel);
  9220.          src += 4;
  9221.          dst += 3;
  9222.       }
  9223.       dst_row += dst_stride;
  9224.       src_row += src_stride/sizeof(*src_row);
  9225.    }
  9226. }
  9227.  
  9228. static INLINE void
  9229. util_format_r8g8b8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9230. {
  9231.          union util_format_r8g8b8_uscaled pixel;
  9232.          memcpy(&pixel, src, sizeof pixel);
  9233.          dst[0] = (float)pixel.chan.r; /* r */
  9234.          dst[1] = (float)pixel.chan.g; /* g */
  9235.          dst[2] = (float)pixel.chan.b; /* b */
  9236.          dst[3] = 1; /* a */
  9237. }
  9238.  
  9239. static INLINE void
  9240. util_format_r8g8b8_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9241. {
  9242.    unsigned x, y;
  9243.    for(y = 0; y < height; y += 1) {
  9244.       uint8_t *dst = dst_row;
  9245.       const uint8_t *src = src_row;
  9246.       for(x = 0; x < width; x += 1) {
  9247.          union util_format_r8g8b8_uscaled pixel;
  9248.          memcpy(&pixel, src, sizeof pixel);
  9249.          dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */
  9250.          dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */
  9251.          dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */
  9252.          dst[3] = 255; /* a */
  9253.          src += 3;
  9254.          dst += 4;
  9255.       }
  9256.       src_row += src_stride;
  9257.       dst_row += dst_stride/sizeof(*dst_row);
  9258.    }
  9259. }
  9260.  
  9261. static INLINE void
  9262. util_format_r8g8b8_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9263. {
  9264.    unsigned x, y;
  9265.    for(y = 0; y < height; y += 1) {
  9266.       const uint8_t *src = src_row;
  9267.       uint8_t *dst = dst_row;
  9268.       for(x = 0; x < width; x += 1) {
  9269.          union util_format_r8g8b8_uscaled pixel;
  9270.          pixel.chan.r = (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  9271.          pixel.chan.g = (uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  9272.          pixel.chan.b = (uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  9273.          memcpy(dst, &pixel, sizeof pixel);
  9274.          src += 4;
  9275.          dst += 3;
  9276.       }
  9277.       dst_row += dst_stride;
  9278.       src_row += src_stride/sizeof(*src_row);
  9279.    }
  9280. }
  9281.  
  9282. union util_format_r8g8b8a8_uscaled {
  9283.    uint32_t value;
  9284.    struct {
  9285.       uint8_t r;
  9286.       uint8_t g;
  9287.       uint8_t b;
  9288.       uint8_t a;
  9289.    } chan;
  9290. };
  9291.  
  9292. static INLINE void
  9293. util_format_r8g8b8a8_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9294. {
  9295.    unsigned x, y;
  9296.    for(y = 0; y < height; y += 1) {
  9297.       float *dst = dst_row;
  9298.       const uint8_t *src = src_row;
  9299.       for(x = 0; x < width; x += 1) {
  9300.          uint32_t value = *(const uint32_t *)src;
  9301.          uint32_t r;
  9302.          uint32_t g;
  9303.          uint32_t b;
  9304.          uint32_t a;
  9305.          r = (value) & 0xff;
  9306.          g = (value >> 8) & 0xff;
  9307.          b = (value >> 16) & 0xff;
  9308.          a = value >> 24;
  9309.          dst[0] = (float)r; /* r */
  9310.          dst[1] = (float)g; /* g */
  9311.          dst[2] = (float)b; /* b */
  9312.          dst[3] = (float)a; /* a */
  9313.          src += 4;
  9314.          dst += 4;
  9315.       }
  9316.       src_row += src_stride;
  9317.       dst_row += dst_stride/sizeof(*dst_row);
  9318.    }
  9319. }
  9320.  
  9321. static INLINE void
  9322. util_format_r8g8b8a8_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9323. {
  9324.    unsigned x, y;
  9325.    for(y = 0; y < height; y += 1) {
  9326.       const float *src = src_row;
  9327.       uint8_t *dst = dst_row;
  9328.       for(x = 0; x < width; x += 1) {
  9329.          uint32_t value = 0;
  9330.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  9331.          value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
  9332.          value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
  9333.          value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24;
  9334.          *(uint32_t *)dst = value;
  9335.          src += 4;
  9336.          dst += 4;
  9337.       }
  9338.       dst_row += dst_stride;
  9339.       src_row += src_stride/sizeof(*src_row);
  9340.    }
  9341. }
  9342.  
  9343. static INLINE void
  9344. util_format_r8g8b8a8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9345. {
  9346.          uint32_t value = *(const uint32_t *)src;
  9347.          uint32_t r;
  9348.          uint32_t g;
  9349.          uint32_t b;
  9350.          uint32_t a;
  9351.          r = (value) & 0xff;
  9352.          g = (value >> 8) & 0xff;
  9353.          b = (value >> 16) & 0xff;
  9354.          a = value >> 24;
  9355.          dst[0] = (float)r; /* r */
  9356.          dst[1] = (float)g; /* g */
  9357.          dst[2] = (float)b; /* b */
  9358.          dst[3] = (float)a; /* a */
  9359. }
  9360.  
  9361. static INLINE void
  9362. util_format_r8g8b8a8_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9363. {
  9364.    unsigned x, y;
  9365.    for(y = 0; y < height; y += 1) {
  9366.       uint8_t *dst = dst_row;
  9367.       const uint8_t *src = src_row;
  9368.       for(x = 0; x < width; x += 1) {
  9369.          uint32_t value = *(const uint32_t *)src;
  9370.          uint32_t r;
  9371.          uint32_t g;
  9372.          uint32_t b;
  9373.          uint32_t a;
  9374.          r = (value) & 0xff;
  9375.          g = (value >> 8) & 0xff;
  9376.          b = (value >> 16) & 0xff;
  9377.          a = value >> 24;
  9378.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  9379.          dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
  9380.          dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */
  9381.          dst[3] = (uint8_t)(((uint32_t)MIN2(a, 1)) * 0xff / 0x1); /* a */
  9382.          src += 4;
  9383.          dst += 4;
  9384.       }
  9385.       src_row += src_stride;
  9386.       dst_row += dst_stride/sizeof(*dst_row);
  9387.    }
  9388. }
  9389.  
  9390. static INLINE void
  9391. util_format_r8g8b8a8_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9392. {
  9393.    unsigned x, y;
  9394.    for(y = 0; y < height; y += 1) {
  9395.       const uint8_t *src = src_row;
  9396.       uint8_t *dst = dst_row;
  9397.       for(x = 0; x < width; x += 1) {
  9398.          uint32_t value = 0;
  9399.          value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff;
  9400.          value |= (((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8;
  9401.          value |= (((uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16;
  9402.          value |= ((uint8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24;
  9403.          *(uint32_t *)dst = value;
  9404.          src += 4;
  9405.          dst += 4;
  9406.       }
  9407.       dst_row += dst_stride;
  9408.       src_row += src_stride/sizeof(*src_row);
  9409.    }
  9410. }
  9411.  
  9412. union util_format_r8_snorm {
  9413.    uint8_t value;
  9414.    struct {
  9415.       int8_t r;
  9416.    } chan;
  9417. };
  9418.  
  9419. static INLINE void
  9420. util_format_r8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9421. {
  9422.    unsigned x, y;
  9423.    for(y = 0; y < height; y += 1) {
  9424.       float *dst = dst_row;
  9425.       const uint8_t *src = src_row;
  9426.       for(x = 0; x < width; x += 1) {
  9427.          uint8_t value = *(const uint8_t *)src;
  9428.          int8_t r;
  9429.          r = (int8_t)(value) ;
  9430.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9431.          dst[1] = 0; /* g */
  9432.          dst[2] = 0; /* b */
  9433.          dst[3] = 1; /* a */
  9434.          src += 1;
  9435.          dst += 4;
  9436.       }
  9437.       src_row += src_stride;
  9438.       dst_row += dst_stride/sizeof(*dst_row);
  9439.    }
  9440. }
  9441.  
  9442. static INLINE void
  9443. util_format_r8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9444. {
  9445.    unsigned x, y;
  9446.    for(y = 0; y < height; y += 1) {
  9447.       const float *src = src_row;
  9448.       uint8_t *dst = dst_row;
  9449.       for(x = 0; x < width; x += 1) {
  9450.          uint8_t value = 0;
  9451.          value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ;
  9452.          *(uint8_t *)dst = value;
  9453.          src += 4;
  9454.          dst += 1;
  9455.       }
  9456.       dst_row += dst_stride;
  9457.       src_row += src_stride/sizeof(*src_row);
  9458.    }
  9459. }
  9460.  
  9461. static INLINE void
  9462. util_format_r8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9463. {
  9464.          uint8_t value = *(const uint8_t *)src;
  9465.          int8_t r;
  9466.          r = (int8_t)(value) ;
  9467.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9468.          dst[1] = 0; /* g */
  9469.          dst[2] = 0; /* b */
  9470.          dst[3] = 1; /* a */
  9471. }
  9472.  
  9473. static INLINE void
  9474. util_format_r8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9475. {
  9476.    unsigned x, y;
  9477.    for(y = 0; y < height; y += 1) {
  9478.       uint8_t *dst = dst_row;
  9479.       const uint8_t *src = src_row;
  9480.       for(x = 0; x < width; x += 1) {
  9481.          uint8_t value = *(const uint8_t *)src;
  9482.          int8_t r;
  9483.          r = (int8_t)(value) ;
  9484.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  9485.          dst[1] = 0; /* g */
  9486.          dst[2] = 0; /* b */
  9487.          dst[3] = 255; /* a */
  9488.          src += 1;
  9489.          dst += 4;
  9490.       }
  9491.       src_row += src_stride;
  9492.       dst_row += dst_stride/sizeof(*dst_row);
  9493.    }
  9494. }
  9495.  
  9496. static INLINE void
  9497. util_format_r8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9498. {
  9499.    unsigned x, y;
  9500.    for(y = 0; y < height; y += 1) {
  9501.       const uint8_t *src = src_row;
  9502.       uint8_t *dst = dst_row;
  9503.       for(x = 0; x < width; x += 1) {
  9504.          uint8_t value = 0;
  9505.          value |= (uint8_t)((int8_t)(src[0] >> 1)) ;
  9506.          *(uint8_t *)dst = value;
  9507.          src += 4;
  9508.          dst += 1;
  9509.       }
  9510.       dst_row += dst_stride;
  9511.       src_row += src_stride/sizeof(*src_row);
  9512.    }
  9513. }
  9514.  
  9515. union util_format_r8g8_snorm {
  9516.    uint16_t value;
  9517.    struct {
  9518.       int8_t r;
  9519.       int8_t g;
  9520.    } chan;
  9521. };
  9522.  
  9523. static INLINE void
  9524. util_format_r8g8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9525. {
  9526.    unsigned x, y;
  9527.    for(y = 0; y < height; y += 1) {
  9528.       float *dst = dst_row;
  9529.       const uint8_t *src = src_row;
  9530.       for(x = 0; x < width; x += 1) {
  9531.          uint16_t value = *(const uint16_t *)src;
  9532.          int16_t r;
  9533.          int16_t g;
  9534.          r = ((int16_t)(value << 8) ) >> 8;
  9535.          g = ((int16_t)(value) ) >> 8;
  9536.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9537.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  9538.          dst[2] = 0; /* b */
  9539.          dst[3] = 1; /* a */
  9540.          src += 2;
  9541.          dst += 4;
  9542.       }
  9543.       src_row += src_stride;
  9544.       dst_row += dst_stride/sizeof(*dst_row);
  9545.    }
  9546. }
  9547.  
  9548. static INLINE void
  9549. util_format_r8g8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9550. {
  9551.    unsigned x, y;
  9552.    for(y = 0; y < height; y += 1) {
  9553.       const float *src = src_row;
  9554.       uint8_t *dst = dst_row;
  9555.       for(x = 0; x < width; x += 1) {
  9556.          uint16_t value = 0;
  9557.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  9558.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) << 8) ;
  9559.          *(uint16_t *)dst = value;
  9560.          src += 4;
  9561.          dst += 2;
  9562.       }
  9563.       dst_row += dst_stride;
  9564.       src_row += src_stride/sizeof(*src_row);
  9565.    }
  9566. }
  9567.  
  9568. static INLINE void
  9569. util_format_r8g8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9570. {
  9571.          uint16_t value = *(const uint16_t *)src;
  9572.          int16_t r;
  9573.          int16_t g;
  9574.          r = ((int16_t)(value << 8) ) >> 8;
  9575.          g = ((int16_t)(value) ) >> 8;
  9576.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9577.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  9578.          dst[2] = 0; /* b */
  9579.          dst[3] = 1; /* a */
  9580. }
  9581.  
  9582. static INLINE void
  9583. util_format_r8g8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9584. {
  9585.    unsigned x, y;
  9586.    for(y = 0; y < height; y += 1) {
  9587.       uint8_t *dst = dst_row;
  9588.       const uint8_t *src = src_row;
  9589.       for(x = 0; x < width; x += 1) {
  9590.          uint16_t value = *(const uint16_t *)src;
  9591.          int16_t r;
  9592.          int16_t g;
  9593.          r = ((int16_t)(value << 8) ) >> 8;
  9594.          g = ((int16_t)(value) ) >> 8;
  9595.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  9596.          dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
  9597.          dst[2] = 0; /* b */
  9598.          dst[3] = 255; /* a */
  9599.          src += 2;
  9600.          dst += 4;
  9601.       }
  9602.       src_row += src_stride;
  9603.       dst_row += dst_stride/sizeof(*dst_row);
  9604.    }
  9605. }
  9606.  
  9607. static INLINE void
  9608. util_format_r8g8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9609. {
  9610.    unsigned x, y;
  9611.    for(y = 0; y < height; y += 1) {
  9612.       const uint8_t *src = src_row;
  9613.       uint8_t *dst = dst_row;
  9614.       for(x = 0; x < width; x += 1) {
  9615.          uint16_t value = 0;
  9616.          value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
  9617.          value |= (uint16_t)(((int8_t)(src[1] >> 1)) << 8) ;
  9618.          *(uint16_t *)dst = value;
  9619.          src += 4;
  9620.          dst += 2;
  9621.       }
  9622.       dst_row += dst_stride;
  9623.       src_row += src_stride/sizeof(*src_row);
  9624.    }
  9625. }
  9626.  
  9627. union util_format_r8g8b8_snorm {
  9628.    struct {
  9629.       int8_t r;
  9630.       int8_t g;
  9631.       int8_t b;
  9632.    } chan;
  9633. };
  9634.  
  9635. static INLINE void
  9636. util_format_r8g8b8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9637. {
  9638.    unsigned x, y;
  9639.    for(y = 0; y < height; y += 1) {
  9640.       float *dst = dst_row;
  9641.       const uint8_t *src = src_row;
  9642.       for(x = 0; x < width; x += 1) {
  9643.          union util_format_r8g8b8_snorm pixel;
  9644.          memcpy(&pixel, src, sizeof pixel);
  9645.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */
  9646.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */
  9647.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */
  9648.          dst[3] = 1; /* a */
  9649.          src += 3;
  9650.          dst += 4;
  9651.       }
  9652.       src_row += src_stride;
  9653.       dst_row += dst_stride/sizeof(*dst_row);
  9654.    }
  9655. }
  9656.  
  9657. static INLINE void
  9658. util_format_r8g8b8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9659. {
  9660.    unsigned x, y;
  9661.    for(y = 0; y < height; y += 1) {
  9662.       const float *src = src_row;
  9663.       uint8_t *dst = dst_row;
  9664.       for(x = 0; x < width; x += 1) {
  9665.          union util_format_r8g8b8_snorm pixel;
  9666.          pixel.chan.r = (int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f);
  9667.          pixel.chan.g = (int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f);
  9668.          pixel.chan.b = (int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f);
  9669.          memcpy(dst, &pixel, sizeof pixel);
  9670.          src += 4;
  9671.          dst += 3;
  9672.       }
  9673.       dst_row += dst_stride;
  9674.       src_row += src_stride/sizeof(*src_row);
  9675.    }
  9676. }
  9677.  
  9678. static INLINE void
  9679. util_format_r8g8b8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9680. {
  9681.          union util_format_r8g8b8_snorm pixel;
  9682.          memcpy(&pixel, src, sizeof pixel);
  9683.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */
  9684.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */
  9685.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */
  9686.          dst[3] = 1; /* a */
  9687. }
  9688.  
  9689. static INLINE void
  9690. util_format_r8g8b8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9691. {
  9692.    unsigned x, y;
  9693.    for(y = 0; y < height; y += 1) {
  9694.       uint8_t *dst = dst_row;
  9695.       const uint8_t *src = src_row;
  9696.       for(x = 0; x < width; x += 1) {
  9697.          union util_format_r8g8b8_snorm pixel;
  9698.          memcpy(&pixel, src, sizeof pixel);
  9699.          dst[0] = (uint8_t)(((uint32_t)MAX2(pixel.chan.r, 0)) * 0xff / 0x7f); /* r */
  9700.          dst[1] = (uint8_t)(((uint32_t)MAX2(pixel.chan.g, 0)) * 0xff / 0x7f); /* g */
  9701.          dst[2] = (uint8_t)(((uint32_t)MAX2(pixel.chan.b, 0)) * 0xff / 0x7f); /* b */
  9702.          dst[3] = 255; /* a */
  9703.          src += 3;
  9704.          dst += 4;
  9705.       }
  9706.       src_row += src_stride;
  9707.       dst_row += dst_stride/sizeof(*dst_row);
  9708.    }
  9709. }
  9710.  
  9711. static INLINE void
  9712. util_format_r8g8b8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9713. {
  9714.    unsigned x, y;
  9715.    for(y = 0; y < height; y += 1) {
  9716.       const uint8_t *src = src_row;
  9717.       uint8_t *dst = dst_row;
  9718.       for(x = 0; x < width; x += 1) {
  9719.          union util_format_r8g8b8_snorm pixel;
  9720.          pixel.chan.r = (int8_t)(src[0] >> 1);
  9721.          pixel.chan.g = (int8_t)(src[1] >> 1);
  9722.          pixel.chan.b = (int8_t)(src[2] >> 1);
  9723.          memcpy(dst, &pixel, sizeof pixel);
  9724.          src += 4;
  9725.          dst += 3;
  9726.       }
  9727.       dst_row += dst_stride;
  9728.       src_row += src_stride/sizeof(*src_row);
  9729.    }
  9730. }
  9731.  
  9732. union util_format_r8g8b8a8_snorm {
  9733.    uint32_t value;
  9734.    struct {
  9735.       int8_t r;
  9736.       int8_t g;
  9737.       int8_t b;
  9738.       int8_t a;
  9739.    } chan;
  9740. };
  9741.  
  9742. static INLINE void
  9743. util_format_r8g8b8a8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9744. {
  9745.    unsigned x, y;
  9746.    for(y = 0; y < height; y += 1) {
  9747.       float *dst = dst_row;
  9748.       const uint8_t *src = src_row;
  9749.       for(x = 0; x < width; x += 1) {
  9750.          uint32_t value = *(const uint32_t *)src;
  9751.          int32_t r;
  9752.          int32_t g;
  9753.          int32_t b;
  9754.          int32_t a;
  9755.          r = ((int32_t)(value << 24) ) >> 24;
  9756.          g = ((int32_t)(value << 16) ) >> 24;
  9757.          b = ((int32_t)(value << 8) ) >> 24;
  9758.          a = ((int32_t)(value) ) >> 24;
  9759.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9760.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  9761.          dst[2] = (float)(b * (1.0f/0x7f)); /* b */
  9762.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  9763.          src += 4;
  9764.          dst += 4;
  9765.       }
  9766.       src_row += src_stride;
  9767.       dst_row += dst_stride/sizeof(*dst_row);
  9768.    }
  9769. }
  9770.  
  9771. static INLINE void
  9772. util_format_r8g8b8a8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9773. {
  9774.    unsigned x, y;
  9775.    for(y = 0; y < height; y += 1) {
  9776.       const float *src = src_row;
  9777.       uint8_t *dst = dst_row;
  9778.       for(x = 0; x < width; x += 1) {
  9779.          uint32_t value = 0;
  9780.          value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  9781.          value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
  9782.          value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ;
  9783.          value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 24) ;
  9784.          *(uint32_t *)dst = value;
  9785.          src += 4;
  9786.          dst += 4;
  9787.       }
  9788.       dst_row += dst_stride;
  9789.       src_row += src_stride/sizeof(*src_row);
  9790.    }
  9791. }
  9792.  
  9793. static INLINE void
  9794. util_format_r8g8b8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9795. {
  9796.          uint32_t value = *(const uint32_t *)src;
  9797.          int32_t r;
  9798.          int32_t g;
  9799.          int32_t b;
  9800.          int32_t a;
  9801.          r = ((int32_t)(value << 24) ) >> 24;
  9802.          g = ((int32_t)(value << 16) ) >> 24;
  9803.          b = ((int32_t)(value << 8) ) >> 24;
  9804.          a = ((int32_t)(value) ) >> 24;
  9805.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  9806.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  9807.          dst[2] = (float)(b * (1.0f/0x7f)); /* b */
  9808.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  9809. }
  9810.  
  9811. static INLINE void
  9812. util_format_r8g8b8a8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9813. {
  9814.    unsigned x, y;
  9815.    for(y = 0; y < height; y += 1) {
  9816.       uint8_t *dst = dst_row;
  9817.       const uint8_t *src = src_row;
  9818.       for(x = 0; x < width; x += 1) {
  9819.          uint32_t value = *(const uint32_t *)src;
  9820.          int32_t r;
  9821.          int32_t g;
  9822.          int32_t b;
  9823.          int32_t a;
  9824.          r = ((int32_t)(value << 24) ) >> 24;
  9825.          g = ((int32_t)(value << 16) ) >> 24;
  9826.          b = ((int32_t)(value << 8) ) >> 24;
  9827.          a = ((int32_t)(value) ) >> 24;
  9828.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  9829.          dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
  9830.          dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */
  9831.          dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
  9832.          src += 4;
  9833.          dst += 4;
  9834.       }
  9835.       src_row += src_stride;
  9836.       dst_row += dst_stride/sizeof(*dst_row);
  9837.    }
  9838. }
  9839.  
  9840. static INLINE void
  9841. util_format_r8g8b8a8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9842. {
  9843.    unsigned x, y;
  9844.    for(y = 0; y < height; y += 1) {
  9845.       const uint8_t *src = src_row;
  9846.       uint8_t *dst = dst_row;
  9847.       for(x = 0; x < width; x += 1) {
  9848.          uint32_t value = 0;
  9849.          value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
  9850.          value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ;
  9851.          value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ;
  9852.          value |= (uint32_t)(((int8_t)(src[3] >> 1)) << 24) ;
  9853.          *(uint32_t *)dst = value;
  9854.          src += 4;
  9855.          dst += 4;
  9856.       }
  9857.       dst_row += dst_stride;
  9858.       src_row += src_stride/sizeof(*src_row);
  9859.    }
  9860. }
  9861.  
  9862. union util_format_r8_sscaled {
  9863.    uint8_t value;
  9864.    struct {
  9865.       int8_t r;
  9866.    } chan;
  9867. };
  9868.  
  9869. static INLINE void
  9870. util_format_r8_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9871. {
  9872.    unsigned x, y;
  9873.    for(y = 0; y < height; y += 1) {
  9874.       float *dst = dst_row;
  9875.       const uint8_t *src = src_row;
  9876.       for(x = 0; x < width; x += 1) {
  9877.          uint8_t value = *(const uint8_t *)src;
  9878.          int8_t r;
  9879.          r = (int8_t)(value) ;
  9880.          dst[0] = (float)r; /* r */
  9881.          dst[1] = 0; /* g */
  9882.          dst[2] = 0; /* b */
  9883.          dst[3] = 1; /* a */
  9884.          src += 1;
  9885.          dst += 4;
  9886.       }
  9887.       src_row += src_stride;
  9888.       dst_row += dst_stride/sizeof(*dst_row);
  9889.    }
  9890. }
  9891.  
  9892. static INLINE void
  9893. util_format_r8_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  9894. {
  9895.    unsigned x, y;
  9896.    for(y = 0; y < height; y += 1) {
  9897.       const float *src = src_row;
  9898.       uint8_t *dst = dst_row;
  9899.       for(x = 0; x < width; x += 1) {
  9900.          uint8_t value = 0;
  9901.          value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
  9902.          *(uint8_t *)dst = value;
  9903.          src += 4;
  9904.          dst += 1;
  9905.       }
  9906.       dst_row += dst_stride;
  9907.       src_row += src_stride/sizeof(*src_row);
  9908.    }
  9909. }
  9910.  
  9911. static INLINE void
  9912. util_format_r8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  9913. {
  9914.          uint8_t value = *(const uint8_t *)src;
  9915.          int8_t r;
  9916.          r = (int8_t)(value) ;
  9917.          dst[0] = (float)r; /* r */
  9918.          dst[1] = 0; /* g */
  9919.          dst[2] = 0; /* b */
  9920.          dst[3] = 1; /* a */
  9921. }
  9922.  
  9923. static INLINE void
  9924. util_format_r8_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9925. {
  9926.    unsigned x, y;
  9927.    for(y = 0; y < height; y += 1) {
  9928.       uint8_t *dst = dst_row;
  9929.       const uint8_t *src = src_row;
  9930.       for(x = 0; x < width; x += 1) {
  9931.          uint8_t value = *(const uint8_t *)src;
  9932.          int8_t r;
  9933.          r = (int8_t)(value) ;
  9934.          dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  9935.          dst[1] = 0; /* g */
  9936.          dst[2] = 0; /* b */
  9937.          dst[3] = 255; /* a */
  9938.          src += 1;
  9939.          dst += 4;
  9940.       }
  9941.       src_row += src_stride;
  9942.       dst_row += dst_stride/sizeof(*dst_row);
  9943.    }
  9944. }
  9945.  
  9946. static INLINE void
  9947. util_format_r8_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9948. {
  9949.    unsigned x, y;
  9950.    for(y = 0; y < height; y += 1) {
  9951.       const uint8_t *src = src_row;
  9952.       uint8_t *dst = dst_row;
  9953.       for(x = 0; x < width; x += 1) {
  9954.          uint8_t value = 0;
  9955.          value |= (uint8_t)((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ;
  9956.          *(uint8_t *)dst = value;
  9957.          src += 4;
  9958.          dst += 1;
  9959.       }
  9960.       dst_row += dst_stride;
  9961.       src_row += src_stride/sizeof(*src_row);
  9962.    }
  9963. }
  9964.  
  9965. union util_format_r8g8_sscaled {
  9966.    uint16_t value;
  9967.    struct {
  9968.       int8_t r;
  9969.       int8_t g;
  9970.    } chan;
  9971. };
  9972.  
  9973. static INLINE void
  9974. util_format_r8g8_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  9975. {
  9976.    unsigned x, y;
  9977.    for(y = 0; y < height; y += 1) {
  9978.       float *dst = dst_row;
  9979.       const uint8_t *src = src_row;
  9980.       for(x = 0; x < width; x += 1) {
  9981.          uint16_t value = *(const uint16_t *)src;
  9982.          int16_t r;
  9983.          int16_t g;
  9984.          r = ((int16_t)(value << 8) ) >> 8;
  9985.          g = ((int16_t)(value) ) >> 8;
  9986.          dst[0] = (float)r; /* r */
  9987.          dst[1] = (float)g; /* g */
  9988.          dst[2] = 0; /* b */
  9989.          dst[3] = 1; /* a */
  9990.          src += 2;
  9991.          dst += 4;
  9992.       }
  9993.       src_row += src_stride;
  9994.       dst_row += dst_stride/sizeof(*dst_row);
  9995.    }
  9996. }
  9997.  
  9998. static INLINE void
  9999. util_format_r8g8_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10000. {
  10001.    unsigned x, y;
  10002.    for(y = 0; y < height; y += 1) {
  10003.       const float *src = src_row;
  10004.       uint8_t *dst = dst_row;
  10005.       for(x = 0; x < width; x += 1) {
  10006.          uint16_t value = 0;
  10007.          value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  10008.          value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ;
  10009.          *(uint16_t *)dst = value;
  10010.          src += 4;
  10011.          dst += 2;
  10012.       }
  10013.       dst_row += dst_stride;
  10014.       src_row += src_stride/sizeof(*src_row);
  10015.    }
  10016. }
  10017.  
  10018. static INLINE void
  10019. util_format_r8g8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10020. {
  10021.          uint16_t value = *(const uint16_t *)src;
  10022.          int16_t r;
  10023.          int16_t g;
  10024.          r = ((int16_t)(value << 8) ) >> 8;
  10025.          g = ((int16_t)(value) ) >> 8;
  10026.          dst[0] = (float)r; /* r */
  10027.          dst[1] = (float)g; /* g */
  10028.          dst[2] = 0; /* b */
  10029.          dst[3] = 1; /* a */
  10030. }
  10031.  
  10032. static INLINE void
  10033. util_format_r8g8_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10034. {
  10035.    unsigned x, y;
  10036.    for(y = 0; y < height; y += 1) {
  10037.       uint8_t *dst = dst_row;
  10038.       const uint8_t *src = src_row;
  10039.       for(x = 0; x < width; x += 1) {
  10040.          uint16_t value = *(const uint16_t *)src;
  10041.          int16_t r;
  10042.          int16_t g;
  10043.          r = ((int16_t)(value << 8) ) >> 8;
  10044.          g = ((int16_t)(value) ) >> 8;
  10045.          dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  10046.          dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
  10047.          dst[2] = 0; /* b */
  10048.          dst[3] = 255; /* a */
  10049.          src += 2;
  10050.          dst += 4;
  10051.       }
  10052.       src_row += src_stride;
  10053.       dst_row += dst_stride/sizeof(*dst_row);
  10054.    }
  10055. }
  10056.  
  10057. static INLINE void
  10058. util_format_r8g8_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10059. {
  10060.    unsigned x, y;
  10061.    for(y = 0; y < height; y += 1) {
  10062.       const uint8_t *src = src_row;
  10063.       uint8_t *dst = dst_row;
  10064.       for(x = 0; x < width; x += 1) {
  10065.          uint16_t value = 0;
  10066.          value |= (uint16_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ;
  10067.          value |= (uint16_t)(((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8) ;
  10068.          *(uint16_t *)dst = value;
  10069.          src += 4;
  10070.          dst += 2;
  10071.       }
  10072.       dst_row += dst_stride;
  10073.       src_row += src_stride/sizeof(*src_row);
  10074.    }
  10075. }
  10076.  
  10077. union util_format_r8g8b8_sscaled {
  10078.    struct {
  10079.       int8_t r;
  10080.       int8_t g;
  10081.       int8_t b;
  10082.    } chan;
  10083. };
  10084.  
  10085. static INLINE void
  10086. util_format_r8g8b8_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10087. {
  10088.    unsigned x, y;
  10089.    for(y = 0; y < height; y += 1) {
  10090.       float *dst = dst_row;
  10091.       const uint8_t *src = src_row;
  10092.       for(x = 0; x < width; x += 1) {
  10093.          union util_format_r8g8b8_sscaled pixel;
  10094.          memcpy(&pixel, src, sizeof pixel);
  10095.          dst[0] = (float)pixel.chan.r; /* r */
  10096.          dst[1] = (float)pixel.chan.g; /* g */
  10097.          dst[2] = (float)pixel.chan.b; /* b */
  10098.          dst[3] = 1; /* a */
  10099.          src += 3;
  10100.          dst += 4;
  10101.       }
  10102.       src_row += src_stride;
  10103.       dst_row += dst_stride/sizeof(*dst_row);
  10104.    }
  10105. }
  10106.  
  10107. static INLINE void
  10108. util_format_r8g8b8_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10109. {
  10110.    unsigned x, y;
  10111.    for(y = 0; y < height; y += 1) {
  10112.       const float *src = src_row;
  10113.       uint8_t *dst = dst_row;
  10114.       for(x = 0; x < width; x += 1) {
  10115.          union util_format_r8g8b8_sscaled pixel;
  10116.          pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127);
  10117.          pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127);
  10118.          pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127);
  10119.          memcpy(dst, &pixel, sizeof pixel);
  10120.          src += 4;
  10121.          dst += 3;
  10122.       }
  10123.       dst_row += dst_stride;
  10124.       src_row += src_stride/sizeof(*src_row);
  10125.    }
  10126. }
  10127.  
  10128. static INLINE void
  10129. util_format_r8g8b8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10130. {
  10131.          union util_format_r8g8b8_sscaled pixel;
  10132.          memcpy(&pixel, src, sizeof pixel);
  10133.          dst[0] = (float)pixel.chan.r; /* r */
  10134.          dst[1] = (float)pixel.chan.g; /* g */
  10135.          dst[2] = (float)pixel.chan.b; /* b */
  10136.          dst[3] = 1; /* a */
  10137. }
  10138.  
  10139. static INLINE void
  10140. util_format_r8g8b8_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10141. {
  10142.    unsigned x, y;
  10143.    for(y = 0; y < height; y += 1) {
  10144.       uint8_t *dst = dst_row;
  10145.       const uint8_t *src = src_row;
  10146.       for(x = 0; x < width; x += 1) {
  10147.          union util_format_r8g8b8_sscaled pixel;
  10148.          memcpy(&pixel, src, sizeof pixel);
  10149.          dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */
  10150.          dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */
  10151.          dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */
  10152.          dst[3] = 255; /* a */
  10153.          src += 3;
  10154.          dst += 4;
  10155.       }
  10156.       src_row += src_stride;
  10157.       dst_row += dst_stride/sizeof(*dst_row);
  10158.    }
  10159. }
  10160.  
  10161. static INLINE void
  10162. util_format_r8g8b8_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10163. {
  10164.    unsigned x, y;
  10165.    for(y = 0; y < height; y += 1) {
  10166.       const uint8_t *src = src_row;
  10167.       uint8_t *dst = dst_row;
  10168.       for(x = 0; x < width; x += 1) {
  10169.          union util_format_r8g8b8_sscaled pixel;
  10170.          pixel.chan.r = (int8_t)(((uint32_t)src[0]) * 0x1 / 0xff);
  10171.          pixel.chan.g = (int8_t)(((uint32_t)src[1]) * 0x1 / 0xff);
  10172.          pixel.chan.b = (int8_t)(((uint32_t)src[2]) * 0x1 / 0xff);
  10173.          memcpy(dst, &pixel, sizeof pixel);
  10174.          src += 4;
  10175.          dst += 3;
  10176.       }
  10177.       dst_row += dst_stride;
  10178.       src_row += src_stride/sizeof(*src_row);
  10179.    }
  10180. }
  10181.  
  10182. union util_format_r8g8b8a8_sscaled {
  10183.    uint32_t value;
  10184.    struct {
  10185.       int8_t r;
  10186.       int8_t g;
  10187.       int8_t b;
  10188.       int8_t a;
  10189.    } chan;
  10190. };
  10191.  
  10192. static INLINE void
  10193. util_format_r8g8b8a8_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10194. {
  10195.    unsigned x, y;
  10196.    for(y = 0; y < height; y += 1) {
  10197.       float *dst = dst_row;
  10198.       const uint8_t *src = src_row;
  10199.       for(x = 0; x < width; x += 1) {
  10200.          uint32_t value = *(const uint32_t *)src;
  10201.          int32_t r;
  10202.          int32_t g;
  10203.          int32_t b;
  10204.          int32_t a;
  10205.          r = ((int32_t)(value << 24) ) >> 24;
  10206.          g = ((int32_t)(value << 16) ) >> 24;
  10207.          b = ((int32_t)(value << 8) ) >> 24;
  10208.          a = ((int32_t)(value) ) >> 24;
  10209.          dst[0] = (float)r; /* r */
  10210.          dst[1] = (float)g; /* g */
  10211.          dst[2] = (float)b; /* b */
  10212.          dst[3] = (float)a; /* a */
  10213.          src += 4;
  10214.          dst += 4;
  10215.       }
  10216.       src_row += src_stride;
  10217.       dst_row += dst_stride/sizeof(*dst_row);
  10218.    }
  10219. }
  10220.  
  10221. static INLINE void
  10222. util_format_r8g8b8a8_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10223. {
  10224.    unsigned x, y;
  10225.    for(y = 0; y < height; y += 1) {
  10226.       const float *src = src_row;
  10227.       uint8_t *dst = dst_row;
  10228.       for(x = 0; x < width; x += 1) {
  10229.          uint32_t value = 0;
  10230.          value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  10231.          value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
  10232.          value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
  10233.          value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ;
  10234.          *(uint32_t *)dst = value;
  10235.          src += 4;
  10236.          dst += 4;
  10237.       }
  10238.       dst_row += dst_stride;
  10239.       src_row += src_stride/sizeof(*src_row);
  10240.    }
  10241. }
  10242.  
  10243. static INLINE void
  10244. util_format_r8g8b8a8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10245. {
  10246.          uint32_t value = *(const uint32_t *)src;
  10247.          int32_t r;
  10248.          int32_t g;
  10249.          int32_t b;
  10250.          int32_t a;
  10251.          r = ((int32_t)(value << 24) ) >> 24;
  10252.          g = ((int32_t)(value << 16) ) >> 24;
  10253.          b = ((int32_t)(value << 8) ) >> 24;
  10254.          a = ((int32_t)(value) ) >> 24;
  10255.          dst[0] = (float)r; /* r */
  10256.          dst[1] = (float)g; /* g */
  10257.          dst[2] = (float)b; /* b */
  10258.          dst[3] = (float)a; /* a */
  10259. }
  10260.  
  10261. static INLINE void
  10262. util_format_r8g8b8a8_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10263. {
  10264.    unsigned x, y;
  10265.    for(y = 0; y < height; y += 1) {
  10266.       uint8_t *dst = dst_row;
  10267.       const uint8_t *src = src_row;
  10268.       for(x = 0; x < width; x += 1) {
  10269.          uint32_t value = *(const uint32_t *)src;
  10270.          int32_t r;
  10271.          int32_t g;
  10272.          int32_t b;
  10273.          int32_t a;
  10274.          r = ((int32_t)(value << 24) ) >> 24;
  10275.          g = ((int32_t)(value << 16) ) >> 24;
  10276.          b = ((int32_t)(value << 8) ) >> 24;
  10277.          a = ((int32_t)(value) ) >> 24;
  10278.          dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */
  10279.          dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */
  10280.          dst[2] = (uint8_t)(((uint32_t)CLAMP(b, 0, 1)) * 0xff / 0x1); /* b */
  10281.          dst[3] = (uint8_t)(((uint32_t)CLAMP(a, 0, 1)) * 0xff / 0x1); /* a */
  10282.          src += 4;
  10283.          dst += 4;
  10284.       }
  10285.       src_row += src_stride;
  10286.       dst_row += dst_stride/sizeof(*dst_row);
  10287.    }
  10288. }
  10289.  
  10290. static INLINE void
  10291. util_format_r8g8b8a8_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10292. {
  10293.    unsigned x, y;
  10294.    for(y = 0; y < height; y += 1) {
  10295.       const uint8_t *src = src_row;
  10296.       uint8_t *dst = dst_row;
  10297.       for(x = 0; x < width; x += 1) {
  10298.          uint32_t value = 0;
  10299.          value |= (uint32_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ;
  10300.          value |= (uint32_t)((((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8) ;
  10301.          value |= (uint32_t)((((int8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16) ;
  10302.          value |= (uint32_t)(((int8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24) ;
  10303.          *(uint32_t *)dst = value;
  10304.          src += 4;
  10305.          dst += 4;
  10306.       }
  10307.       dst_row += dst_stride;
  10308.       src_row += src_stride/sizeof(*src_row);
  10309.    }
  10310. }
  10311.  
  10312. union util_format_r32_fixed {
  10313.    uint32_t value;
  10314.    struct {
  10315.       int32_t r;
  10316.    } chan;
  10317. };
  10318.  
  10319. static INLINE void
  10320. util_format_r32_fixed_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10321. {
  10322.    unsigned x, y;
  10323.    for(y = 0; y < height; y += 1) {
  10324.       float *dst = dst_row;
  10325.       const uint8_t *src = src_row;
  10326.       for(x = 0; x < width; x += 1) {
  10327.          union util_format_r32_fixed pixel;
  10328.          memcpy(&pixel, src, sizeof pixel);
  10329.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10330.          dst[1] = 0; /* g */
  10331.          dst[2] = 0; /* b */
  10332.          dst[3] = 1; /* a */
  10333.          src += 4;
  10334.          dst += 4;
  10335.       }
  10336.       src_row += src_stride;
  10337.       dst_row += dst_stride/sizeof(*dst_row);
  10338.    }
  10339. }
  10340.  
  10341. static INLINE void
  10342. util_format_r32_fixed_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10343. {
  10344.    unsigned x, y;
  10345.    for(y = 0; y < height; y += 1) {
  10346.       const float *src = src_row;
  10347.       uint8_t *dst = dst_row;
  10348.       for(x = 0; x < width; x += 1) {
  10349.          union util_format_r32_fixed pixel;
  10350.          pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
  10351.          memcpy(dst, &pixel, sizeof pixel);
  10352.          src += 4;
  10353.          dst += 4;
  10354.       }
  10355.       dst_row += dst_stride;
  10356.       src_row += src_stride/sizeof(*src_row);
  10357.    }
  10358. }
  10359.  
  10360. static INLINE void
  10361. util_format_r32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10362. {
  10363.          union util_format_r32_fixed pixel;
  10364.          memcpy(&pixel, src, sizeof pixel);
  10365.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10366.          dst[1] = 0; /* g */
  10367.          dst[2] = 0; /* b */
  10368.          dst[3] = 1; /* a */
  10369. }
  10370.  
  10371. static INLINE void
  10372. util_format_r32_fixed_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10373. {
  10374.    unsigned x, y;
  10375.    for(y = 0; y < height; y += 1) {
  10376.       uint8_t *dst = dst_row;
  10377.       const uint8_t *src = src_row;
  10378.       for(x = 0; x < width; x += 1) {
  10379.          union util_format_r32_fixed pixel;
  10380.          memcpy(&pixel, src, sizeof pixel);
  10381.          dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
  10382.          dst[1] = 0; /* g */
  10383.          dst[2] = 0; /* b */
  10384.          dst[3] = 255; /* a */
  10385.          src += 4;
  10386.          dst += 4;
  10387.       }
  10388.       src_row += src_stride;
  10389.       dst_row += dst_stride/sizeof(*dst_row);
  10390.    }
  10391. }
  10392.  
  10393. static INLINE void
  10394. util_format_r32_fixed_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10395. {
  10396.    unsigned x, y;
  10397.    for(y = 0; y < height; y += 1) {
  10398.       const uint8_t *src = src_row;
  10399.       uint8_t *dst = dst_row;
  10400.       for(x = 0; x < width; x += 1) {
  10401.          union util_format_r32_fixed pixel;
  10402.          pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
  10403.          memcpy(dst, &pixel, sizeof pixel);
  10404.          src += 4;
  10405.          dst += 4;
  10406.       }
  10407.       dst_row += dst_stride;
  10408.       src_row += src_stride/sizeof(*src_row);
  10409.    }
  10410. }
  10411.  
  10412. union util_format_r32g32_fixed {
  10413.    uint64_t value;
  10414.    struct {
  10415.       int32_t r;
  10416.       int32_t g;
  10417.    } chan;
  10418. };
  10419.  
  10420. static INLINE void
  10421. util_format_r32g32_fixed_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10422. {
  10423.    unsigned x, y;
  10424.    for(y = 0; y < height; y += 1) {
  10425.       float *dst = dst_row;
  10426.       const uint8_t *src = src_row;
  10427.       for(x = 0; x < width; x += 1) {
  10428.          union util_format_r32g32_fixed pixel;
  10429.          memcpy(&pixel, src, sizeof pixel);
  10430.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10431.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10432.          dst[2] = 0; /* b */
  10433.          dst[3] = 1; /* a */
  10434.          src += 8;
  10435.          dst += 4;
  10436.       }
  10437.       src_row += src_stride;
  10438.       dst_row += dst_stride/sizeof(*dst_row);
  10439.    }
  10440. }
  10441.  
  10442. static INLINE void
  10443. util_format_r32g32_fixed_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10444. {
  10445.    unsigned x, y;
  10446.    for(y = 0; y < height; y += 1) {
  10447.       const float *src = src_row;
  10448.       uint8_t *dst = dst_row;
  10449.       for(x = 0; x < width; x += 1) {
  10450.          union util_format_r32g32_fixed pixel;
  10451.          pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
  10452.          pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
  10453.          memcpy(dst, &pixel, sizeof pixel);
  10454.          src += 4;
  10455.          dst += 8;
  10456.       }
  10457.       dst_row += dst_stride;
  10458.       src_row += src_stride/sizeof(*src_row);
  10459.    }
  10460. }
  10461.  
  10462. static INLINE void
  10463. util_format_r32g32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10464. {
  10465.          union util_format_r32g32_fixed pixel;
  10466.          memcpy(&pixel, src, sizeof pixel);
  10467.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10468.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10469.          dst[2] = 0; /* b */
  10470.          dst[3] = 1; /* a */
  10471. }
  10472.  
  10473. static INLINE void
  10474. util_format_r32g32_fixed_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10475. {
  10476.    unsigned x, y;
  10477.    for(y = 0; y < height; y += 1) {
  10478.       uint8_t *dst = dst_row;
  10479.       const uint8_t *src = src_row;
  10480.       for(x = 0; x < width; x += 1) {
  10481.          union util_format_r32g32_fixed pixel;
  10482.          memcpy(&pixel, src, sizeof pixel);
  10483.          dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
  10484.          dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
  10485.          dst[2] = 0; /* b */
  10486.          dst[3] = 255; /* a */
  10487.          src += 8;
  10488.          dst += 4;
  10489.       }
  10490.       src_row += src_stride;
  10491.       dst_row += dst_stride/sizeof(*dst_row);
  10492.    }
  10493. }
  10494.  
  10495. static INLINE void
  10496. util_format_r32g32_fixed_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10497. {
  10498.    unsigned x, y;
  10499.    for(y = 0; y < height; y += 1) {
  10500.       const uint8_t *src = src_row;
  10501.       uint8_t *dst = dst_row;
  10502.       for(x = 0; x < width; x += 1) {
  10503.          union util_format_r32g32_fixed pixel;
  10504.          pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
  10505.          pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
  10506.          memcpy(dst, &pixel, sizeof pixel);
  10507.          src += 4;
  10508.          dst += 8;
  10509.       }
  10510.       dst_row += dst_stride;
  10511.       src_row += src_stride/sizeof(*src_row);
  10512.    }
  10513. }
  10514.  
  10515. union util_format_r32g32b32_fixed {
  10516.    struct {
  10517.       int32_t r;
  10518.       int32_t g;
  10519.       int32_t b;
  10520.    } chan;
  10521. };
  10522.  
  10523. static INLINE void
  10524. util_format_r32g32b32_fixed_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10525. {
  10526.    unsigned x, y;
  10527.    for(y = 0; y < height; y += 1) {
  10528.       float *dst = dst_row;
  10529.       const uint8_t *src = src_row;
  10530.       for(x = 0; x < width; x += 1) {
  10531.          union util_format_r32g32b32_fixed pixel;
  10532.          memcpy(&pixel, src, sizeof pixel);
  10533.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10534.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10535.          dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
  10536.          dst[3] = 1; /* a */
  10537.          src += 12;
  10538.          dst += 4;
  10539.       }
  10540.       src_row += src_stride;
  10541.       dst_row += dst_stride/sizeof(*dst_row);
  10542.    }
  10543. }
  10544.  
  10545. static INLINE void
  10546. util_format_r32g32b32_fixed_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10547. {
  10548.    unsigned x, y;
  10549.    for(y = 0; y < height; y += 1) {
  10550.       const float *src = src_row;
  10551.       uint8_t *dst = dst_row;
  10552.       for(x = 0; x < width; x += 1) {
  10553.          union util_format_r32g32b32_fixed pixel;
  10554.          pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
  10555.          pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
  10556.          pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000);
  10557.          memcpy(dst, &pixel, sizeof pixel);
  10558.          src += 4;
  10559.          dst += 12;
  10560.       }
  10561.       dst_row += dst_stride;
  10562.       src_row += src_stride/sizeof(*src_row);
  10563.    }
  10564. }
  10565.  
  10566. static INLINE void
  10567. util_format_r32g32b32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10568. {
  10569.          union util_format_r32g32b32_fixed pixel;
  10570.          memcpy(&pixel, src, sizeof pixel);
  10571.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10572.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10573.          dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
  10574.          dst[3] = 1; /* a */
  10575. }
  10576.  
  10577. static INLINE void
  10578. util_format_r32g32b32_fixed_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10579. {
  10580.    unsigned x, y;
  10581.    for(y = 0; y < height; y += 1) {
  10582.       uint8_t *dst = dst_row;
  10583.       const uint8_t *src = src_row;
  10584.       for(x = 0; x < width; x += 1) {
  10585.          union util_format_r32g32b32_fixed pixel;
  10586.          memcpy(&pixel, src, sizeof pixel);
  10587.          dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
  10588.          dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
  10589.          dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */
  10590.          dst[3] = 255; /* a */
  10591.          src += 12;
  10592.          dst += 4;
  10593.       }
  10594.       src_row += src_stride;
  10595.       dst_row += dst_stride/sizeof(*dst_row);
  10596.    }
  10597. }
  10598.  
  10599. static INLINE void
  10600. util_format_r32g32b32_fixed_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10601. {
  10602.    unsigned x, y;
  10603.    for(y = 0; y < height; y += 1) {
  10604.       const uint8_t *src = src_row;
  10605.       uint8_t *dst = dst_row;
  10606.       for(x = 0; x < width; x += 1) {
  10607.          union util_format_r32g32b32_fixed pixel;
  10608.          pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
  10609.          pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
  10610.          pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000);
  10611.          memcpy(dst, &pixel, sizeof pixel);
  10612.          src += 4;
  10613.          dst += 12;
  10614.       }
  10615.       dst_row += dst_stride;
  10616.       src_row += src_stride/sizeof(*src_row);
  10617.    }
  10618. }
  10619.  
  10620. union util_format_r32g32b32a32_fixed {
  10621.    struct {
  10622.       int32_t r;
  10623.       int32_t g;
  10624.       int32_t b;
  10625.       int32_t a;
  10626.    } chan;
  10627. };
  10628.  
  10629. static INLINE void
  10630. util_format_r32g32b32a32_fixed_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10631. {
  10632.    unsigned x, y;
  10633.    for(y = 0; y < height; y += 1) {
  10634.       float *dst = dst_row;
  10635.       const uint8_t *src = src_row;
  10636.       for(x = 0; x < width; x += 1) {
  10637.          union util_format_r32g32b32a32_fixed pixel;
  10638.          memcpy(&pixel, src, sizeof pixel);
  10639.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10640.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10641.          dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
  10642.          dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */
  10643.          src += 16;
  10644.          dst += 4;
  10645.       }
  10646.       src_row += src_stride;
  10647.       dst_row += dst_stride/sizeof(*dst_row);
  10648.    }
  10649. }
  10650.  
  10651. static INLINE void
  10652. util_format_r32g32b32a32_fixed_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10653. {
  10654.    unsigned x, y;
  10655.    for(y = 0; y < height; y += 1) {
  10656.       const float *src = src_row;
  10657.       uint8_t *dst = dst_row;
  10658.       for(x = 0; x < width; x += 1) {
  10659.          union util_format_r32g32b32a32_fixed pixel;
  10660.          pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000);
  10661.          pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000);
  10662.          pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000);
  10663.          pixel.chan.a = (int32_t)(CLAMP(src[3], -65536, 65535) * (double)0x10000);
  10664.          memcpy(dst, &pixel, sizeof pixel);
  10665.          src += 4;
  10666.          dst += 16;
  10667.       }
  10668.       dst_row += dst_stride;
  10669.       src_row += src_stride/sizeof(*src_row);
  10670.    }
  10671. }
  10672.  
  10673. static INLINE void
  10674. util_format_r32g32b32a32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10675. {
  10676.          union util_format_r32g32b32a32_fixed pixel;
  10677.          memcpy(&pixel, src, sizeof pixel);
  10678.          dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */
  10679.          dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */
  10680.          dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */
  10681.          dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */
  10682. }
  10683.  
  10684. static INLINE void
  10685. util_format_r32g32b32a32_fixed_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10686. {
  10687.    unsigned x, y;
  10688.    for(y = 0; y < height; y += 1) {
  10689.       uint8_t *dst = dst_row;
  10690.       const uint8_t *src = src_row;
  10691.       for(x = 0; x < width; x += 1) {
  10692.          union util_format_r32g32b32a32_fixed pixel;
  10693.          memcpy(&pixel, src, sizeof pixel);
  10694.          dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */
  10695.          dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */
  10696.          dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */
  10697.          dst[3] = (uint8_t)util_iround((CLAMP(pixel.chan.a, 0, 65536) * (1.0/0x10000)) * 0xff); /* a */
  10698.          src += 16;
  10699.          dst += 4;
  10700.       }
  10701.       src_row += src_stride;
  10702.       dst_row += dst_stride/sizeof(*dst_row);
  10703.    }
  10704. }
  10705.  
  10706. static INLINE void
  10707. util_format_r32g32b32a32_fixed_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10708. {
  10709.    unsigned x, y;
  10710.    for(y = 0; y < height; y += 1) {
  10711.       const uint8_t *src = src_row;
  10712.       uint8_t *dst = dst_row;
  10713.       for(x = 0; x < width; x += 1) {
  10714.          union util_format_r32g32b32a32_fixed pixel;
  10715.          pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000);
  10716.          pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000);
  10717.          pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000);
  10718.          pixel.chan.a = (int32_t)((float)(src[3] * (1.0f/0xff)) * (double)0x10000);
  10719.          memcpy(dst, &pixel, sizeof pixel);
  10720.          src += 4;
  10721.          dst += 16;
  10722.       }
  10723.       dst_row += dst_stride;
  10724.       src_row += src_stride/sizeof(*src_row);
  10725.    }
  10726. }
  10727.  
  10728. union util_format_r10g10b10x2_uscaled {
  10729.    uint32_t value;
  10730.    struct {
  10731.       unsigned r:10;
  10732.       unsigned g:10;
  10733.       unsigned b:10;
  10734.       unsigned x:2;
  10735.    } chan;
  10736. };
  10737.  
  10738. static INLINE void
  10739. util_format_r10g10b10x2_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10740. {
  10741.    unsigned x, y;
  10742.    for(y = 0; y < height; y += 1) {
  10743.       float *dst = dst_row;
  10744.       const uint8_t *src = src_row;
  10745.       for(x = 0; x < width; x += 1) {
  10746.          uint32_t value = *(const uint32_t *)src;
  10747.          uint32_t r;
  10748.          uint32_t g;
  10749.          uint32_t b;
  10750.          r = (value) & 0x3ff;
  10751.          g = (value >> 10) & 0x3ff;
  10752.          b = (value >> 20) & 0x3ff;
  10753.          dst[0] = (float)r; /* r */
  10754.          dst[1] = (float)g; /* g */
  10755.          dst[2] = (float)b; /* b */
  10756.          dst[3] = 1; /* a */
  10757.          src += 4;
  10758.          dst += 4;
  10759.       }
  10760.       src_row += src_stride;
  10761.       dst_row += dst_stride/sizeof(*dst_row);
  10762.    }
  10763. }
  10764.  
  10765. static INLINE void
  10766. util_format_r10g10b10x2_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10767. {
  10768.    unsigned x, y;
  10769.    for(y = 0; y < height; y += 1) {
  10770.       const float *src = src_row;
  10771.       uint8_t *dst = dst_row;
  10772.       for(x = 0; x < width; x += 1) {
  10773.          uint32_t value = 0;
  10774.          value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff;
  10775.          value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10;
  10776.          value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20;
  10777.          *(uint32_t *)dst = value;
  10778.          src += 4;
  10779.          dst += 4;
  10780.       }
  10781.       dst_row += dst_stride;
  10782.       src_row += src_stride/sizeof(*src_row);
  10783.    }
  10784. }
  10785.  
  10786. static INLINE void
  10787. util_format_r10g10b10x2_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10788. {
  10789.          uint32_t value = *(const uint32_t *)src;
  10790.          uint32_t r;
  10791.          uint32_t g;
  10792.          uint32_t b;
  10793.          r = (value) & 0x3ff;
  10794.          g = (value >> 10) & 0x3ff;
  10795.          b = (value >> 20) & 0x3ff;
  10796.          dst[0] = (float)r; /* r */
  10797.          dst[1] = (float)g; /* g */
  10798.          dst[2] = (float)b; /* b */
  10799.          dst[3] = 1; /* a */
  10800. }
  10801.  
  10802. static INLINE void
  10803. util_format_r10g10b10x2_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10804. {
  10805.    unsigned x, y;
  10806.    for(y = 0; y < height; y += 1) {
  10807.       uint8_t *dst = dst_row;
  10808.       const uint8_t *src = src_row;
  10809.       for(x = 0; x < width; x += 1) {
  10810.          uint32_t value = *(const uint32_t *)src;
  10811.          uint32_t r;
  10812.          uint32_t g;
  10813.          uint32_t b;
  10814.          r = (value) & 0x3ff;
  10815.          g = (value >> 10) & 0x3ff;
  10816.          b = (value >> 20) & 0x3ff;
  10817.          dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */
  10818.          dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */
  10819.          dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */
  10820.          dst[3] = 255; /* a */
  10821.          src += 4;
  10822.          dst += 4;
  10823.       }
  10824.       src_row += src_stride;
  10825.       dst_row += dst_stride/sizeof(*dst_row);
  10826.    }
  10827. }
  10828.  
  10829. static INLINE void
  10830. util_format_r10g10b10x2_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10831. {
  10832.    unsigned x, y;
  10833.    for(y = 0; y < height; y += 1) {
  10834.       const uint8_t *src = src_row;
  10835.       uint8_t *dst = dst_row;
  10836.       for(x = 0; x < width; x += 1) {
  10837.          uint32_t value = 0;
  10838.          value |= ((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff;
  10839.          value |= (((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10;
  10840.          value |= (((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) << 20;
  10841.          *(uint32_t *)dst = value;
  10842.          src += 4;
  10843.          dst += 4;
  10844.       }
  10845.       dst_row += dst_stride;
  10846.       src_row += src_stride/sizeof(*src_row);
  10847.    }
  10848. }
  10849.  
  10850. union util_format_r10g10b10x2_snorm {
  10851.    uint32_t value;
  10852.    struct {
  10853.       int r:10;
  10854.       int g:10;
  10855.       int b:10;
  10856.       unsigned x:2;
  10857.    } chan;
  10858. };
  10859.  
  10860. static INLINE void
  10861. util_format_r10g10b10x2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10862. {
  10863.    unsigned x, y;
  10864.    for(y = 0; y < height; y += 1) {
  10865.       float *dst = dst_row;
  10866.       const uint8_t *src = src_row;
  10867.       for(x = 0; x < width; x += 1) {
  10868.          uint32_t value = *(const uint32_t *)src;
  10869.          int32_t r;
  10870.          int32_t g;
  10871.          int32_t b;
  10872.          r = ((int32_t)(value << 22) ) >> 22;
  10873.          g = ((int32_t)(value << 12) ) >> 22;
  10874.          b = ((int32_t)(value << 2) ) >> 22;
  10875.          dst[0] = (float)(r * (1.0f/0x1ff)); /* r */
  10876.          dst[1] = (float)(g * (1.0f/0x1ff)); /* g */
  10877.          dst[2] = (float)(b * (1.0f/0x1ff)); /* b */
  10878.          dst[3] = 1; /* a */
  10879.          src += 4;
  10880.          dst += 4;
  10881.       }
  10882.       src_row += src_stride;
  10883.       dst_row += dst_stride/sizeof(*dst_row);
  10884.    }
  10885. }
  10886.  
  10887. static INLINE void
  10888. util_format_r10g10b10x2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  10889. {
  10890.    unsigned x, y;
  10891.    for(y = 0; y < height; y += 1) {
  10892.       const float *src = src_row;
  10893.       uint8_t *dst = dst_row;
  10894.       for(x = 0; x < width; x += 1) {
  10895.          uint32_t value = 0;
  10896.          value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ;
  10897.          value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ;
  10898.          value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ;
  10899.          *(uint32_t *)dst = value;
  10900.          src += 4;
  10901.          dst += 4;
  10902.       }
  10903.       dst_row += dst_stride;
  10904.       src_row += src_stride/sizeof(*src_row);
  10905.    }
  10906. }
  10907.  
  10908. static INLINE void
  10909. util_format_r10g10b10x2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  10910. {
  10911.          uint32_t value = *(const uint32_t *)src;
  10912.          int32_t r;
  10913.          int32_t g;
  10914.          int32_t b;
  10915.          r = ((int32_t)(value << 22) ) >> 22;
  10916.          g = ((int32_t)(value << 12) ) >> 22;
  10917.          b = ((int32_t)(value << 2) ) >> 22;
  10918.          dst[0] = (float)(r * (1.0f/0x1ff)); /* r */
  10919.          dst[1] = (float)(g * (1.0f/0x1ff)); /* g */
  10920.          dst[2] = (float)(b * (1.0f/0x1ff)); /* b */
  10921.          dst[3] = 1; /* a */
  10922. }
  10923.  
  10924. static INLINE void
  10925. util_format_r10g10b10x2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10926. {
  10927.    unsigned x, y;
  10928.    for(y = 0; y < height; y += 1) {
  10929.       uint8_t *dst = dst_row;
  10930.       const uint8_t *src = src_row;
  10931.       for(x = 0; x < width; x += 1) {
  10932.          uint32_t value = *(const uint32_t *)src;
  10933.          int32_t r;
  10934.          int32_t g;
  10935.          int32_t b;
  10936.          r = ((int32_t)(value << 22) ) >> 22;
  10937.          g = ((int32_t)(value << 12) ) >> 22;
  10938.          b = ((int32_t)(value << 2) ) >> 22;
  10939.          dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */
  10940.          dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */
  10941.          dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */
  10942.          dst[3] = 255; /* a */
  10943.          src += 4;
  10944.          dst += 4;
  10945.       }
  10946.       src_row += src_stride;
  10947.       dst_row += dst_stride/sizeof(*dst_row);
  10948.    }
  10949. }
  10950.  
  10951. static INLINE void
  10952. util_format_r10g10b10x2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10953. {
  10954.    unsigned x, y;
  10955.    for(y = 0; y < height; y += 1) {
  10956.       const uint8_t *src = src_row;
  10957.       uint8_t *dst = dst_row;
  10958.       for(x = 0; x < width; x += 1) {
  10959.          uint32_t value = 0;
  10960.          value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) ;
  10961.          value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ;
  10962.          value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) << 20) ;
  10963.          *(uint32_t *)dst = value;
  10964.          src += 4;
  10965.          dst += 4;
  10966.       }
  10967.       dst_row += dst_stride;
  10968.       src_row += src_stride/sizeof(*src_row);
  10969.    }
  10970. }
  10971.  
  10972. union util_format_r4a4_unorm {
  10973.    uint8_t value;
  10974.    struct {
  10975.       unsigned a:4;
  10976.       unsigned r:4;
  10977.    } chan;
  10978. };
  10979.  
  10980. static INLINE void
  10981. util_format_r4a4_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  10982. {
  10983.    unsigned x, y;
  10984.    for(y = 0; y < height; y += 1) {
  10985.       float *dst = dst_row;
  10986.       const uint8_t *src = src_row;
  10987.       for(x = 0; x < width; x += 1) {
  10988.          uint8_t value = *(const uint8_t *)src;
  10989.          uint8_t a;
  10990.          uint8_t r;
  10991.          a = (value) & 0xf;
  10992.          r = value >> 4;
  10993.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  10994.          dst[1] = 0; /* g */
  10995.          dst[2] = 0; /* b */
  10996.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  10997.          src += 1;
  10998.          dst += 4;
  10999.       }
  11000.       src_row += src_stride;
  11001.       dst_row += dst_stride/sizeof(*dst_row);
  11002.    }
  11003. }
  11004.  
  11005. static INLINE void
  11006. util_format_r4a4_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  11007. {
  11008.    unsigned x, y;
  11009.    for(y = 0; y < height; y += 1) {
  11010.       const float *src = src_row;
  11011.       uint8_t *dst = dst_row;
  11012.       for(x = 0; x < width; x += 1) {
  11013.          uint8_t value = 0;
  11014.          value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) & 0xf;
  11015.          value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) << 4;
  11016.          *(uint8_t *)dst = value;
  11017.          src += 4;
  11018.          dst += 1;
  11019.       }
  11020.       dst_row += dst_stride;
  11021.       src_row += src_stride/sizeof(*src_row);
  11022.    }
  11023. }
  11024.  
  11025. static INLINE void
  11026. util_format_r4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  11027. {
  11028.          uint8_t value = *(const uint8_t *)src;
  11029.          uint8_t a;
  11030.          uint8_t r;
  11031.          a = (value) & 0xf;
  11032.          r = value >> 4;
  11033.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  11034.          dst[1] = 0; /* g */
  11035.          dst[2] = 0; /* b */
  11036.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  11037. }
  11038.  
  11039. static INLINE void
  11040. util_format_r4a4_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11041. {
  11042.    unsigned x, y;
  11043.    for(y = 0; y < height; y += 1) {
  11044.       uint8_t *dst = dst_row;
  11045.       const uint8_t *src = src_row;
  11046.       for(x = 0; x < width; x += 1) {
  11047.          uint8_t value = *(const uint8_t *)src;
  11048.          uint8_t a;
  11049.          uint8_t r;
  11050.          a = (value) & 0xf;
  11051.          r = value >> 4;
  11052.          dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */
  11053.          dst[1] = 0; /* g */
  11054.          dst[2] = 0; /* b */
  11055.          dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
  11056.          src += 1;
  11057.          dst += 4;
  11058.       }
  11059.       src_row += src_stride;
  11060.       dst_row += dst_stride/sizeof(*dst_row);
  11061.    }
  11062. }
  11063.  
  11064. static INLINE void
  11065. util_format_r4a4_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11066. {
  11067.    unsigned x, y;
  11068.    for(y = 0; y < height; y += 1) {
  11069.       const uint8_t *src = src_row;
  11070.       uint8_t *dst = dst_row;
  11071.       for(x = 0; x < width; x += 1) {
  11072.          uint8_t value = 0;
  11073.          value |= ((uint8_t)(src[3] >> 4)) & 0xf;
  11074.          value |= ((uint8_t)(src[0] >> 4)) << 4;
  11075.          *(uint8_t *)dst = value;
  11076.          src += 4;
  11077.          dst += 1;
  11078.       }
  11079.       dst_row += dst_stride;
  11080.       src_row += src_stride/sizeof(*src_row);
  11081.    }
  11082. }
  11083.  
  11084. union util_format_a4r4_unorm {
  11085.    uint8_t value;
  11086.    struct {
  11087.       unsigned r:4;
  11088.       unsigned a:4;
  11089.    } chan;
  11090. };
  11091.  
  11092. static INLINE void
  11093. util_format_a4r4_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11094. {
  11095.    unsigned x, y;
  11096.    for(y = 0; y < height; y += 1) {
  11097.       float *dst = dst_row;
  11098.       const uint8_t *src = src_row;
  11099.       for(x = 0; x < width; x += 1) {
  11100.          uint8_t value = *(const uint8_t *)src;
  11101.          uint8_t r;
  11102.          uint8_t a;
  11103.          r = (value) & 0xf;
  11104.          a = value >> 4;
  11105.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  11106.          dst[1] = 0; /* g */
  11107.          dst[2] = 0; /* b */
  11108.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  11109.          src += 1;
  11110.          dst += 4;
  11111.       }
  11112.       src_row += src_stride;
  11113.       dst_row += dst_stride/sizeof(*dst_row);
  11114.    }
  11115. }
  11116.  
  11117. static INLINE void
  11118. util_format_a4r4_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  11119. {
  11120.    unsigned x, y;
  11121.    for(y = 0; y < height; y += 1) {
  11122.       const float *src = src_row;
  11123.       uint8_t *dst = dst_row;
  11124.       for(x = 0; x < width; x += 1) {
  11125.          uint8_t value = 0;
  11126.          value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf;
  11127.          value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4;
  11128.          *(uint8_t *)dst = value;
  11129.          src += 4;
  11130.          dst += 1;
  11131.       }
  11132.       dst_row += dst_stride;
  11133.       src_row += src_stride/sizeof(*src_row);
  11134.    }
  11135. }
  11136.  
  11137. static INLINE void
  11138. util_format_a4r4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  11139. {
  11140.          uint8_t value = *(const uint8_t *)src;
  11141.          uint8_t r;
  11142.          uint8_t a;
  11143.          r = (value) & 0xf;
  11144.          a = value >> 4;
  11145.          dst[0] = (float)(r * (1.0f/0xf)); /* r */
  11146.          dst[1] = 0; /* g */
  11147.          dst[2] = 0; /* b */
  11148.          dst[3] = (float)(a * (1.0f/0xf)); /* a */
  11149. }
  11150.  
  11151. static INLINE void
  11152. util_format_a4r4_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11153. {
  11154.    unsigned x, y;
  11155.    for(y = 0; y < height; y += 1) {
  11156.       uint8_t *dst = dst_row;
  11157.       const uint8_t *src = src_row;
  11158.       for(x = 0; x < width; x += 1) {
  11159.          uint8_t value = *(const uint8_t *)src;
  11160.          uint8_t r;
  11161.          uint8_t a;
  11162.          r = (value) & 0xf;
  11163.          a = value >> 4;
  11164.          dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */
  11165.          dst[1] = 0; /* g */
  11166.          dst[2] = 0; /* b */
  11167.          dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */
  11168.          src += 1;
  11169.          dst += 4;
  11170.       }
  11171.       src_row += src_stride;
  11172.       dst_row += dst_stride/sizeof(*dst_row);
  11173.    }
  11174. }
  11175.  
  11176. static INLINE void
  11177. util_format_a4r4_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11178. {
  11179.    unsigned x, y;
  11180.    for(y = 0; y < height; y += 1) {
  11181.       const uint8_t *src = src_row;
  11182.       uint8_t *dst = dst_row;
  11183.       for(x = 0; x < width; x += 1) {
  11184.          uint8_t value = 0;
  11185.          value |= ((uint8_t)(src[0] >> 4)) & 0xf;
  11186.          value |= ((uint8_t)(src[3] >> 4)) << 4;
  11187.          *(uint8_t *)dst = value;
  11188.          src += 4;
  11189.          dst += 1;
  11190.       }
  11191.       dst_row += dst_stride;
  11192.       src_row += src_stride/sizeof(*src_row);
  11193.    }
  11194. }
  11195.  
  11196. union util_format_r8a8_unorm {
  11197.    uint16_t value;
  11198.    struct {
  11199.       uint8_t r;
  11200.       uint8_t a;
  11201.    } chan;
  11202. };
  11203.  
  11204. static INLINE void
  11205. util_format_r8a8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11206. {
  11207.    unsigned x, y;
  11208.    for(y = 0; y < height; y += 1) {
  11209.       float *dst = dst_row;
  11210.       const uint8_t *src = src_row;
  11211.       for(x = 0; x < width; x += 1) {
  11212.          uint16_t value = *(const uint16_t *)src;
  11213.          uint16_t r;
  11214.          uint16_t a;
  11215.          r = (value) & 0xff;
  11216.          a = value >> 8;
  11217.          dst[0] = ubyte_to_float(r); /* r */
  11218.          dst[1] = 0; /* g */
  11219.          dst[2] = 0; /* b */
  11220.          dst[3] = ubyte_to_float(a); /* a */
  11221.          src += 2;
  11222.          dst += 4;
  11223.       }
  11224.       src_row += src_stride;
  11225.       dst_row += dst_stride/sizeof(*dst_row);
  11226.    }
  11227. }
  11228.  
  11229. static INLINE void
  11230. util_format_r8a8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  11231. {
  11232.    unsigned x, y;
  11233.    for(y = 0; y < height; y += 1) {
  11234.       const float *src = src_row;
  11235.       uint8_t *dst = dst_row;
  11236.       for(x = 0; x < width; x += 1) {
  11237.          uint16_t value = 0;
  11238.          value |= (float_to_ubyte(src[0])) & 0xff;
  11239.          value |= (float_to_ubyte(src[3])) << 8;
  11240.          *(uint16_t *)dst = value;
  11241.          src += 4;
  11242.          dst += 2;
  11243.       }
  11244.       dst_row += dst_stride;
  11245.       src_row += src_stride/sizeof(*src_row);
  11246.    }
  11247. }
  11248.  
  11249. static INLINE void
  11250. util_format_r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  11251. {
  11252.          uint16_t value = *(const uint16_t *)src;
  11253.          uint16_t r;
  11254.          uint16_t a;
  11255.          r = (value) & 0xff;
  11256.          a = value >> 8;
  11257.          dst[0] = ubyte_to_float(r); /* r */
  11258.          dst[1] = 0; /* g */
  11259.          dst[2] = 0; /* b */
  11260.          dst[3] = ubyte_to_float(a); /* a */
  11261. }
  11262.  
  11263. static INLINE void
  11264. util_format_r8a8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11265. {
  11266.    unsigned x, y;
  11267.    for(y = 0; y < height; y += 1) {
  11268.       uint8_t *dst = dst_row;
  11269.       const uint8_t *src = src_row;
  11270.       for(x = 0; x < width; x += 1) {
  11271.          uint16_t value = *(const uint16_t *)src;
  11272.          uint16_t r;
  11273.          uint16_t a;
  11274.          r = (value) & 0xff;
  11275.          a = value >> 8;
  11276.          dst[0] = r; /* r */
  11277.          dst[1] = 0; /* g */
  11278.          dst[2] = 0; /* b */
  11279.          dst[3] = a; /* a */
  11280.          src += 2;
  11281.          dst += 4;
  11282.       }
  11283.       src_row += src_stride;
  11284.       dst_row += dst_stride/sizeof(*dst_row);
  11285.    }
  11286. }
  11287.  
  11288. static INLINE void
  11289. util_format_r8a8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11290. {
  11291.    unsigned x, y;
  11292.    for(y = 0; y < height; y += 1) {
  11293.       const uint8_t *src = src_row;
  11294.       uint8_t *dst = dst_row;
  11295.       for(x = 0; x < width; x += 1) {
  11296.          uint16_t value = 0;
  11297.          value |= (src[0]) & 0xff;
  11298.          value |= (src[3]) << 8;
  11299.          *(uint16_t *)dst = value;
  11300.          src += 4;
  11301.          dst += 2;
  11302.       }
  11303.       dst_row += dst_stride;
  11304.       src_row += src_stride/sizeof(*src_row);
  11305.    }
  11306. }
  11307.  
  11308. union util_format_a8r8_unorm {
  11309.    uint16_t value;
  11310.    struct {
  11311.       uint8_t a;
  11312.       uint8_t r;
  11313.    } chan;
  11314. };
  11315.  
  11316. static INLINE void
  11317. util_format_a8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11318. {
  11319.    unsigned x, y;
  11320.    for(y = 0; y < height; y += 1) {
  11321.       float *dst = dst_row;
  11322.       const uint8_t *src = src_row;
  11323.       for(x = 0; x < width; x += 1) {
  11324.          uint16_t value = *(const uint16_t *)src;
  11325.          uint16_t a;
  11326.          uint16_t r;
  11327.          a = (value) & 0xff;
  11328.          r = value >> 8;
  11329.          dst[0] = ubyte_to_float(r); /* r */
  11330.          dst[1] = 0; /* g */
  11331.          dst[2] = 0; /* b */
  11332.          dst[3] = ubyte_to_float(a); /* a */
  11333.          src += 2;
  11334.          dst += 4;
  11335.       }
  11336.       src_row += src_stride;
  11337.       dst_row += dst_stride/sizeof(*dst_row);
  11338.    }
  11339. }
  11340.  
  11341. static INLINE void
  11342. util_format_a8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  11343. {
  11344.    unsigned x, y;
  11345.    for(y = 0; y < height; y += 1) {
  11346.       const float *src = src_row;
  11347.       uint8_t *dst = dst_row;
  11348.       for(x = 0; x < width; x += 1) {
  11349.          uint16_t value = 0;
  11350.          value |= (float_to_ubyte(src[3])) & 0xff;
  11351.          value |= (float_to_ubyte(src[0])) << 8;
  11352.          *(uint16_t *)dst = value;
  11353.          src += 4;
  11354.          dst += 2;
  11355.       }
  11356.       dst_row += dst_stride;
  11357.       src_row += src_stride/sizeof(*src_row);
  11358.    }
  11359. }
  11360.  
  11361. static INLINE void
  11362. util_format_a8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  11363. {
  11364.          uint16_t value = *(const uint16_t *)src;
  11365.          uint16_t a;
  11366.          uint16_t r;
  11367.          a = (value) & 0xff;
  11368.          r = value >> 8;
  11369.          dst[0] = ubyte_to_float(r); /* r */
  11370.          dst[1] = 0; /* g */
  11371.          dst[2] = 0; /* b */
  11372.          dst[3] = ubyte_to_float(a); /* a */
  11373. }
  11374.  
  11375. static INLINE void
  11376. util_format_a8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11377. {
  11378.    unsigned x, y;
  11379.    for(y = 0; y < height; y += 1) {
  11380.       uint8_t *dst = dst_row;
  11381.       const uint8_t *src = src_row;
  11382.       for(x = 0; x < width; x += 1) {
  11383.          uint16_t value = *(const uint16_t *)src;
  11384.          uint16_t a;
  11385.          uint16_t r;
  11386.          a = (value) & 0xff;
  11387.          r = value >> 8;
  11388.          dst[0] = r; /* r */
  11389.          dst[1] = 0; /* g */
  11390.          dst[2] = 0; /* b */
  11391.          dst[3] = a; /* a */
  11392.          src += 2;
  11393.          dst += 4;
  11394.       }
  11395.       src_row += src_stride;
  11396.       dst_row += dst_stride/sizeof(*dst_row);
  11397.    }
  11398. }
  11399.  
  11400. static INLINE void
  11401. util_format_a8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11402. {
  11403.    unsigned x, y;
  11404.    for(y = 0; y < height; y += 1) {
  11405.       const uint8_t *src = src_row;
  11406.       uint8_t *dst = dst_row;
  11407.       for(x = 0; x < width; x += 1) {
  11408.          uint16_t value = 0;
  11409.          value |= (src[3]) & 0xff;
  11410.          value |= (src[0]) << 8;
  11411.          *(uint16_t *)dst = value;
  11412.          src += 4;
  11413.          dst += 2;
  11414.       }
  11415.       dst_row += dst_stride;
  11416.       src_row += src_stride/sizeof(*src_row);
  11417.    }
  11418. }
  11419.  
  11420. union util_format_r8_uint {
  11421.    uint8_t value;
  11422.    struct {
  11423.       uint8_t r;
  11424.    } chan;
  11425. };
  11426.  
  11427. static INLINE void
  11428. util_format_r8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11429. {
  11430.    unsigned x, y;
  11431.    for(y = 0; y < height; y += 1) {
  11432.       unsigned *dst = dst_row;
  11433.       const uint8_t *src = src_row;
  11434.       for(x = 0; x < width; x += 1) {
  11435.          uint8_t value = *(const uint8_t *)src;
  11436.          uint8_t r;
  11437.          r = value;
  11438.          dst[0] = (unsigned)r; /* r */
  11439.          dst[1] = 0; /* g */
  11440.          dst[2] = 0; /* b */
  11441.          dst[3] = 1; /* a */
  11442.          src += 1;
  11443.          dst += 4;
  11444.       }
  11445.       src_row += src_stride;
  11446.       dst_row += dst_stride/sizeof(*dst_row);
  11447.    }
  11448. }
  11449.  
  11450. static INLINE void
  11451. util_format_r8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  11452. {
  11453.    unsigned x, y;
  11454.    for(y = 0; y < height; y += 1) {
  11455.       const unsigned *src = src_row;
  11456.       uint8_t *dst = dst_row;
  11457.       for(x = 0; x < width; x += 1) {
  11458.          uint8_t value = 0;
  11459.          value |= (uint8_t)MIN2(src[0], 255);
  11460.          *(uint8_t *)dst = value;
  11461.          src += 4;
  11462.          dst += 1;
  11463.       }
  11464.       dst_row += dst_stride;
  11465.       src_row += src_stride/sizeof(*src_row);
  11466.    }
  11467. }
  11468.  
  11469. static INLINE void
  11470. util_format_r8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  11471. {
  11472.          uint8_t value = *(const uint8_t *)src;
  11473.          uint8_t r;
  11474.          r = value;
  11475.          dst[0] = (unsigned)r; /* r */
  11476.          dst[1] = 0; /* g */
  11477.          dst[2] = 0; /* b */
  11478.          dst[3] = 1; /* a */
  11479. }
  11480.  
  11481. static INLINE void
  11482. util_format_r8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11483. {
  11484.    unsigned x, y;
  11485.    for(y = 0; y < height; y += 1) {
  11486.       int *dst = dst_row;
  11487.       const uint8_t *src = src_row;
  11488.       for(x = 0; x < width; x += 1) {
  11489.          uint8_t value = *(const uint8_t *)src;
  11490.          uint8_t r;
  11491.          r = value;
  11492.          dst[0] = (int)r; /* r */
  11493.          dst[1] = 0; /* g */
  11494.          dst[2] = 0; /* b */
  11495.          dst[3] = 1; /* a */
  11496.          src += 1;
  11497.          dst += 4;
  11498.       }
  11499.       src_row += src_stride;
  11500.       dst_row += dst_stride/sizeof(*dst_row);
  11501.    }
  11502. }
  11503.  
  11504. static INLINE void
  11505. util_format_r8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  11506. {
  11507.    unsigned x, y;
  11508.    for(y = 0; y < height; y += 1) {
  11509.       const int *src = src_row;
  11510.       uint8_t *dst = dst_row;
  11511.       for(x = 0; x < width; x += 1) {
  11512.          uint8_t value = 0;
  11513.          value |= (uint8_t)CLAMP(src[0], 0, 255);
  11514.          *(uint8_t *)dst = value;
  11515.          src += 4;
  11516.          dst += 1;
  11517.       }
  11518.       dst_row += dst_stride;
  11519.       src_row += src_stride/sizeof(*src_row);
  11520.    }
  11521. }
  11522.  
  11523. union util_format_r8g8_uint {
  11524.    uint16_t value;
  11525.    struct {
  11526.       uint8_t r;
  11527.       uint8_t g;
  11528.    } chan;
  11529. };
  11530.  
  11531. static INLINE void
  11532. util_format_r8g8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11533. {
  11534.    unsigned x, y;
  11535.    for(y = 0; y < height; y += 1) {
  11536.       unsigned *dst = dst_row;
  11537.       const uint8_t *src = src_row;
  11538.       for(x = 0; x < width; x += 1) {
  11539.          uint16_t value = *(const uint16_t *)src;
  11540.          uint16_t r;
  11541.          uint16_t g;
  11542.          r = (value) & 0xff;
  11543.          g = value >> 8;
  11544.          dst[0] = (unsigned)r; /* r */
  11545.          dst[1] = (unsigned)g; /* g */
  11546.          dst[2] = 0; /* b */
  11547.          dst[3] = 1; /* a */
  11548.          src += 2;
  11549.          dst += 4;
  11550.       }
  11551.       src_row += src_stride;
  11552.       dst_row += dst_stride/sizeof(*dst_row);
  11553.    }
  11554. }
  11555.  
  11556. static INLINE void
  11557. util_format_r8g8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  11558. {
  11559.    unsigned x, y;
  11560.    for(y = 0; y < height; y += 1) {
  11561.       const unsigned *src = src_row;
  11562.       uint8_t *dst = dst_row;
  11563.       for(x = 0; x < width; x += 1) {
  11564.          uint16_t value = 0;
  11565.          value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
  11566.          value |= ((uint8_t)MIN2(src[1], 255)) << 8;
  11567.          *(uint16_t *)dst = value;
  11568.          src += 4;
  11569.          dst += 2;
  11570.       }
  11571.       dst_row += dst_stride;
  11572.       src_row += src_stride/sizeof(*src_row);
  11573.    }
  11574. }
  11575.  
  11576. static INLINE void
  11577. util_format_r8g8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  11578. {
  11579.          uint16_t value = *(const uint16_t *)src;
  11580.          uint16_t r;
  11581.          uint16_t g;
  11582.          r = (value) & 0xff;
  11583.          g = value >> 8;
  11584.          dst[0] = (unsigned)r; /* r */
  11585.          dst[1] = (unsigned)g; /* g */
  11586.          dst[2] = 0; /* b */
  11587.          dst[3] = 1; /* a */
  11588. }
  11589.  
  11590. static INLINE void
  11591. util_format_r8g8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11592. {
  11593.    unsigned x, y;
  11594.    for(y = 0; y < height; y += 1) {
  11595.       int *dst = dst_row;
  11596.       const uint8_t *src = src_row;
  11597.       for(x = 0; x < width; x += 1) {
  11598.          uint16_t value = *(const uint16_t *)src;
  11599.          uint16_t r;
  11600.          uint16_t g;
  11601.          r = (value) & 0xff;
  11602.          g = value >> 8;
  11603.          dst[0] = (int)r; /* r */
  11604.          dst[1] = (int)g; /* g */
  11605.          dst[2] = 0; /* b */
  11606.          dst[3] = 1; /* a */
  11607.          src += 2;
  11608.          dst += 4;
  11609.       }
  11610.       src_row += src_stride;
  11611.       dst_row += dst_stride/sizeof(*dst_row);
  11612.    }
  11613. }
  11614.  
  11615. static INLINE void
  11616. util_format_r8g8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  11617. {
  11618.    unsigned x, y;
  11619.    for(y = 0; y < height; y += 1) {
  11620.       const int *src = src_row;
  11621.       uint8_t *dst = dst_row;
  11622.       for(x = 0; x < width; x += 1) {
  11623.          uint16_t value = 0;
  11624.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  11625.          value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8;
  11626.          *(uint16_t *)dst = value;
  11627.          src += 4;
  11628.          dst += 2;
  11629.       }
  11630.       dst_row += dst_stride;
  11631.       src_row += src_stride/sizeof(*src_row);
  11632.    }
  11633. }
  11634.  
  11635. union util_format_r8g8b8_uint {
  11636.    struct {
  11637.       uint8_t r;
  11638.       uint8_t g;
  11639.       uint8_t b;
  11640.    } chan;
  11641. };
  11642.  
  11643. static INLINE void
  11644. util_format_r8g8b8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11645. {
  11646.    unsigned x, y;
  11647.    for(y = 0; y < height; y += 1) {
  11648.       unsigned *dst = dst_row;
  11649.       const uint8_t *src = src_row;
  11650.       for(x = 0; x < width; x += 1) {
  11651.          union util_format_r8g8b8_uint pixel;
  11652.          memcpy(&pixel, src, sizeof pixel);
  11653.          dst[0] = (unsigned)pixel.chan.r; /* r */
  11654.          dst[1] = (unsigned)pixel.chan.g; /* g */
  11655.          dst[2] = (unsigned)pixel.chan.b; /* b */
  11656.          dst[3] = 1; /* a */
  11657.          src += 3;
  11658.          dst += 4;
  11659.       }
  11660.       src_row += src_stride;
  11661.       dst_row += dst_stride/sizeof(*dst_row);
  11662.    }
  11663. }
  11664.  
  11665. static INLINE void
  11666. util_format_r8g8b8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  11667. {
  11668.    unsigned x, y;
  11669.    for(y = 0; y < height; y += 1) {
  11670.       const unsigned *src = src_row;
  11671.       uint8_t *dst = dst_row;
  11672.       for(x = 0; x < width; x += 1) {
  11673.          union util_format_r8g8b8_uint pixel;
  11674.          pixel.chan.r = (uint8_t)MIN2(src[0], 255);
  11675.          pixel.chan.g = (uint8_t)MIN2(src[1], 255);
  11676.          pixel.chan.b = (uint8_t)MIN2(src[2], 255);
  11677.          memcpy(dst, &pixel, sizeof pixel);
  11678.          src += 4;
  11679.          dst += 3;
  11680.       }
  11681.       dst_row += dst_stride;
  11682.       src_row += src_stride/sizeof(*src_row);
  11683.    }
  11684. }
  11685.  
  11686. static INLINE void
  11687. util_format_r8g8b8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  11688. {
  11689.          union util_format_r8g8b8_uint pixel;
  11690.          memcpy(&pixel, src, sizeof pixel);
  11691.          dst[0] = (unsigned)pixel.chan.r; /* r */
  11692.          dst[1] = (unsigned)pixel.chan.g; /* g */
  11693.          dst[2] = (unsigned)pixel.chan.b; /* b */
  11694.          dst[3] = 1; /* a */
  11695. }
  11696.  
  11697. static INLINE void
  11698. util_format_r8g8b8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11699. {
  11700.    unsigned x, y;
  11701.    for(y = 0; y < height; y += 1) {
  11702.       int *dst = dst_row;
  11703.       const uint8_t *src = src_row;
  11704.       for(x = 0; x < width; x += 1) {
  11705.          union util_format_r8g8b8_uint pixel;
  11706.          memcpy(&pixel, src, sizeof pixel);
  11707.          dst[0] = (int)pixel.chan.r; /* r */
  11708.          dst[1] = (int)pixel.chan.g; /* g */
  11709.          dst[2] = (int)pixel.chan.b; /* b */
  11710.          dst[3] = 1; /* a */
  11711.          src += 3;
  11712.          dst += 4;
  11713.       }
  11714.       src_row += src_stride;
  11715.       dst_row += dst_stride/sizeof(*dst_row);
  11716.    }
  11717. }
  11718.  
  11719. static INLINE void
  11720. util_format_r8g8b8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  11721. {
  11722.    unsigned x, y;
  11723.    for(y = 0; y < height; y += 1) {
  11724.       const int *src = src_row;
  11725.       uint8_t *dst = dst_row;
  11726.       for(x = 0; x < width; x += 1) {
  11727.          union util_format_r8g8b8_uint pixel;
  11728.          pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255);
  11729.          pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255);
  11730.          pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255);
  11731.          memcpy(dst, &pixel, sizeof pixel);
  11732.          src += 4;
  11733.          dst += 3;
  11734.       }
  11735.       dst_row += dst_stride;
  11736.       src_row += src_stride/sizeof(*src_row);
  11737.    }
  11738. }
  11739.  
  11740. union util_format_r8g8b8a8_uint {
  11741.    uint32_t value;
  11742.    struct {
  11743.       uint8_t r;
  11744.       uint8_t g;
  11745.       uint8_t b;
  11746.       uint8_t a;
  11747.    } chan;
  11748. };
  11749.  
  11750. static INLINE void
  11751. util_format_r8g8b8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11752. {
  11753.    unsigned x, y;
  11754.    for(y = 0; y < height; y += 1) {
  11755.       unsigned *dst = dst_row;
  11756.       const uint8_t *src = src_row;
  11757.       for(x = 0; x < width; x += 1) {
  11758.          uint32_t value = *(const uint32_t *)src;
  11759.          uint32_t r;
  11760.          uint32_t g;
  11761.          uint32_t b;
  11762.          uint32_t a;
  11763.          r = (value) & 0xff;
  11764.          g = (value >> 8) & 0xff;
  11765.          b = (value >> 16) & 0xff;
  11766.          a = value >> 24;
  11767.          dst[0] = (unsigned)r; /* r */
  11768.          dst[1] = (unsigned)g; /* g */
  11769.          dst[2] = (unsigned)b; /* b */
  11770.          dst[3] = (unsigned)a; /* a */
  11771.          src += 4;
  11772.          dst += 4;
  11773.       }
  11774.       src_row += src_stride;
  11775.       dst_row += dst_stride/sizeof(*dst_row);
  11776.    }
  11777. }
  11778.  
  11779. static INLINE void
  11780. util_format_r8g8b8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  11781. {
  11782.    unsigned x, y;
  11783.    for(y = 0; y < height; y += 1) {
  11784.       const unsigned *src = src_row;
  11785.       uint8_t *dst = dst_row;
  11786.       for(x = 0; x < width; x += 1) {
  11787.          uint32_t value = 0;
  11788.          value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
  11789.          value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8;
  11790.          value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16;
  11791.          value |= ((uint8_t)MIN2(src[3], 255)) << 24;
  11792.          *(uint32_t *)dst = value;
  11793.          src += 4;
  11794.          dst += 4;
  11795.       }
  11796.       dst_row += dst_stride;
  11797.       src_row += src_stride/sizeof(*src_row);
  11798.    }
  11799. }
  11800.  
  11801. static INLINE void
  11802. util_format_r8g8b8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  11803. {
  11804.          uint32_t value = *(const uint32_t *)src;
  11805.          uint32_t r;
  11806.          uint32_t g;
  11807.          uint32_t b;
  11808.          uint32_t a;
  11809.          r = (value) & 0xff;
  11810.          g = (value >> 8) & 0xff;
  11811.          b = (value >> 16) & 0xff;
  11812.          a = value >> 24;
  11813.          dst[0] = (unsigned)r; /* r */
  11814.          dst[1] = (unsigned)g; /* g */
  11815.          dst[2] = (unsigned)b; /* b */
  11816.          dst[3] = (unsigned)a; /* a */
  11817. }
  11818.  
  11819. static INLINE void
  11820. util_format_r8g8b8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11821. {
  11822.    unsigned x, y;
  11823.    for(y = 0; y < height; y += 1) {
  11824.       int *dst = dst_row;
  11825.       const uint8_t *src = src_row;
  11826.       for(x = 0; x < width; x += 1) {
  11827.          uint32_t value = *(const uint32_t *)src;
  11828.          uint32_t r;
  11829.          uint32_t g;
  11830.          uint32_t b;
  11831.          uint32_t a;
  11832.          r = (value) & 0xff;
  11833.          g = (value >> 8) & 0xff;
  11834.          b = (value >> 16) & 0xff;
  11835.          a = value >> 24;
  11836.          dst[0] = (int)r; /* r */
  11837.          dst[1] = (int)g; /* g */
  11838.          dst[2] = (int)b; /* b */
  11839.          dst[3] = (int)a; /* a */
  11840.          src += 4;
  11841.          dst += 4;
  11842.       }
  11843.       src_row += src_stride;
  11844.       dst_row += dst_stride/sizeof(*dst_row);
  11845.    }
  11846. }
  11847.  
  11848. static INLINE void
  11849. util_format_r8g8b8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  11850. {
  11851.    unsigned x, y;
  11852.    for(y = 0; y < height; y += 1) {
  11853.       const int *src = src_row;
  11854.       uint8_t *dst = dst_row;
  11855.       for(x = 0; x < width; x += 1) {
  11856.          uint32_t value = 0;
  11857.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  11858.          value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
  11859.          value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
  11860.          value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24;
  11861.          *(uint32_t *)dst = value;
  11862.          src += 4;
  11863.          dst += 4;
  11864.       }
  11865.       dst_row += dst_stride;
  11866.       src_row += src_stride/sizeof(*src_row);
  11867.    }
  11868. }
  11869.  
  11870. union util_format_r8_sint {
  11871.    uint8_t value;
  11872.    struct {
  11873.       int8_t r;
  11874.    } chan;
  11875. };
  11876.  
  11877. static INLINE void
  11878. util_format_r8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11879. {
  11880.    unsigned x, y;
  11881.    for(y = 0; y < height; y += 1) {
  11882.       int *dst = dst_row;
  11883.       const uint8_t *src = src_row;
  11884.       for(x = 0; x < width; x += 1) {
  11885.          uint8_t value = *(const uint8_t *)src;
  11886.          int8_t r;
  11887.          r = (int8_t)(value) ;
  11888.          dst[0] = (int)r; /* r */
  11889.          dst[1] = 0; /* g */
  11890.          dst[2] = 0; /* b */
  11891.          dst[3] = 1; /* a */
  11892.          src += 1;
  11893.          dst += 4;
  11894.       }
  11895.       src_row += src_stride;
  11896.       dst_row += dst_stride/sizeof(*dst_row);
  11897.    }
  11898. }
  11899.  
  11900. static INLINE void
  11901. util_format_r8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  11902. {
  11903.    unsigned x, y;
  11904.    for(y = 0; y < height; y += 1) {
  11905.       const int *src = src_row;
  11906.       uint8_t *dst = dst_row;
  11907.       for(x = 0; x < width; x += 1) {
  11908.          uint8_t value = 0;
  11909.          value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
  11910.          *(uint8_t *)dst = value;
  11911.          src += 4;
  11912.          dst += 1;
  11913.       }
  11914.       dst_row += dst_stride;
  11915.       src_row += src_stride/sizeof(*src_row);
  11916.    }
  11917. }
  11918.  
  11919. static INLINE void
  11920. util_format_r8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  11921. {
  11922.          uint8_t value = *(const uint8_t *)src;
  11923.          int8_t r;
  11924.          r = (int8_t)(value) ;
  11925.          dst[0] = (int)r; /* r */
  11926.          dst[1] = 0; /* g */
  11927.          dst[2] = 0; /* b */
  11928.          dst[3] = 1; /* a */
  11929. }
  11930.  
  11931. static INLINE void
  11932. util_format_r8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11933. {
  11934.    unsigned x, y;
  11935.    for(y = 0; y < height; y += 1) {
  11936.       unsigned *dst = dst_row;
  11937.       const uint8_t *src = src_row;
  11938.       for(x = 0; x < width; x += 1) {
  11939.          uint8_t value = *(const uint8_t *)src;
  11940.          int8_t r;
  11941.          r = (int8_t)(value) ;
  11942.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  11943.          dst[1] = 0; /* g */
  11944.          dst[2] = 0; /* b */
  11945.          dst[3] = 1; /* a */
  11946.          src += 1;
  11947.          dst += 4;
  11948.       }
  11949.       src_row += src_stride;
  11950.       dst_row += dst_stride/sizeof(*dst_row);
  11951.    }
  11952. }
  11953.  
  11954. static INLINE void
  11955. util_format_r8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  11956. {
  11957.    unsigned x, y;
  11958.    for(y = 0; y < height; y += 1) {
  11959.       const unsigned *src = src_row;
  11960.       uint8_t *dst = dst_row;
  11961.       for(x = 0; x < width; x += 1) {
  11962.          uint8_t value = 0;
  11963.          value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
  11964.          *(uint8_t *)dst = value;
  11965.          src += 4;
  11966.          dst += 1;
  11967.       }
  11968.       dst_row += dst_stride;
  11969.       src_row += src_stride/sizeof(*src_row);
  11970.    }
  11971. }
  11972.  
  11973. union util_format_r8g8_sint {
  11974.    uint16_t value;
  11975.    struct {
  11976.       int8_t r;
  11977.       int8_t g;
  11978.    } chan;
  11979. };
  11980.  
  11981. static INLINE void
  11982. util_format_r8g8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  11983. {
  11984.    unsigned x, y;
  11985.    for(y = 0; y < height; y += 1) {
  11986.       int *dst = dst_row;
  11987.       const uint8_t *src = src_row;
  11988.       for(x = 0; x < width; x += 1) {
  11989.          uint16_t value = *(const uint16_t *)src;
  11990.          int16_t r;
  11991.          int16_t g;
  11992.          r = ((int16_t)(value << 8) ) >> 8;
  11993.          g = ((int16_t)(value) ) >> 8;
  11994.          dst[0] = (int)r; /* r */
  11995.          dst[1] = (int)g; /* g */
  11996.          dst[2] = 0; /* b */
  11997.          dst[3] = 1; /* a */
  11998.          src += 2;
  11999.          dst += 4;
  12000.       }
  12001.       src_row += src_stride;
  12002.       dst_row += dst_stride/sizeof(*dst_row);
  12003.    }
  12004. }
  12005.  
  12006. static INLINE void
  12007. util_format_r8g8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12008. {
  12009.    unsigned x, y;
  12010.    for(y = 0; y < height; y += 1) {
  12011.       const int *src = src_row;
  12012.       uint8_t *dst = dst_row;
  12013.       for(x = 0; x < width; x += 1) {
  12014.          uint16_t value = 0;
  12015.          value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  12016.          value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ;
  12017.          *(uint16_t *)dst = value;
  12018.          src += 4;
  12019.          dst += 2;
  12020.       }
  12021.       dst_row += dst_stride;
  12022.       src_row += src_stride/sizeof(*src_row);
  12023.    }
  12024. }
  12025.  
  12026. static INLINE void
  12027. util_format_r8g8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  12028. {
  12029.          uint16_t value = *(const uint16_t *)src;
  12030.          int16_t r;
  12031.          int16_t g;
  12032.          r = ((int16_t)(value << 8) ) >> 8;
  12033.          g = ((int16_t)(value) ) >> 8;
  12034.          dst[0] = (int)r; /* r */
  12035.          dst[1] = (int)g; /* g */
  12036.          dst[2] = 0; /* b */
  12037.          dst[3] = 1; /* a */
  12038. }
  12039.  
  12040. static INLINE void
  12041. util_format_r8g8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12042. {
  12043.    unsigned x, y;
  12044.    for(y = 0; y < height; y += 1) {
  12045.       unsigned *dst = dst_row;
  12046.       const uint8_t *src = src_row;
  12047.       for(x = 0; x < width; x += 1) {
  12048.          uint16_t value = *(const uint16_t *)src;
  12049.          int16_t r;
  12050.          int16_t g;
  12051.          r = ((int16_t)(value << 8) ) >> 8;
  12052.          g = ((int16_t)(value) ) >> 8;
  12053.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  12054.          dst[1] = (unsigned)MAX2(g, 0); /* g */
  12055.          dst[2] = 0; /* b */
  12056.          dst[3] = 1; /* a */
  12057.          src += 2;
  12058.          dst += 4;
  12059.       }
  12060.       src_row += src_stride;
  12061.       dst_row += dst_stride/sizeof(*dst_row);
  12062.    }
  12063. }
  12064.  
  12065. static INLINE void
  12066. util_format_r8g8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12067. {
  12068.    unsigned x, y;
  12069.    for(y = 0; y < height; y += 1) {
  12070.       const unsigned *src = src_row;
  12071.       uint8_t *dst = dst_row;
  12072.       for(x = 0; x < width; x += 1) {
  12073.          uint16_t value = 0;
  12074.          value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
  12075.          value |= (uint16_t)(((int8_t)MIN2(src[1], 127)) << 8) ;
  12076.          *(uint16_t *)dst = value;
  12077.          src += 4;
  12078.          dst += 2;
  12079.       }
  12080.       dst_row += dst_stride;
  12081.       src_row += src_stride/sizeof(*src_row);
  12082.    }
  12083. }
  12084.  
  12085. union util_format_r8g8b8_sint {
  12086.    struct {
  12087.       int8_t r;
  12088.       int8_t g;
  12089.       int8_t b;
  12090.    } chan;
  12091. };
  12092.  
  12093. static INLINE void
  12094. util_format_r8g8b8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12095. {
  12096.    unsigned x, y;
  12097.    for(y = 0; y < height; y += 1) {
  12098.       int *dst = dst_row;
  12099.       const uint8_t *src = src_row;
  12100.       for(x = 0; x < width; x += 1) {
  12101.          union util_format_r8g8b8_sint pixel;
  12102.          memcpy(&pixel, src, sizeof pixel);
  12103.          dst[0] = (int)pixel.chan.r; /* r */
  12104.          dst[1] = (int)pixel.chan.g; /* g */
  12105.          dst[2] = (int)pixel.chan.b; /* b */
  12106.          dst[3] = 1; /* a */
  12107.          src += 3;
  12108.          dst += 4;
  12109.       }
  12110.       src_row += src_stride;
  12111.       dst_row += dst_stride/sizeof(*dst_row);
  12112.    }
  12113. }
  12114.  
  12115. static INLINE void
  12116. util_format_r8g8b8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12117. {
  12118.    unsigned x, y;
  12119.    for(y = 0; y < height; y += 1) {
  12120.       const int *src = src_row;
  12121.       uint8_t *dst = dst_row;
  12122.       for(x = 0; x < width; x += 1) {
  12123.          union util_format_r8g8b8_sint pixel;
  12124.          pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127);
  12125.          pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127);
  12126.          pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127);
  12127.          memcpy(dst, &pixel, sizeof pixel);
  12128.          src += 4;
  12129.          dst += 3;
  12130.       }
  12131.       dst_row += dst_stride;
  12132.       src_row += src_stride/sizeof(*src_row);
  12133.    }
  12134. }
  12135.  
  12136. static INLINE void
  12137. util_format_r8g8b8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  12138. {
  12139.          union util_format_r8g8b8_sint pixel;
  12140.          memcpy(&pixel, src, sizeof pixel);
  12141.          dst[0] = (int)pixel.chan.r; /* r */
  12142.          dst[1] = (int)pixel.chan.g; /* g */
  12143.          dst[2] = (int)pixel.chan.b; /* b */
  12144.          dst[3] = 1; /* a */
  12145. }
  12146.  
  12147. static INLINE void
  12148. util_format_r8g8b8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12149. {
  12150.    unsigned x, y;
  12151.    for(y = 0; y < height; y += 1) {
  12152.       unsigned *dst = dst_row;
  12153.       const uint8_t *src = src_row;
  12154.       for(x = 0; x < width; x += 1) {
  12155.          union util_format_r8g8b8_sint pixel;
  12156.          memcpy(&pixel, src, sizeof pixel);
  12157.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  12158.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  12159.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  12160.          dst[3] = 1; /* a */
  12161.          src += 3;
  12162.          dst += 4;
  12163.       }
  12164.       src_row += src_stride;
  12165.       dst_row += dst_stride/sizeof(*dst_row);
  12166.    }
  12167. }
  12168.  
  12169. static INLINE void
  12170. util_format_r8g8b8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12171. {
  12172.    unsigned x, y;
  12173.    for(y = 0; y < height; y += 1) {
  12174.       const unsigned *src = src_row;
  12175.       uint8_t *dst = dst_row;
  12176.       for(x = 0; x < width; x += 1) {
  12177.          union util_format_r8g8b8_sint pixel;
  12178.          pixel.chan.r = (int8_t)MIN2(src[0], 127);
  12179.          pixel.chan.g = (int8_t)MIN2(src[1], 127);
  12180.          pixel.chan.b = (int8_t)MIN2(src[2], 127);
  12181.          memcpy(dst, &pixel, sizeof pixel);
  12182.          src += 4;
  12183.          dst += 3;
  12184.       }
  12185.       dst_row += dst_stride;
  12186.       src_row += src_stride/sizeof(*src_row);
  12187.    }
  12188. }
  12189.  
  12190. union util_format_r8g8b8a8_sint {
  12191.    uint32_t value;
  12192.    struct {
  12193.       int8_t r;
  12194.       int8_t g;
  12195.       int8_t b;
  12196.       int8_t a;
  12197.    } chan;
  12198. };
  12199.  
  12200. static INLINE void
  12201. util_format_r8g8b8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12202. {
  12203.    unsigned x, y;
  12204.    for(y = 0; y < height; y += 1) {
  12205.       int *dst = dst_row;
  12206.       const uint8_t *src = src_row;
  12207.       for(x = 0; x < width; x += 1) {
  12208.          uint32_t value = *(const uint32_t *)src;
  12209.          int32_t r;
  12210.          int32_t g;
  12211.          int32_t b;
  12212.          int32_t a;
  12213.          r = ((int32_t)(value << 24) ) >> 24;
  12214.          g = ((int32_t)(value << 16) ) >> 24;
  12215.          b = ((int32_t)(value << 8) ) >> 24;
  12216.          a = ((int32_t)(value) ) >> 24;
  12217.          dst[0] = (int)r; /* r */
  12218.          dst[1] = (int)g; /* g */
  12219.          dst[2] = (int)b; /* b */
  12220.          dst[3] = (int)a; /* a */
  12221.          src += 4;
  12222.          dst += 4;
  12223.       }
  12224.       src_row += src_stride;
  12225.       dst_row += dst_stride/sizeof(*dst_row);
  12226.    }
  12227. }
  12228.  
  12229. static INLINE void
  12230. util_format_r8g8b8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12231. {
  12232.    unsigned x, y;
  12233.    for(y = 0; y < height; y += 1) {
  12234.       const int *src = src_row;
  12235.       uint8_t *dst = dst_row;
  12236.       for(x = 0; x < width; x += 1) {
  12237.          uint32_t value = 0;
  12238.          value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  12239.          value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
  12240.          value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
  12241.          value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ;
  12242.          *(uint32_t *)dst = value;
  12243.          src += 4;
  12244.          dst += 4;
  12245.       }
  12246.       dst_row += dst_stride;
  12247.       src_row += src_stride/sizeof(*src_row);
  12248.    }
  12249. }
  12250.  
  12251. static INLINE void
  12252. util_format_r8g8b8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  12253. {
  12254.          uint32_t value = *(const uint32_t *)src;
  12255.          int32_t r;
  12256.          int32_t g;
  12257.          int32_t b;
  12258.          int32_t a;
  12259.          r = ((int32_t)(value << 24) ) >> 24;
  12260.          g = ((int32_t)(value << 16) ) >> 24;
  12261.          b = ((int32_t)(value << 8) ) >> 24;
  12262.          a = ((int32_t)(value) ) >> 24;
  12263.          dst[0] = (int)r; /* r */
  12264.          dst[1] = (int)g; /* g */
  12265.          dst[2] = (int)b; /* b */
  12266.          dst[3] = (int)a; /* a */
  12267. }
  12268.  
  12269. static INLINE void
  12270. util_format_r8g8b8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12271. {
  12272.    unsigned x, y;
  12273.    for(y = 0; y < height; y += 1) {
  12274.       unsigned *dst = dst_row;
  12275.       const uint8_t *src = src_row;
  12276.       for(x = 0; x < width; x += 1) {
  12277.          uint32_t value = *(const uint32_t *)src;
  12278.          int32_t r;
  12279.          int32_t g;
  12280.          int32_t b;
  12281.          int32_t a;
  12282.          r = ((int32_t)(value << 24) ) >> 24;
  12283.          g = ((int32_t)(value << 16) ) >> 24;
  12284.          b = ((int32_t)(value << 8) ) >> 24;
  12285.          a = ((int32_t)(value) ) >> 24;
  12286.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  12287.          dst[1] = (unsigned)MAX2(g, 0); /* g */
  12288.          dst[2] = (unsigned)MAX2(b, 0); /* b */
  12289.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  12290.          src += 4;
  12291.          dst += 4;
  12292.       }
  12293.       src_row += src_stride;
  12294.       dst_row += dst_stride/sizeof(*dst_row);
  12295.    }
  12296. }
  12297.  
  12298. static INLINE void
  12299. util_format_r8g8b8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12300. {
  12301.    unsigned x, y;
  12302.    for(y = 0; y < height; y += 1) {
  12303.       const unsigned *src = src_row;
  12304.       uint8_t *dst = dst_row;
  12305.       for(x = 0; x < width; x += 1) {
  12306.          uint32_t value = 0;
  12307.          value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
  12308.          value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ;
  12309.          value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ;
  12310.          value |= (uint32_t)(((int8_t)MIN2(src[3], 127)) << 24) ;
  12311.          *(uint32_t *)dst = value;
  12312.          src += 4;
  12313.          dst += 4;
  12314.       }
  12315.       dst_row += dst_stride;
  12316.       src_row += src_stride/sizeof(*src_row);
  12317.    }
  12318. }
  12319.  
  12320. union util_format_r16_uint {
  12321.    uint16_t value;
  12322.    struct {
  12323.       uint16_t r;
  12324.    } chan;
  12325. };
  12326.  
  12327. static INLINE void
  12328. util_format_r16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12329. {
  12330.    unsigned x, y;
  12331.    for(y = 0; y < height; y += 1) {
  12332.       unsigned *dst = dst_row;
  12333.       const uint8_t *src = src_row;
  12334.       for(x = 0; x < width; x += 1) {
  12335.          uint16_t value = *(const uint16_t *)src;
  12336.          uint16_t r;
  12337.          r = value;
  12338.          dst[0] = (unsigned)r; /* r */
  12339.          dst[1] = 0; /* g */
  12340.          dst[2] = 0; /* b */
  12341.          dst[3] = 1; /* a */
  12342.          src += 2;
  12343.          dst += 4;
  12344.       }
  12345.       src_row += src_stride;
  12346.       dst_row += dst_stride/sizeof(*dst_row);
  12347.    }
  12348. }
  12349.  
  12350. static INLINE void
  12351. util_format_r16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12352. {
  12353.    unsigned x, y;
  12354.    for(y = 0; y < height; y += 1) {
  12355.       const unsigned *src = src_row;
  12356.       uint8_t *dst = dst_row;
  12357.       for(x = 0; x < width; x += 1) {
  12358.          uint16_t value = 0;
  12359.          value |= (uint16_t)MIN2(src[0], 65535);
  12360.          *(uint16_t *)dst = value;
  12361.          src += 4;
  12362.          dst += 2;
  12363.       }
  12364.       dst_row += dst_stride;
  12365.       src_row += src_stride/sizeof(*src_row);
  12366.    }
  12367. }
  12368.  
  12369. static INLINE void
  12370. util_format_r16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  12371. {
  12372.          uint16_t value = *(const uint16_t *)src;
  12373.          uint16_t r;
  12374.          r = value;
  12375.          dst[0] = (unsigned)r; /* r */
  12376.          dst[1] = 0; /* g */
  12377.          dst[2] = 0; /* b */
  12378.          dst[3] = 1; /* a */
  12379. }
  12380.  
  12381. static INLINE void
  12382. util_format_r16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12383. {
  12384.    unsigned x, y;
  12385.    for(y = 0; y < height; y += 1) {
  12386.       int *dst = dst_row;
  12387.       const uint8_t *src = src_row;
  12388.       for(x = 0; x < width; x += 1) {
  12389.          uint16_t value = *(const uint16_t *)src;
  12390.          uint16_t r;
  12391.          r = value;
  12392.          dst[0] = (int)r; /* r */
  12393.          dst[1] = 0; /* g */
  12394.          dst[2] = 0; /* b */
  12395.          dst[3] = 1; /* a */
  12396.          src += 2;
  12397.          dst += 4;
  12398.       }
  12399.       src_row += src_stride;
  12400.       dst_row += dst_stride/sizeof(*dst_row);
  12401.    }
  12402. }
  12403.  
  12404. static INLINE void
  12405. util_format_r16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12406. {
  12407.    unsigned x, y;
  12408.    for(y = 0; y < height; y += 1) {
  12409.       const int *src = src_row;
  12410.       uint8_t *dst = dst_row;
  12411.       for(x = 0; x < width; x += 1) {
  12412.          uint16_t value = 0;
  12413.          value |= (uint16_t)CLAMP(src[0], 0, 65535);
  12414.          *(uint16_t *)dst = value;
  12415.          src += 4;
  12416.          dst += 2;
  12417.       }
  12418.       dst_row += dst_stride;
  12419.       src_row += src_stride/sizeof(*src_row);
  12420.    }
  12421. }
  12422.  
  12423. union util_format_r16g16_uint {
  12424.    uint32_t value;
  12425.    struct {
  12426.       uint16_t r;
  12427.       uint16_t g;
  12428.    } chan;
  12429. };
  12430.  
  12431. static INLINE void
  12432. util_format_r16g16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12433. {
  12434.    unsigned x, y;
  12435.    for(y = 0; y < height; y += 1) {
  12436.       unsigned *dst = dst_row;
  12437.       const uint8_t *src = src_row;
  12438.       for(x = 0; x < width; x += 1) {
  12439.          uint32_t value = *(const uint32_t *)src;
  12440.          uint32_t r;
  12441.          uint32_t g;
  12442.          r = (value) & 0xffff;
  12443.          g = value >> 16;
  12444.          dst[0] = (unsigned)r; /* r */
  12445.          dst[1] = (unsigned)g; /* g */
  12446.          dst[2] = 0; /* b */
  12447.          dst[3] = 1; /* a */
  12448.          src += 4;
  12449.          dst += 4;
  12450.       }
  12451.       src_row += src_stride;
  12452.       dst_row += dst_stride/sizeof(*dst_row);
  12453.    }
  12454. }
  12455.  
  12456. static INLINE void
  12457. util_format_r16g16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12458. {
  12459.    unsigned x, y;
  12460.    for(y = 0; y < height; y += 1) {
  12461.       const unsigned *src = src_row;
  12462.       uint8_t *dst = dst_row;
  12463.       for(x = 0; x < width; x += 1) {
  12464.          uint32_t value = 0;
  12465.          value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
  12466.          value |= ((uint16_t)MIN2(src[1], 65535)) << 16;
  12467.          *(uint32_t *)dst = value;
  12468.          src += 4;
  12469.          dst += 4;
  12470.       }
  12471.       dst_row += dst_stride;
  12472.       src_row += src_stride/sizeof(*src_row);
  12473.    }
  12474. }
  12475.  
  12476. static INLINE void
  12477. util_format_r16g16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  12478. {
  12479.          uint32_t value = *(const uint32_t *)src;
  12480.          uint32_t r;
  12481.          uint32_t g;
  12482.          r = (value) & 0xffff;
  12483.          g = value >> 16;
  12484.          dst[0] = (unsigned)r; /* r */
  12485.          dst[1] = (unsigned)g; /* g */
  12486.          dst[2] = 0; /* b */
  12487.          dst[3] = 1; /* a */
  12488. }
  12489.  
  12490. static INLINE void
  12491. util_format_r16g16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12492. {
  12493.    unsigned x, y;
  12494.    for(y = 0; y < height; y += 1) {
  12495.       int *dst = dst_row;
  12496.       const uint8_t *src = src_row;
  12497.       for(x = 0; x < width; x += 1) {
  12498.          uint32_t value = *(const uint32_t *)src;
  12499.          uint32_t r;
  12500.          uint32_t g;
  12501.          r = (value) & 0xffff;
  12502.          g = value >> 16;
  12503.          dst[0] = (int)r; /* r */
  12504.          dst[1] = (int)g; /* g */
  12505.          dst[2] = 0; /* b */
  12506.          dst[3] = 1; /* a */
  12507.          src += 4;
  12508.          dst += 4;
  12509.       }
  12510.       src_row += src_stride;
  12511.       dst_row += dst_stride/sizeof(*dst_row);
  12512.    }
  12513. }
  12514.  
  12515. static INLINE void
  12516. util_format_r16g16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12517. {
  12518.    unsigned x, y;
  12519.    for(y = 0; y < height; y += 1) {
  12520.       const int *src = src_row;
  12521.       uint8_t *dst = dst_row;
  12522.       for(x = 0; x < width; x += 1) {
  12523.          uint32_t value = 0;
  12524.          value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
  12525.          value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16;
  12526.          *(uint32_t *)dst = value;
  12527.          src += 4;
  12528.          dst += 4;
  12529.       }
  12530.       dst_row += dst_stride;
  12531.       src_row += src_stride/sizeof(*src_row);
  12532.    }
  12533. }
  12534.  
  12535. union util_format_r16g16b16_uint {
  12536.    struct {
  12537.       uint16_t r;
  12538.       uint16_t g;
  12539.       uint16_t b;
  12540.    } chan;
  12541. };
  12542.  
  12543. static INLINE void
  12544. util_format_r16g16b16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12545. {
  12546.    unsigned x, y;
  12547.    for(y = 0; y < height; y += 1) {
  12548.       unsigned *dst = dst_row;
  12549.       const uint8_t *src = src_row;
  12550.       for(x = 0; x < width; x += 1) {
  12551.          union util_format_r16g16b16_uint pixel;
  12552.          memcpy(&pixel, src, sizeof pixel);
  12553.          dst[0] = (unsigned)pixel.chan.r; /* r */
  12554.          dst[1] = (unsigned)pixel.chan.g; /* g */
  12555.          dst[2] = (unsigned)pixel.chan.b; /* b */
  12556.          dst[3] = 1; /* a */
  12557.          src += 6;
  12558.          dst += 4;
  12559.       }
  12560.       src_row += src_stride;
  12561.       dst_row += dst_stride/sizeof(*dst_row);
  12562.    }
  12563. }
  12564.  
  12565. static INLINE void
  12566. util_format_r16g16b16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12567. {
  12568.    unsigned x, y;
  12569.    for(y = 0; y < height; y += 1) {
  12570.       const unsigned *src = src_row;
  12571.       uint8_t *dst = dst_row;
  12572.       for(x = 0; x < width; x += 1) {
  12573.          union util_format_r16g16b16_uint pixel;
  12574.          pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
  12575.          pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
  12576.          pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
  12577.          memcpy(dst, &pixel, sizeof pixel);
  12578.          src += 4;
  12579.          dst += 6;
  12580.       }
  12581.       dst_row += dst_stride;
  12582.       src_row += src_stride/sizeof(*src_row);
  12583.    }
  12584. }
  12585.  
  12586. static INLINE void
  12587. util_format_r16g16b16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  12588. {
  12589.          union util_format_r16g16b16_uint pixel;
  12590.          memcpy(&pixel, src, sizeof pixel);
  12591.          dst[0] = (unsigned)pixel.chan.r; /* r */
  12592.          dst[1] = (unsigned)pixel.chan.g; /* g */
  12593.          dst[2] = (unsigned)pixel.chan.b; /* b */
  12594.          dst[3] = 1; /* a */
  12595. }
  12596.  
  12597. static INLINE void
  12598. util_format_r16g16b16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12599. {
  12600.    unsigned x, y;
  12601.    for(y = 0; y < height; y += 1) {
  12602.       int *dst = dst_row;
  12603.       const uint8_t *src = src_row;
  12604.       for(x = 0; x < width; x += 1) {
  12605.          union util_format_r16g16b16_uint pixel;
  12606.          memcpy(&pixel, src, sizeof pixel);
  12607.          dst[0] = (int)pixel.chan.r; /* r */
  12608.          dst[1] = (int)pixel.chan.g; /* g */
  12609.          dst[2] = (int)pixel.chan.b; /* b */
  12610.          dst[3] = 1; /* a */
  12611.          src += 6;
  12612.          dst += 4;
  12613.       }
  12614.       src_row += src_stride;
  12615.       dst_row += dst_stride/sizeof(*dst_row);
  12616.    }
  12617. }
  12618.  
  12619. static INLINE void
  12620. util_format_r16g16b16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12621. {
  12622.    unsigned x, y;
  12623.    for(y = 0; y < height; y += 1) {
  12624.       const int *src = src_row;
  12625.       uint8_t *dst = dst_row;
  12626.       for(x = 0; x < width; x += 1) {
  12627.          union util_format_r16g16b16_uint pixel;
  12628.          pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
  12629.          pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
  12630.          pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
  12631.          memcpy(dst, &pixel, sizeof pixel);
  12632.          src += 4;
  12633.          dst += 6;
  12634.       }
  12635.       dst_row += dst_stride;
  12636.       src_row += src_stride/sizeof(*src_row);
  12637.    }
  12638. }
  12639.  
  12640. union util_format_r16g16b16a16_uint {
  12641.    uint64_t value;
  12642.    struct {
  12643.       uint16_t r;
  12644.       uint16_t g;
  12645.       uint16_t b;
  12646.       uint16_t a;
  12647.    } chan;
  12648. };
  12649.  
  12650. static INLINE void
  12651. util_format_r16g16b16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12652. {
  12653.    unsigned x, y;
  12654.    for(y = 0; y < height; y += 1) {
  12655.       unsigned *dst = dst_row;
  12656.       const uint8_t *src = src_row;
  12657.       for(x = 0; x < width; x += 1) {
  12658.          union util_format_r16g16b16a16_uint pixel;
  12659.          memcpy(&pixel, src, sizeof pixel);
  12660.          dst[0] = (unsigned)pixel.chan.r; /* r */
  12661.          dst[1] = (unsigned)pixel.chan.g; /* g */
  12662.          dst[2] = (unsigned)pixel.chan.b; /* b */
  12663.          dst[3] = (unsigned)pixel.chan.a; /* a */
  12664.          src += 8;
  12665.          dst += 4;
  12666.       }
  12667.       src_row += src_stride;
  12668.       dst_row += dst_stride/sizeof(*dst_row);
  12669.    }
  12670. }
  12671.  
  12672. static INLINE void
  12673. util_format_r16g16b16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12674. {
  12675.    unsigned x, y;
  12676.    for(y = 0; y < height; y += 1) {
  12677.       const unsigned *src = src_row;
  12678.       uint8_t *dst = dst_row;
  12679.       for(x = 0; x < width; x += 1) {
  12680.          union util_format_r16g16b16a16_uint pixel;
  12681.          pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
  12682.          pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
  12683.          pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
  12684.          pixel.chan.a = (uint16_t)MIN2(src[3], 65535);
  12685.          memcpy(dst, &pixel, sizeof pixel);
  12686.          src += 4;
  12687.          dst += 8;
  12688.       }
  12689.       dst_row += dst_stride;
  12690.       src_row += src_stride/sizeof(*src_row);
  12691.    }
  12692. }
  12693.  
  12694. static INLINE void
  12695. util_format_r16g16b16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  12696. {
  12697.          union util_format_r16g16b16a16_uint pixel;
  12698.          memcpy(&pixel, src, sizeof pixel);
  12699.          dst[0] = (unsigned)pixel.chan.r; /* r */
  12700.          dst[1] = (unsigned)pixel.chan.g; /* g */
  12701.          dst[2] = (unsigned)pixel.chan.b; /* b */
  12702.          dst[3] = (unsigned)pixel.chan.a; /* a */
  12703. }
  12704.  
  12705. static INLINE void
  12706. util_format_r16g16b16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12707. {
  12708.    unsigned x, y;
  12709.    for(y = 0; y < height; y += 1) {
  12710.       int *dst = dst_row;
  12711.       const uint8_t *src = src_row;
  12712.       for(x = 0; x < width; x += 1) {
  12713.          union util_format_r16g16b16a16_uint pixel;
  12714.          memcpy(&pixel, src, sizeof pixel);
  12715.          dst[0] = (int)pixel.chan.r; /* r */
  12716.          dst[1] = (int)pixel.chan.g; /* g */
  12717.          dst[2] = (int)pixel.chan.b; /* b */
  12718.          dst[3] = (int)pixel.chan.a; /* a */
  12719.          src += 8;
  12720.          dst += 4;
  12721.       }
  12722.       src_row += src_stride;
  12723.       dst_row += dst_stride/sizeof(*dst_row);
  12724.    }
  12725. }
  12726.  
  12727. static INLINE void
  12728. util_format_r16g16b16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12729. {
  12730.    unsigned x, y;
  12731.    for(y = 0; y < height; y += 1) {
  12732.       const int *src = src_row;
  12733.       uint8_t *dst = dst_row;
  12734.       for(x = 0; x < width; x += 1) {
  12735.          union util_format_r16g16b16a16_uint pixel;
  12736.          pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
  12737.          pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
  12738.          pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
  12739.          pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535);
  12740.          memcpy(dst, &pixel, sizeof pixel);
  12741.          src += 4;
  12742.          dst += 8;
  12743.       }
  12744.       dst_row += dst_stride;
  12745.       src_row += src_stride/sizeof(*src_row);
  12746.    }
  12747. }
  12748.  
  12749. union util_format_r16_sint {
  12750.    uint16_t value;
  12751.    struct {
  12752.       int16_t r;
  12753.    } chan;
  12754. };
  12755.  
  12756. static INLINE void
  12757. util_format_r16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12758. {
  12759.    unsigned x, y;
  12760.    for(y = 0; y < height; y += 1) {
  12761.       int *dst = dst_row;
  12762.       const uint8_t *src = src_row;
  12763.       for(x = 0; x < width; x += 1) {
  12764.          uint16_t value = *(const uint16_t *)src;
  12765.          int16_t r;
  12766.          r = (int16_t)(value) ;
  12767.          dst[0] = (int)r; /* r */
  12768.          dst[1] = 0; /* g */
  12769.          dst[2] = 0; /* b */
  12770.          dst[3] = 1; /* a */
  12771.          src += 2;
  12772.          dst += 4;
  12773.       }
  12774.       src_row += src_stride;
  12775.       dst_row += dst_stride/sizeof(*dst_row);
  12776.    }
  12777. }
  12778.  
  12779. static INLINE void
  12780. util_format_r16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12781. {
  12782.    unsigned x, y;
  12783.    for(y = 0; y < height; y += 1) {
  12784.       const int *src = src_row;
  12785.       uint8_t *dst = dst_row;
  12786.       for(x = 0; x < width; x += 1) {
  12787.          uint16_t value = 0;
  12788.          value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
  12789.          *(uint16_t *)dst = value;
  12790.          src += 4;
  12791.          dst += 2;
  12792.       }
  12793.       dst_row += dst_stride;
  12794.       src_row += src_stride/sizeof(*src_row);
  12795.    }
  12796. }
  12797.  
  12798. static INLINE void
  12799. util_format_r16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  12800. {
  12801.          uint16_t value = *(const uint16_t *)src;
  12802.          int16_t r;
  12803.          r = (int16_t)(value) ;
  12804.          dst[0] = (int)r; /* r */
  12805.          dst[1] = 0; /* g */
  12806.          dst[2] = 0; /* b */
  12807.          dst[3] = 1; /* a */
  12808. }
  12809.  
  12810. static INLINE void
  12811. util_format_r16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12812. {
  12813.    unsigned x, y;
  12814.    for(y = 0; y < height; y += 1) {
  12815.       unsigned *dst = dst_row;
  12816.       const uint8_t *src = src_row;
  12817.       for(x = 0; x < width; x += 1) {
  12818.          uint16_t value = *(const uint16_t *)src;
  12819.          int16_t r;
  12820.          r = (int16_t)(value) ;
  12821.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  12822.          dst[1] = 0; /* g */
  12823.          dst[2] = 0; /* b */
  12824.          dst[3] = 1; /* a */
  12825.          src += 2;
  12826.          dst += 4;
  12827.       }
  12828.       src_row += src_stride;
  12829.       dst_row += dst_stride/sizeof(*dst_row);
  12830.    }
  12831. }
  12832.  
  12833. static INLINE void
  12834. util_format_r16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12835. {
  12836.    unsigned x, y;
  12837.    for(y = 0; y < height; y += 1) {
  12838.       const unsigned *src = src_row;
  12839.       uint8_t *dst = dst_row;
  12840.       for(x = 0; x < width; x += 1) {
  12841.          uint16_t value = 0;
  12842.          value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
  12843.          *(uint16_t *)dst = value;
  12844.          src += 4;
  12845.          dst += 2;
  12846.       }
  12847.       dst_row += dst_stride;
  12848.       src_row += src_stride/sizeof(*src_row);
  12849.    }
  12850. }
  12851.  
  12852. union util_format_r16g16_sint {
  12853.    uint32_t value;
  12854.    struct {
  12855.       int16_t r;
  12856.       int16_t g;
  12857.    } chan;
  12858. };
  12859.  
  12860. static INLINE void
  12861. util_format_r16g16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12862. {
  12863.    unsigned x, y;
  12864.    for(y = 0; y < height; y += 1) {
  12865.       int *dst = dst_row;
  12866.       const uint8_t *src = src_row;
  12867.       for(x = 0; x < width; x += 1) {
  12868.          uint32_t value = *(const uint32_t *)src;
  12869.          int32_t r;
  12870.          int32_t g;
  12871.          r = ((int32_t)(value << 16) ) >> 16;
  12872.          g = ((int32_t)(value) ) >> 16;
  12873.          dst[0] = (int)r; /* r */
  12874.          dst[1] = (int)g; /* g */
  12875.          dst[2] = 0; /* b */
  12876.          dst[3] = 1; /* a */
  12877.          src += 4;
  12878.          dst += 4;
  12879.       }
  12880.       src_row += src_stride;
  12881.       dst_row += dst_stride/sizeof(*dst_row);
  12882.    }
  12883. }
  12884.  
  12885. static INLINE void
  12886. util_format_r16g16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12887. {
  12888.    unsigned x, y;
  12889.    for(y = 0; y < height; y += 1) {
  12890.       const int *src = src_row;
  12891.       uint8_t *dst = dst_row;
  12892.       for(x = 0; x < width; x += 1) {
  12893.          uint32_t value = 0;
  12894.          value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
  12895.          value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ;
  12896.          *(uint32_t *)dst = value;
  12897.          src += 4;
  12898.          dst += 4;
  12899.       }
  12900.       dst_row += dst_stride;
  12901.       src_row += src_stride/sizeof(*src_row);
  12902.    }
  12903. }
  12904.  
  12905. static INLINE void
  12906. util_format_r16g16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  12907. {
  12908.          uint32_t value = *(const uint32_t *)src;
  12909.          int32_t r;
  12910.          int32_t g;
  12911.          r = ((int32_t)(value << 16) ) >> 16;
  12912.          g = ((int32_t)(value) ) >> 16;
  12913.          dst[0] = (int)r; /* r */
  12914.          dst[1] = (int)g; /* g */
  12915.          dst[2] = 0; /* b */
  12916.          dst[3] = 1; /* a */
  12917. }
  12918.  
  12919. static INLINE void
  12920. util_format_r16g16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12921. {
  12922.    unsigned x, y;
  12923.    for(y = 0; y < height; y += 1) {
  12924.       unsigned *dst = dst_row;
  12925.       const uint8_t *src = src_row;
  12926.       for(x = 0; x < width; x += 1) {
  12927.          uint32_t value = *(const uint32_t *)src;
  12928.          int32_t r;
  12929.          int32_t g;
  12930.          r = ((int32_t)(value << 16) ) >> 16;
  12931.          g = ((int32_t)(value) ) >> 16;
  12932.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  12933.          dst[1] = (unsigned)MAX2(g, 0); /* g */
  12934.          dst[2] = 0; /* b */
  12935.          dst[3] = 1; /* a */
  12936.          src += 4;
  12937.          dst += 4;
  12938.       }
  12939.       src_row += src_stride;
  12940.       dst_row += dst_stride/sizeof(*dst_row);
  12941.    }
  12942. }
  12943.  
  12944. static INLINE void
  12945. util_format_r16g16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  12946. {
  12947.    unsigned x, y;
  12948.    for(y = 0; y < height; y += 1) {
  12949.       const unsigned *src = src_row;
  12950.       uint8_t *dst = dst_row;
  12951.       for(x = 0; x < width; x += 1) {
  12952.          uint32_t value = 0;
  12953.          value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
  12954.          value |= (uint32_t)(((int16_t)MIN2(src[1], 32767)) << 16) ;
  12955.          *(uint32_t *)dst = value;
  12956.          src += 4;
  12957.          dst += 4;
  12958.       }
  12959.       dst_row += dst_stride;
  12960.       src_row += src_stride/sizeof(*src_row);
  12961.    }
  12962. }
  12963.  
  12964. union util_format_r16g16b16_sint {
  12965.    struct {
  12966.       int16_t r;
  12967.       int16_t g;
  12968.       int16_t b;
  12969.    } chan;
  12970. };
  12971.  
  12972. static INLINE void
  12973. util_format_r16g16b16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  12974. {
  12975.    unsigned x, y;
  12976.    for(y = 0; y < height; y += 1) {
  12977.       int *dst = dst_row;
  12978.       const uint8_t *src = src_row;
  12979.       for(x = 0; x < width; x += 1) {
  12980.          union util_format_r16g16b16_sint pixel;
  12981.          memcpy(&pixel, src, sizeof pixel);
  12982.          dst[0] = (int)pixel.chan.r; /* r */
  12983.          dst[1] = (int)pixel.chan.g; /* g */
  12984.          dst[2] = (int)pixel.chan.b; /* b */
  12985.          dst[3] = 1; /* a */
  12986.          src += 6;
  12987.          dst += 4;
  12988.       }
  12989.       src_row += src_stride;
  12990.       dst_row += dst_stride/sizeof(*dst_row);
  12991.    }
  12992. }
  12993.  
  12994. static INLINE void
  12995. util_format_r16g16b16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  12996. {
  12997.    unsigned x, y;
  12998.    for(y = 0; y < height; y += 1) {
  12999.       const int *src = src_row;
  13000.       uint8_t *dst = dst_row;
  13001.       for(x = 0; x < width; x += 1) {
  13002.          union util_format_r16g16b16_sint pixel;
  13003.          pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
  13004.          pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
  13005.          pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
  13006.          memcpy(dst, &pixel, sizeof pixel);
  13007.          src += 4;
  13008.          dst += 6;
  13009.       }
  13010.       dst_row += dst_stride;
  13011.       src_row += src_stride/sizeof(*src_row);
  13012.    }
  13013. }
  13014.  
  13015. static INLINE void
  13016. util_format_r16g16b16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13017. {
  13018.          union util_format_r16g16b16_sint pixel;
  13019.          memcpy(&pixel, src, sizeof pixel);
  13020.          dst[0] = (int)pixel.chan.r; /* r */
  13021.          dst[1] = (int)pixel.chan.g; /* g */
  13022.          dst[2] = (int)pixel.chan.b; /* b */
  13023.          dst[3] = 1; /* a */
  13024. }
  13025.  
  13026. static INLINE void
  13027. util_format_r16g16b16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13028. {
  13029.    unsigned x, y;
  13030.    for(y = 0; y < height; y += 1) {
  13031.       unsigned *dst = dst_row;
  13032.       const uint8_t *src = src_row;
  13033.       for(x = 0; x < width; x += 1) {
  13034.          union util_format_r16g16b16_sint pixel;
  13035.          memcpy(&pixel, src, sizeof pixel);
  13036.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  13037.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  13038.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  13039.          dst[3] = 1; /* a */
  13040.          src += 6;
  13041.          dst += 4;
  13042.       }
  13043.       src_row += src_stride;
  13044.       dst_row += dst_stride/sizeof(*dst_row);
  13045.    }
  13046. }
  13047.  
  13048. static INLINE void
  13049. util_format_r16g16b16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13050. {
  13051.    unsigned x, y;
  13052.    for(y = 0; y < height; y += 1) {
  13053.       const unsigned *src = src_row;
  13054.       uint8_t *dst = dst_row;
  13055.       for(x = 0; x < width; x += 1) {
  13056.          union util_format_r16g16b16_sint pixel;
  13057.          pixel.chan.r = (int16_t)MIN2(src[0], 32767);
  13058.          pixel.chan.g = (int16_t)MIN2(src[1], 32767);
  13059.          pixel.chan.b = (int16_t)MIN2(src[2], 32767);
  13060.          memcpy(dst, &pixel, sizeof pixel);
  13061.          src += 4;
  13062.          dst += 6;
  13063.       }
  13064.       dst_row += dst_stride;
  13065.       src_row += src_stride/sizeof(*src_row);
  13066.    }
  13067. }
  13068.  
  13069. union util_format_r16g16b16a16_sint {
  13070.    uint64_t value;
  13071.    struct {
  13072.       int16_t r;
  13073.       int16_t g;
  13074.       int16_t b;
  13075.       int16_t a;
  13076.    } chan;
  13077. };
  13078.  
  13079. static INLINE void
  13080. util_format_r16g16b16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13081. {
  13082.    unsigned x, y;
  13083.    for(y = 0; y < height; y += 1) {
  13084.       int *dst = dst_row;
  13085.       const uint8_t *src = src_row;
  13086.       for(x = 0; x < width; x += 1) {
  13087.          union util_format_r16g16b16a16_sint pixel;
  13088.          memcpy(&pixel, src, sizeof pixel);
  13089.          dst[0] = (int)pixel.chan.r; /* r */
  13090.          dst[1] = (int)pixel.chan.g; /* g */
  13091.          dst[2] = (int)pixel.chan.b; /* b */
  13092.          dst[3] = (int)pixel.chan.a; /* a */
  13093.          src += 8;
  13094.          dst += 4;
  13095.       }
  13096.       src_row += src_stride;
  13097.       dst_row += dst_stride/sizeof(*dst_row);
  13098.    }
  13099. }
  13100.  
  13101. static INLINE void
  13102. util_format_r16g16b16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13103. {
  13104.    unsigned x, y;
  13105.    for(y = 0; y < height; y += 1) {
  13106.       const int *src = src_row;
  13107.       uint8_t *dst = dst_row;
  13108.       for(x = 0; x < width; x += 1) {
  13109.          union util_format_r16g16b16a16_sint pixel;
  13110.          pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
  13111.          pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
  13112.          pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
  13113.          pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767);
  13114.          memcpy(dst, &pixel, sizeof pixel);
  13115.          src += 4;
  13116.          dst += 8;
  13117.       }
  13118.       dst_row += dst_stride;
  13119.       src_row += src_stride/sizeof(*src_row);
  13120.    }
  13121. }
  13122.  
  13123. static INLINE void
  13124. util_format_r16g16b16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13125. {
  13126.          union util_format_r16g16b16a16_sint pixel;
  13127.          memcpy(&pixel, src, sizeof pixel);
  13128.          dst[0] = (int)pixel.chan.r; /* r */
  13129.          dst[1] = (int)pixel.chan.g; /* g */
  13130.          dst[2] = (int)pixel.chan.b; /* b */
  13131.          dst[3] = (int)pixel.chan.a; /* a */
  13132. }
  13133.  
  13134. static INLINE void
  13135. util_format_r16g16b16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13136. {
  13137.    unsigned x, y;
  13138.    for(y = 0; y < height; y += 1) {
  13139.       unsigned *dst = dst_row;
  13140.       const uint8_t *src = src_row;
  13141.       for(x = 0; x < width; x += 1) {
  13142.          union util_format_r16g16b16a16_sint pixel;
  13143.          memcpy(&pixel, src, sizeof pixel);
  13144.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  13145.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  13146.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  13147.          dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
  13148.          src += 8;
  13149.          dst += 4;
  13150.       }
  13151.       src_row += src_stride;
  13152.       dst_row += dst_stride/sizeof(*dst_row);
  13153.    }
  13154. }
  13155.  
  13156. static INLINE void
  13157. util_format_r16g16b16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13158. {
  13159.    unsigned x, y;
  13160.    for(y = 0; y < height; y += 1) {
  13161.       const unsigned *src = src_row;
  13162.       uint8_t *dst = dst_row;
  13163.       for(x = 0; x < width; x += 1) {
  13164.          union util_format_r16g16b16a16_sint pixel;
  13165.          pixel.chan.r = (int16_t)MIN2(src[0], 32767);
  13166.          pixel.chan.g = (int16_t)MIN2(src[1], 32767);
  13167.          pixel.chan.b = (int16_t)MIN2(src[2], 32767);
  13168.          pixel.chan.a = (int16_t)MIN2(src[3], 32767);
  13169.          memcpy(dst, &pixel, sizeof pixel);
  13170.          src += 4;
  13171.          dst += 8;
  13172.       }
  13173.       dst_row += dst_stride;
  13174.       src_row += src_stride/sizeof(*src_row);
  13175.    }
  13176. }
  13177.  
  13178. union util_format_r32_uint {
  13179.    uint32_t value;
  13180.    struct {
  13181.       uint32_t r;
  13182.    } chan;
  13183. };
  13184.  
  13185. static INLINE void
  13186. util_format_r32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13187. {
  13188.    unsigned x, y;
  13189.    for(y = 0; y < height; y += 1) {
  13190.       unsigned *dst = dst_row;
  13191.       const uint8_t *src = src_row;
  13192.       for(x = 0; x < width; x += 1) {
  13193.          uint32_t value = *(const uint32_t *)src;
  13194.          uint32_t r;
  13195.          r = value;
  13196.          dst[0] = r; /* r */
  13197.          dst[1] = 0; /* g */
  13198.          dst[2] = 0; /* b */
  13199.          dst[3] = 1; /* a */
  13200.          src += 4;
  13201.          dst += 4;
  13202.       }
  13203.       src_row += src_stride;
  13204.       dst_row += dst_stride/sizeof(*dst_row);
  13205.    }
  13206. }
  13207.  
  13208. static INLINE void
  13209. util_format_r32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13210. {
  13211.    unsigned x, y;
  13212.    for(y = 0; y < height; y += 1) {
  13213.       const unsigned *src = src_row;
  13214.       uint8_t *dst = dst_row;
  13215.       for(x = 0; x < width; x += 1) {
  13216.          uint32_t value = 0;
  13217.          value |= src[0];
  13218.          *(uint32_t *)dst = value;
  13219.          src += 4;
  13220.          dst += 4;
  13221.       }
  13222.       dst_row += dst_stride;
  13223.       src_row += src_stride/sizeof(*src_row);
  13224.    }
  13225. }
  13226.  
  13227. static INLINE void
  13228. util_format_r32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  13229. {
  13230.          uint32_t value = *(const uint32_t *)src;
  13231.          uint32_t r;
  13232.          r = value;
  13233.          dst[0] = r; /* r */
  13234.          dst[1] = 0; /* g */
  13235.          dst[2] = 0; /* b */
  13236.          dst[3] = 1; /* a */
  13237. }
  13238.  
  13239. static INLINE void
  13240. util_format_r32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13241. {
  13242.    unsigned x, y;
  13243.    for(y = 0; y < height; y += 1) {
  13244.       int *dst = dst_row;
  13245.       const uint8_t *src = src_row;
  13246.       for(x = 0; x < width; x += 1) {
  13247.          uint32_t value = *(const uint32_t *)src;
  13248.          uint32_t r;
  13249.          r = value;
  13250.          dst[0] = (int)MIN2(r, 2147483647); /* r */
  13251.          dst[1] = 0; /* g */
  13252.          dst[2] = 0; /* b */
  13253.          dst[3] = 1; /* a */
  13254.          src += 4;
  13255.          dst += 4;
  13256.       }
  13257.       src_row += src_stride;
  13258.       dst_row += dst_stride/sizeof(*dst_row);
  13259.    }
  13260. }
  13261.  
  13262. static INLINE void
  13263. util_format_r32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13264. {
  13265.    unsigned x, y;
  13266.    for(y = 0; y < height; y += 1) {
  13267.       const int *src = src_row;
  13268.       uint8_t *dst = dst_row;
  13269.       for(x = 0; x < width; x += 1) {
  13270.          uint32_t value = 0;
  13271.          value |= (uint32_t)MAX2(src[0], 0);
  13272.          *(uint32_t *)dst = value;
  13273.          src += 4;
  13274.          dst += 4;
  13275.       }
  13276.       dst_row += dst_stride;
  13277.       src_row += src_stride/sizeof(*src_row);
  13278.    }
  13279. }
  13280.  
  13281. union util_format_r32g32_uint {
  13282.    uint64_t value;
  13283.    struct {
  13284.       uint32_t r;
  13285.       uint32_t g;
  13286.    } chan;
  13287. };
  13288.  
  13289. static INLINE void
  13290. util_format_r32g32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13291. {
  13292.    unsigned x, y;
  13293.    for(y = 0; y < height; y += 1) {
  13294.       unsigned *dst = dst_row;
  13295.       const uint8_t *src = src_row;
  13296.       for(x = 0; x < width; x += 1) {
  13297.          union util_format_r32g32_uint pixel;
  13298.          memcpy(&pixel, src, sizeof pixel);
  13299.          dst[0] = pixel.chan.r; /* r */
  13300.          dst[1] = pixel.chan.g; /* g */
  13301.          dst[2] = 0; /* b */
  13302.          dst[3] = 1; /* a */
  13303.          src += 8;
  13304.          dst += 4;
  13305.       }
  13306.       src_row += src_stride;
  13307.       dst_row += dst_stride/sizeof(*dst_row);
  13308.    }
  13309. }
  13310.  
  13311. static INLINE void
  13312. util_format_r32g32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13313. {
  13314.    unsigned x, y;
  13315.    for(y = 0; y < height; y += 1) {
  13316.       const unsigned *src = src_row;
  13317.       uint8_t *dst = dst_row;
  13318.       for(x = 0; x < width; x += 1) {
  13319.          union util_format_r32g32_uint pixel;
  13320.          pixel.chan.r = src[0];
  13321.          pixel.chan.g = src[1];
  13322.          memcpy(dst, &pixel, sizeof pixel);
  13323.          src += 4;
  13324.          dst += 8;
  13325.       }
  13326.       dst_row += dst_stride;
  13327.       src_row += src_stride/sizeof(*src_row);
  13328.    }
  13329. }
  13330.  
  13331. static INLINE void
  13332. util_format_r32g32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  13333. {
  13334.          union util_format_r32g32_uint pixel;
  13335.          memcpy(&pixel, src, sizeof pixel);
  13336.          dst[0] = pixel.chan.r; /* r */
  13337.          dst[1] = pixel.chan.g; /* g */
  13338.          dst[2] = 0; /* b */
  13339.          dst[3] = 1; /* a */
  13340. }
  13341.  
  13342. static INLINE void
  13343. util_format_r32g32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13344. {
  13345.    unsigned x, y;
  13346.    for(y = 0; y < height; y += 1) {
  13347.       int *dst = dst_row;
  13348.       const uint8_t *src = src_row;
  13349.       for(x = 0; x < width; x += 1) {
  13350.          union util_format_r32g32_uint pixel;
  13351.          memcpy(&pixel, src, sizeof pixel);
  13352.          dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
  13353.          dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
  13354.          dst[2] = 0; /* b */
  13355.          dst[3] = 1; /* a */
  13356.          src += 8;
  13357.          dst += 4;
  13358.       }
  13359.       src_row += src_stride;
  13360.       dst_row += dst_stride/sizeof(*dst_row);
  13361.    }
  13362. }
  13363.  
  13364. static INLINE void
  13365. util_format_r32g32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13366. {
  13367.    unsigned x, y;
  13368.    for(y = 0; y < height; y += 1) {
  13369.       const int *src = src_row;
  13370.       uint8_t *dst = dst_row;
  13371.       for(x = 0; x < width; x += 1) {
  13372.          union util_format_r32g32_uint pixel;
  13373.          pixel.chan.r = (uint32_t)MAX2(src[0], 0);
  13374.          pixel.chan.g = (uint32_t)MAX2(src[1], 0);
  13375.          memcpy(dst, &pixel, sizeof pixel);
  13376.          src += 4;
  13377.          dst += 8;
  13378.       }
  13379.       dst_row += dst_stride;
  13380.       src_row += src_stride/sizeof(*src_row);
  13381.    }
  13382. }
  13383.  
  13384. union util_format_r32g32b32_uint {
  13385.    struct {
  13386.       uint32_t r;
  13387.       uint32_t g;
  13388.       uint32_t b;
  13389.    } chan;
  13390. };
  13391.  
  13392. static INLINE void
  13393. util_format_r32g32b32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13394. {
  13395.    unsigned x, y;
  13396.    for(y = 0; y < height; y += 1) {
  13397.       unsigned *dst = dst_row;
  13398.       const uint8_t *src = src_row;
  13399.       for(x = 0; x < width; x += 1) {
  13400.          union util_format_r32g32b32_uint pixel;
  13401.          memcpy(&pixel, src, sizeof pixel);
  13402.          dst[0] = pixel.chan.r; /* r */
  13403.          dst[1] = pixel.chan.g; /* g */
  13404.          dst[2] = pixel.chan.b; /* b */
  13405.          dst[3] = 1; /* a */
  13406.          src += 12;
  13407.          dst += 4;
  13408.       }
  13409.       src_row += src_stride;
  13410.       dst_row += dst_stride/sizeof(*dst_row);
  13411.    }
  13412. }
  13413.  
  13414. static INLINE void
  13415. util_format_r32g32b32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13416. {
  13417.    unsigned x, y;
  13418.    for(y = 0; y < height; y += 1) {
  13419.       const unsigned *src = src_row;
  13420.       uint8_t *dst = dst_row;
  13421.       for(x = 0; x < width; x += 1) {
  13422.          union util_format_r32g32b32_uint pixel;
  13423.          pixel.chan.r = src[0];
  13424.          pixel.chan.g = src[1];
  13425.          pixel.chan.b = src[2];
  13426.          memcpy(dst, &pixel, sizeof pixel);
  13427.          src += 4;
  13428.          dst += 12;
  13429.       }
  13430.       dst_row += dst_stride;
  13431.       src_row += src_stride/sizeof(*src_row);
  13432.    }
  13433. }
  13434.  
  13435. static INLINE void
  13436. util_format_r32g32b32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  13437. {
  13438.          union util_format_r32g32b32_uint pixel;
  13439.          memcpy(&pixel, src, sizeof pixel);
  13440.          dst[0] = pixel.chan.r; /* r */
  13441.          dst[1] = pixel.chan.g; /* g */
  13442.          dst[2] = pixel.chan.b; /* b */
  13443.          dst[3] = 1; /* a */
  13444. }
  13445.  
  13446. static INLINE void
  13447. util_format_r32g32b32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13448. {
  13449.    unsigned x, y;
  13450.    for(y = 0; y < height; y += 1) {
  13451.       int *dst = dst_row;
  13452.       const uint8_t *src = src_row;
  13453.       for(x = 0; x < width; x += 1) {
  13454.          union util_format_r32g32b32_uint pixel;
  13455.          memcpy(&pixel, src, sizeof pixel);
  13456.          dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
  13457.          dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
  13458.          dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
  13459.          dst[3] = 1; /* a */
  13460.          src += 12;
  13461.          dst += 4;
  13462.       }
  13463.       src_row += src_stride;
  13464.       dst_row += dst_stride/sizeof(*dst_row);
  13465.    }
  13466. }
  13467.  
  13468. static INLINE void
  13469. util_format_r32g32b32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13470. {
  13471.    unsigned x, y;
  13472.    for(y = 0; y < height; y += 1) {
  13473.       const int *src = src_row;
  13474.       uint8_t *dst = dst_row;
  13475.       for(x = 0; x < width; x += 1) {
  13476.          union util_format_r32g32b32_uint pixel;
  13477.          pixel.chan.r = (uint32_t)MAX2(src[0], 0);
  13478.          pixel.chan.g = (uint32_t)MAX2(src[1], 0);
  13479.          pixel.chan.b = (uint32_t)MAX2(src[2], 0);
  13480.          memcpy(dst, &pixel, sizeof pixel);
  13481.          src += 4;
  13482.          dst += 12;
  13483.       }
  13484.       dst_row += dst_stride;
  13485.       src_row += src_stride/sizeof(*src_row);
  13486.    }
  13487. }
  13488.  
  13489. union util_format_r32g32b32a32_uint {
  13490.    struct {
  13491.       uint32_t r;
  13492.       uint32_t g;
  13493.       uint32_t b;
  13494.       uint32_t a;
  13495.    } chan;
  13496. };
  13497.  
  13498. static INLINE void
  13499. util_format_r32g32b32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13500. {
  13501.    unsigned x, y;
  13502.    for(y = 0; y < height; y += 1) {
  13503.       unsigned *dst = dst_row;
  13504.       const uint8_t *src = src_row;
  13505.       for(x = 0; x < width; x += 1) {
  13506.          union util_format_r32g32b32a32_uint pixel;
  13507.          memcpy(&pixel, src, sizeof pixel);
  13508.          dst[0] = pixel.chan.r; /* r */
  13509.          dst[1] = pixel.chan.g; /* g */
  13510.          dst[2] = pixel.chan.b; /* b */
  13511.          dst[3] = pixel.chan.a; /* a */
  13512.          src += 16;
  13513.          dst += 4;
  13514.       }
  13515.       src_row += src_stride;
  13516.       dst_row += dst_stride/sizeof(*dst_row);
  13517.    }
  13518. }
  13519.  
  13520. static INLINE void
  13521. util_format_r32g32b32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13522. {
  13523.    unsigned x, y;
  13524.    for(y = 0; y < height; y += 1) {
  13525.       const unsigned *src = src_row;
  13526.       uint8_t *dst = dst_row;
  13527.       for(x = 0; x < width; x += 1) {
  13528.          union util_format_r32g32b32a32_uint pixel;
  13529.          pixel.chan.r = src[0];
  13530.          pixel.chan.g = src[1];
  13531.          pixel.chan.b = src[2];
  13532.          pixel.chan.a = src[3];
  13533.          memcpy(dst, &pixel, sizeof pixel);
  13534.          src += 4;
  13535.          dst += 16;
  13536.       }
  13537.       dst_row += dst_stride;
  13538.       src_row += src_stride/sizeof(*src_row);
  13539.    }
  13540. }
  13541.  
  13542. static INLINE void
  13543. util_format_r32g32b32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  13544. {
  13545.          union util_format_r32g32b32a32_uint pixel;
  13546.          memcpy(&pixel, src, sizeof pixel);
  13547.          dst[0] = pixel.chan.r; /* r */
  13548.          dst[1] = pixel.chan.g; /* g */
  13549.          dst[2] = pixel.chan.b; /* b */
  13550.          dst[3] = pixel.chan.a; /* a */
  13551. }
  13552.  
  13553. static INLINE void
  13554. util_format_r32g32b32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13555. {
  13556.    unsigned x, y;
  13557.    for(y = 0; y < height; y += 1) {
  13558.       int *dst = dst_row;
  13559.       const uint8_t *src = src_row;
  13560.       for(x = 0; x < width; x += 1) {
  13561.          union util_format_r32g32b32a32_uint pixel;
  13562.          memcpy(&pixel, src, sizeof pixel);
  13563.          dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
  13564.          dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
  13565.          dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
  13566.          dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
  13567.          src += 16;
  13568.          dst += 4;
  13569.       }
  13570.       src_row += src_stride;
  13571.       dst_row += dst_stride/sizeof(*dst_row);
  13572.    }
  13573. }
  13574.  
  13575. static INLINE void
  13576. util_format_r32g32b32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13577. {
  13578.    unsigned x, y;
  13579.    for(y = 0; y < height; y += 1) {
  13580.       const int *src = src_row;
  13581.       uint8_t *dst = dst_row;
  13582.       for(x = 0; x < width; x += 1) {
  13583.          union util_format_r32g32b32a32_uint pixel;
  13584.          pixel.chan.r = (uint32_t)MAX2(src[0], 0);
  13585.          pixel.chan.g = (uint32_t)MAX2(src[1], 0);
  13586.          pixel.chan.b = (uint32_t)MAX2(src[2], 0);
  13587.          pixel.chan.a = (uint32_t)MAX2(src[3], 0);
  13588.          memcpy(dst, &pixel, sizeof pixel);
  13589.          src += 4;
  13590.          dst += 16;
  13591.       }
  13592.       dst_row += dst_stride;
  13593.       src_row += src_stride/sizeof(*src_row);
  13594.    }
  13595. }
  13596.  
  13597. union util_format_r32_sint {
  13598.    uint32_t value;
  13599.    struct {
  13600.       int32_t r;
  13601.    } chan;
  13602. };
  13603.  
  13604. static INLINE void
  13605. util_format_r32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13606. {
  13607.    unsigned x, y;
  13608.    for(y = 0; y < height; y += 1) {
  13609.       int *dst = dst_row;
  13610.       const uint8_t *src = src_row;
  13611.       for(x = 0; x < width; x += 1) {
  13612.          uint32_t value = *(const uint32_t *)src;
  13613.          int32_t r;
  13614.          r = (int32_t)(value) ;
  13615.          dst[0] = r; /* r */
  13616.          dst[1] = 0; /* g */
  13617.          dst[2] = 0; /* b */
  13618.          dst[3] = 1; /* a */
  13619.          src += 4;
  13620.          dst += 4;
  13621.       }
  13622.       src_row += src_stride;
  13623.       dst_row += dst_stride/sizeof(*dst_row);
  13624.    }
  13625. }
  13626.  
  13627. static INLINE void
  13628. util_format_r32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13629. {
  13630.    unsigned x, y;
  13631.    for(y = 0; y < height; y += 1) {
  13632.       const int *src = src_row;
  13633.       uint8_t *dst = dst_row;
  13634.       for(x = 0; x < width; x += 1) {
  13635.          uint32_t value = 0;
  13636.          value |= (uint32_t)(src[0]) ;
  13637.          *(uint32_t *)dst = value;
  13638.          src += 4;
  13639.          dst += 4;
  13640.       }
  13641.       dst_row += dst_stride;
  13642.       src_row += src_stride/sizeof(*src_row);
  13643.    }
  13644. }
  13645.  
  13646. static INLINE void
  13647. util_format_r32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13648. {
  13649.          uint32_t value = *(const uint32_t *)src;
  13650.          int32_t r;
  13651.          r = (int32_t)(value) ;
  13652.          dst[0] = r; /* r */
  13653.          dst[1] = 0; /* g */
  13654.          dst[2] = 0; /* b */
  13655.          dst[3] = 1; /* a */
  13656. }
  13657.  
  13658. static INLINE void
  13659. util_format_r32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13660. {
  13661.    unsigned x, y;
  13662.    for(y = 0; y < height; y += 1) {
  13663.       unsigned *dst = dst_row;
  13664.       const uint8_t *src = src_row;
  13665.       for(x = 0; x < width; x += 1) {
  13666.          uint32_t value = *(const uint32_t *)src;
  13667.          int32_t r;
  13668.          r = (int32_t)(value) ;
  13669.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  13670.          dst[1] = 0; /* g */
  13671.          dst[2] = 0; /* b */
  13672.          dst[3] = 1; /* a */
  13673.          src += 4;
  13674.          dst += 4;
  13675.       }
  13676.       src_row += src_stride;
  13677.       dst_row += dst_stride/sizeof(*dst_row);
  13678.    }
  13679. }
  13680.  
  13681. static INLINE void
  13682. util_format_r32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13683. {
  13684.    unsigned x, y;
  13685.    for(y = 0; y < height; y += 1) {
  13686.       const unsigned *src = src_row;
  13687.       uint8_t *dst = dst_row;
  13688.       for(x = 0; x < width; x += 1) {
  13689.          uint32_t value = 0;
  13690.          value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
  13691.          *(uint32_t *)dst = value;
  13692.          src += 4;
  13693.          dst += 4;
  13694.       }
  13695.       dst_row += dst_stride;
  13696.       src_row += src_stride/sizeof(*src_row);
  13697.    }
  13698. }
  13699.  
  13700. union util_format_r32g32_sint {
  13701.    uint64_t value;
  13702.    struct {
  13703.       int32_t r;
  13704.       int32_t g;
  13705.    } chan;
  13706. };
  13707.  
  13708. static INLINE void
  13709. util_format_r32g32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13710. {
  13711.    unsigned x, y;
  13712.    for(y = 0; y < height; y += 1) {
  13713.       int *dst = dst_row;
  13714.       const uint8_t *src = src_row;
  13715.       for(x = 0; x < width; x += 1) {
  13716.          union util_format_r32g32_sint pixel;
  13717.          memcpy(&pixel, src, sizeof pixel);
  13718.          dst[0] = pixel.chan.r; /* r */
  13719.          dst[1] = pixel.chan.g; /* g */
  13720.          dst[2] = 0; /* b */
  13721.          dst[3] = 1; /* a */
  13722.          src += 8;
  13723.          dst += 4;
  13724.       }
  13725.       src_row += src_stride;
  13726.       dst_row += dst_stride/sizeof(*dst_row);
  13727.    }
  13728. }
  13729.  
  13730. static INLINE void
  13731. util_format_r32g32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13732. {
  13733.    unsigned x, y;
  13734.    for(y = 0; y < height; y += 1) {
  13735.       const int *src = src_row;
  13736.       uint8_t *dst = dst_row;
  13737.       for(x = 0; x < width; x += 1) {
  13738.          union util_format_r32g32_sint pixel;
  13739.          pixel.chan.r = src[0];
  13740.          pixel.chan.g = src[1];
  13741.          memcpy(dst, &pixel, sizeof pixel);
  13742.          src += 4;
  13743.          dst += 8;
  13744.       }
  13745.       dst_row += dst_stride;
  13746.       src_row += src_stride/sizeof(*src_row);
  13747.    }
  13748. }
  13749.  
  13750. static INLINE void
  13751. util_format_r32g32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13752. {
  13753.          union util_format_r32g32_sint pixel;
  13754.          memcpy(&pixel, src, sizeof pixel);
  13755.          dst[0] = pixel.chan.r; /* r */
  13756.          dst[1] = pixel.chan.g; /* g */
  13757.          dst[2] = 0; /* b */
  13758.          dst[3] = 1; /* a */
  13759. }
  13760.  
  13761. static INLINE void
  13762. util_format_r32g32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13763. {
  13764.    unsigned x, y;
  13765.    for(y = 0; y < height; y += 1) {
  13766.       unsigned *dst = dst_row;
  13767.       const uint8_t *src = src_row;
  13768.       for(x = 0; x < width; x += 1) {
  13769.          union util_format_r32g32_sint pixel;
  13770.          memcpy(&pixel, src, sizeof pixel);
  13771.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  13772.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  13773.          dst[2] = 0; /* b */
  13774.          dst[3] = 1; /* a */
  13775.          src += 8;
  13776.          dst += 4;
  13777.       }
  13778.       src_row += src_stride;
  13779.       dst_row += dst_stride/sizeof(*dst_row);
  13780.    }
  13781. }
  13782.  
  13783. static INLINE void
  13784. util_format_r32g32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13785. {
  13786.    unsigned x, y;
  13787.    for(y = 0; y < height; y += 1) {
  13788.       const unsigned *src = src_row;
  13789.       uint8_t *dst = dst_row;
  13790.       for(x = 0; x < width; x += 1) {
  13791.          union util_format_r32g32_sint pixel;
  13792.          pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
  13793.          pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
  13794.          memcpy(dst, &pixel, sizeof pixel);
  13795.          src += 4;
  13796.          dst += 8;
  13797.       }
  13798.       dst_row += dst_stride;
  13799.       src_row += src_stride/sizeof(*src_row);
  13800.    }
  13801. }
  13802.  
  13803. union util_format_r32g32b32_sint {
  13804.    struct {
  13805.       int32_t r;
  13806.       int32_t g;
  13807.       int32_t b;
  13808.    } chan;
  13809. };
  13810.  
  13811. static INLINE void
  13812. util_format_r32g32b32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13813. {
  13814.    unsigned x, y;
  13815.    for(y = 0; y < height; y += 1) {
  13816.       int *dst = dst_row;
  13817.       const uint8_t *src = src_row;
  13818.       for(x = 0; x < width; x += 1) {
  13819.          union util_format_r32g32b32_sint pixel;
  13820.          memcpy(&pixel, src, sizeof pixel);
  13821.          dst[0] = pixel.chan.r; /* r */
  13822.          dst[1] = pixel.chan.g; /* g */
  13823.          dst[2] = pixel.chan.b; /* b */
  13824.          dst[3] = 1; /* a */
  13825.          src += 12;
  13826.          dst += 4;
  13827.       }
  13828.       src_row += src_stride;
  13829.       dst_row += dst_stride/sizeof(*dst_row);
  13830.    }
  13831. }
  13832.  
  13833. static INLINE void
  13834. util_format_r32g32b32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13835. {
  13836.    unsigned x, y;
  13837.    for(y = 0; y < height; y += 1) {
  13838.       const int *src = src_row;
  13839.       uint8_t *dst = dst_row;
  13840.       for(x = 0; x < width; x += 1) {
  13841.          union util_format_r32g32b32_sint pixel;
  13842.          pixel.chan.r = src[0];
  13843.          pixel.chan.g = src[1];
  13844.          pixel.chan.b = src[2];
  13845.          memcpy(dst, &pixel, sizeof pixel);
  13846.          src += 4;
  13847.          dst += 12;
  13848.       }
  13849.       dst_row += dst_stride;
  13850.       src_row += src_stride/sizeof(*src_row);
  13851.    }
  13852. }
  13853.  
  13854. static INLINE void
  13855. util_format_r32g32b32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13856. {
  13857.          union util_format_r32g32b32_sint pixel;
  13858.          memcpy(&pixel, src, sizeof pixel);
  13859.          dst[0] = pixel.chan.r; /* r */
  13860.          dst[1] = pixel.chan.g; /* g */
  13861.          dst[2] = pixel.chan.b; /* b */
  13862.          dst[3] = 1; /* a */
  13863. }
  13864.  
  13865. static INLINE void
  13866. util_format_r32g32b32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13867. {
  13868.    unsigned x, y;
  13869.    for(y = 0; y < height; y += 1) {
  13870.       unsigned *dst = dst_row;
  13871.       const uint8_t *src = src_row;
  13872.       for(x = 0; x < width; x += 1) {
  13873.          union util_format_r32g32b32_sint pixel;
  13874.          memcpy(&pixel, src, sizeof pixel);
  13875.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  13876.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  13877.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  13878.          dst[3] = 1; /* a */
  13879.          src += 12;
  13880.          dst += 4;
  13881.       }
  13882.       src_row += src_stride;
  13883.       dst_row += dst_stride/sizeof(*dst_row);
  13884.    }
  13885. }
  13886.  
  13887. static INLINE void
  13888. util_format_r32g32b32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13889. {
  13890.    unsigned x, y;
  13891.    for(y = 0; y < height; y += 1) {
  13892.       const unsigned *src = src_row;
  13893.       uint8_t *dst = dst_row;
  13894.       for(x = 0; x < width; x += 1) {
  13895.          union util_format_r32g32b32_sint pixel;
  13896.          pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
  13897.          pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
  13898.          pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
  13899.          memcpy(dst, &pixel, sizeof pixel);
  13900.          src += 4;
  13901.          dst += 12;
  13902.       }
  13903.       dst_row += dst_stride;
  13904.       src_row += src_stride/sizeof(*src_row);
  13905.    }
  13906. }
  13907.  
  13908. union util_format_r32g32b32a32_sint {
  13909.    struct {
  13910.       int32_t r;
  13911.       int32_t g;
  13912.       int32_t b;
  13913.       int32_t a;
  13914.    } chan;
  13915. };
  13916.  
  13917. static INLINE void
  13918. util_format_r32g32b32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13919. {
  13920.    unsigned x, y;
  13921.    for(y = 0; y < height; y += 1) {
  13922.       int *dst = dst_row;
  13923.       const uint8_t *src = src_row;
  13924.       for(x = 0; x < width; x += 1) {
  13925.          union util_format_r32g32b32a32_sint pixel;
  13926.          memcpy(&pixel, src, sizeof pixel);
  13927.          dst[0] = pixel.chan.r; /* r */
  13928.          dst[1] = pixel.chan.g; /* g */
  13929.          dst[2] = pixel.chan.b; /* b */
  13930.          dst[3] = pixel.chan.a; /* a */
  13931.          src += 16;
  13932.          dst += 4;
  13933.       }
  13934.       src_row += src_stride;
  13935.       dst_row += dst_stride/sizeof(*dst_row);
  13936.    }
  13937. }
  13938.  
  13939. static INLINE void
  13940. util_format_r32g32b32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  13941. {
  13942.    unsigned x, y;
  13943.    for(y = 0; y < height; y += 1) {
  13944.       const int *src = src_row;
  13945.       uint8_t *dst = dst_row;
  13946.       for(x = 0; x < width; x += 1) {
  13947.          union util_format_r32g32b32a32_sint pixel;
  13948.          pixel.chan.r = src[0];
  13949.          pixel.chan.g = src[1];
  13950.          pixel.chan.b = src[2];
  13951.          pixel.chan.a = src[3];
  13952.          memcpy(dst, &pixel, sizeof pixel);
  13953.          src += 4;
  13954.          dst += 16;
  13955.       }
  13956.       dst_row += dst_stride;
  13957.       src_row += src_stride/sizeof(*src_row);
  13958.    }
  13959. }
  13960.  
  13961. static INLINE void
  13962. util_format_r32g32b32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  13963. {
  13964.          union util_format_r32g32b32a32_sint pixel;
  13965.          memcpy(&pixel, src, sizeof pixel);
  13966.          dst[0] = pixel.chan.r; /* r */
  13967.          dst[1] = pixel.chan.g; /* g */
  13968.          dst[2] = pixel.chan.b; /* b */
  13969.          dst[3] = pixel.chan.a; /* a */
  13970. }
  13971.  
  13972. static INLINE void
  13973. util_format_r32g32b32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  13974. {
  13975.    unsigned x, y;
  13976.    for(y = 0; y < height; y += 1) {
  13977.       unsigned *dst = dst_row;
  13978.       const uint8_t *src = src_row;
  13979.       for(x = 0; x < width; x += 1) {
  13980.          union util_format_r32g32b32a32_sint pixel;
  13981.          memcpy(&pixel, src, sizeof pixel);
  13982.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  13983.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  13984.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  13985.          dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
  13986.          src += 16;
  13987.          dst += 4;
  13988.       }
  13989.       src_row += src_stride;
  13990.       dst_row += dst_stride/sizeof(*dst_row);
  13991.    }
  13992. }
  13993.  
  13994. static INLINE void
  13995. util_format_r32g32b32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  13996. {
  13997.    unsigned x, y;
  13998.    for(y = 0; y < height; y += 1) {
  13999.       const unsigned *src = src_row;
  14000.       uint8_t *dst = dst_row;
  14001.       for(x = 0; x < width; x += 1) {
  14002.          union util_format_r32g32b32a32_sint pixel;
  14003.          pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
  14004.          pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
  14005.          pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
  14006.          pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
  14007.          memcpy(dst, &pixel, sizeof pixel);
  14008.          src += 4;
  14009.          dst += 16;
  14010.       }
  14011.       dst_row += dst_stride;
  14012.       src_row += src_stride/sizeof(*src_row);
  14013.    }
  14014. }
  14015.  
  14016. union util_format_a8_uint {
  14017.    uint8_t value;
  14018.    struct {
  14019.       uint8_t a;
  14020.    } chan;
  14021. };
  14022.  
  14023. static INLINE void
  14024. util_format_a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14025. {
  14026.    unsigned x, y;
  14027.    for(y = 0; y < height; y += 1) {
  14028.       unsigned *dst = dst_row;
  14029.       const uint8_t *src = src_row;
  14030.       for(x = 0; x < width; x += 1) {
  14031.          uint8_t value = *(const uint8_t *)src;
  14032.          uint8_t a;
  14033.          a = value;
  14034.          dst[0] = 0; /* r */
  14035.          dst[1] = 0; /* g */
  14036.          dst[2] = 0; /* b */
  14037.          dst[3] = (unsigned)a; /* a */
  14038.          src += 1;
  14039.          dst += 4;
  14040.       }
  14041.       src_row += src_stride;
  14042.       dst_row += dst_stride/sizeof(*dst_row);
  14043.    }
  14044. }
  14045.  
  14046. static INLINE void
  14047. util_format_a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14048. {
  14049.    unsigned x, y;
  14050.    for(y = 0; y < height; y += 1) {
  14051.       const unsigned *src = src_row;
  14052.       uint8_t *dst = dst_row;
  14053.       for(x = 0; x < width; x += 1) {
  14054.          uint8_t value = 0;
  14055.          value |= (uint8_t)MIN2(src[3], 255);
  14056.          *(uint8_t *)dst = value;
  14057.          src += 4;
  14058.          dst += 1;
  14059.       }
  14060.       dst_row += dst_stride;
  14061.       src_row += src_stride/sizeof(*src_row);
  14062.    }
  14063. }
  14064.  
  14065. static INLINE void
  14066. util_format_a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  14067. {
  14068.          uint8_t value = *(const uint8_t *)src;
  14069.          uint8_t a;
  14070.          a = value;
  14071.          dst[0] = 0; /* r */
  14072.          dst[1] = 0; /* g */
  14073.          dst[2] = 0; /* b */
  14074.          dst[3] = (unsigned)a; /* a */
  14075. }
  14076.  
  14077. static INLINE void
  14078. util_format_a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14079. {
  14080.    unsigned x, y;
  14081.    for(y = 0; y < height; y += 1) {
  14082.       int *dst = dst_row;
  14083.       const uint8_t *src = src_row;
  14084.       for(x = 0; x < width; x += 1) {
  14085.          uint8_t value = *(const uint8_t *)src;
  14086.          uint8_t a;
  14087.          a = value;
  14088.          dst[0] = 0; /* r */
  14089.          dst[1] = 0; /* g */
  14090.          dst[2] = 0; /* b */
  14091.          dst[3] = (int)a; /* a */
  14092.          src += 1;
  14093.          dst += 4;
  14094.       }
  14095.       src_row += src_stride;
  14096.       dst_row += dst_stride/sizeof(*dst_row);
  14097.    }
  14098. }
  14099.  
  14100. static INLINE void
  14101. util_format_a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14102. {
  14103.    unsigned x, y;
  14104.    for(y = 0; y < height; y += 1) {
  14105.       const int *src = src_row;
  14106.       uint8_t *dst = dst_row;
  14107.       for(x = 0; x < width; x += 1) {
  14108.          uint8_t value = 0;
  14109.          value |= (uint8_t)CLAMP(src[3], 0, 255);
  14110.          *(uint8_t *)dst = value;
  14111.          src += 4;
  14112.          dst += 1;
  14113.       }
  14114.       dst_row += dst_stride;
  14115.       src_row += src_stride/sizeof(*src_row);
  14116.    }
  14117. }
  14118.  
  14119. union util_format_i8_uint {
  14120.    uint8_t value;
  14121.    struct {
  14122.       uint8_t rgba;
  14123.    } chan;
  14124. };
  14125.  
  14126. static INLINE void
  14127. util_format_i8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14128. {
  14129.    unsigned x, y;
  14130.    for(y = 0; y < height; y += 1) {
  14131.       unsigned *dst = dst_row;
  14132.       const uint8_t *src = src_row;
  14133.       for(x = 0; x < width; x += 1) {
  14134.          uint8_t value = *(const uint8_t *)src;
  14135.          uint8_t rgba;
  14136.          rgba = value;
  14137.          dst[0] = (unsigned)rgba; /* r */
  14138.          dst[1] = (unsigned)rgba; /* g */
  14139.          dst[2] = (unsigned)rgba; /* b */
  14140.          dst[3] = (unsigned)rgba; /* a */
  14141.          src += 1;
  14142.          dst += 4;
  14143.       }
  14144.       src_row += src_stride;
  14145.       dst_row += dst_stride/sizeof(*dst_row);
  14146.    }
  14147. }
  14148.  
  14149. static INLINE void
  14150. util_format_i8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14151. {
  14152.    unsigned x, y;
  14153.    for(y = 0; y < height; y += 1) {
  14154.       const unsigned *src = src_row;
  14155.       uint8_t *dst = dst_row;
  14156.       for(x = 0; x < width; x += 1) {
  14157.          uint8_t value = 0;
  14158.          value |= (uint8_t)MIN2(src[0], 255);
  14159.          *(uint8_t *)dst = value;
  14160.          src += 4;
  14161.          dst += 1;
  14162.       }
  14163.       dst_row += dst_stride;
  14164.       src_row += src_stride/sizeof(*src_row);
  14165.    }
  14166. }
  14167.  
  14168. static INLINE void
  14169. util_format_i8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  14170. {
  14171.          uint8_t value = *(const uint8_t *)src;
  14172.          uint8_t rgba;
  14173.          rgba = value;
  14174.          dst[0] = (unsigned)rgba; /* r */
  14175.          dst[1] = (unsigned)rgba; /* g */
  14176.          dst[2] = (unsigned)rgba; /* b */
  14177.          dst[3] = (unsigned)rgba; /* a */
  14178. }
  14179.  
  14180. static INLINE void
  14181. util_format_i8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14182. {
  14183.    unsigned x, y;
  14184.    for(y = 0; y < height; y += 1) {
  14185.       int *dst = dst_row;
  14186.       const uint8_t *src = src_row;
  14187.       for(x = 0; x < width; x += 1) {
  14188.          uint8_t value = *(const uint8_t *)src;
  14189.          uint8_t rgba;
  14190.          rgba = value;
  14191.          dst[0] = (int)rgba; /* r */
  14192.          dst[1] = (int)rgba; /* g */
  14193.          dst[2] = (int)rgba; /* b */
  14194.          dst[3] = (int)rgba; /* a */
  14195.          src += 1;
  14196.          dst += 4;
  14197.       }
  14198.       src_row += src_stride;
  14199.       dst_row += dst_stride/sizeof(*dst_row);
  14200.    }
  14201. }
  14202.  
  14203. static INLINE void
  14204. util_format_i8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14205. {
  14206.    unsigned x, y;
  14207.    for(y = 0; y < height; y += 1) {
  14208.       const int *src = src_row;
  14209.       uint8_t *dst = dst_row;
  14210.       for(x = 0; x < width; x += 1) {
  14211.          uint8_t value = 0;
  14212.          value |= (uint8_t)CLAMP(src[0], 0, 255);
  14213.          *(uint8_t *)dst = value;
  14214.          src += 4;
  14215.          dst += 1;
  14216.       }
  14217.       dst_row += dst_stride;
  14218.       src_row += src_stride/sizeof(*src_row);
  14219.    }
  14220. }
  14221.  
  14222. union util_format_l8_uint {
  14223.    uint8_t value;
  14224.    struct {
  14225.       uint8_t rgb;
  14226.    } chan;
  14227. };
  14228.  
  14229. static INLINE void
  14230. util_format_l8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14231. {
  14232.    unsigned x, y;
  14233.    for(y = 0; y < height; y += 1) {
  14234.       unsigned *dst = dst_row;
  14235.       const uint8_t *src = src_row;
  14236.       for(x = 0; x < width; x += 1) {
  14237.          uint8_t value = *(const uint8_t *)src;
  14238.          uint8_t rgb;
  14239.          rgb = value;
  14240.          dst[0] = (unsigned)rgb; /* r */
  14241.          dst[1] = (unsigned)rgb; /* g */
  14242.          dst[2] = (unsigned)rgb; /* b */
  14243.          dst[3] = 1; /* a */
  14244.          src += 1;
  14245.          dst += 4;
  14246.       }
  14247.       src_row += src_stride;
  14248.       dst_row += dst_stride/sizeof(*dst_row);
  14249.    }
  14250. }
  14251.  
  14252. static INLINE void
  14253. util_format_l8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14254. {
  14255.    unsigned x, y;
  14256.    for(y = 0; y < height; y += 1) {
  14257.       const unsigned *src = src_row;
  14258.       uint8_t *dst = dst_row;
  14259.       for(x = 0; x < width; x += 1) {
  14260.          uint8_t value = 0;
  14261.          value |= (uint8_t)MIN2(src[0], 255);
  14262.          *(uint8_t *)dst = value;
  14263.          src += 4;
  14264.          dst += 1;
  14265.       }
  14266.       dst_row += dst_stride;
  14267.       src_row += src_stride/sizeof(*src_row);
  14268.    }
  14269. }
  14270.  
  14271. static INLINE void
  14272. util_format_l8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  14273. {
  14274.          uint8_t value = *(const uint8_t *)src;
  14275.          uint8_t rgb;
  14276.          rgb = value;
  14277.          dst[0] = (unsigned)rgb; /* r */
  14278.          dst[1] = (unsigned)rgb; /* g */
  14279.          dst[2] = (unsigned)rgb; /* b */
  14280.          dst[3] = 1; /* a */
  14281. }
  14282.  
  14283. static INLINE void
  14284. util_format_l8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14285. {
  14286.    unsigned x, y;
  14287.    for(y = 0; y < height; y += 1) {
  14288.       int *dst = dst_row;
  14289.       const uint8_t *src = src_row;
  14290.       for(x = 0; x < width; x += 1) {
  14291.          uint8_t value = *(const uint8_t *)src;
  14292.          uint8_t rgb;
  14293.          rgb = value;
  14294.          dst[0] = (int)rgb; /* r */
  14295.          dst[1] = (int)rgb; /* g */
  14296.          dst[2] = (int)rgb; /* b */
  14297.          dst[3] = 1; /* a */
  14298.          src += 1;
  14299.          dst += 4;
  14300.       }
  14301.       src_row += src_stride;
  14302.       dst_row += dst_stride/sizeof(*dst_row);
  14303.    }
  14304. }
  14305.  
  14306. static INLINE void
  14307. util_format_l8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14308. {
  14309.    unsigned x, y;
  14310.    for(y = 0; y < height; y += 1) {
  14311.       const int *src = src_row;
  14312.       uint8_t *dst = dst_row;
  14313.       for(x = 0; x < width; x += 1) {
  14314.          uint8_t value = 0;
  14315.          value |= (uint8_t)CLAMP(src[0], 0, 255);
  14316.          *(uint8_t *)dst = value;
  14317.          src += 4;
  14318.          dst += 1;
  14319.       }
  14320.       dst_row += dst_stride;
  14321.       src_row += src_stride/sizeof(*src_row);
  14322.    }
  14323. }
  14324.  
  14325. union util_format_l8a8_uint {
  14326.    uint16_t value;
  14327.    struct {
  14328.       uint8_t rgb;
  14329.       uint8_t a;
  14330.    } chan;
  14331. };
  14332.  
  14333. static INLINE void
  14334. util_format_l8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14335. {
  14336.    unsigned x, y;
  14337.    for(y = 0; y < height; y += 1) {
  14338.       unsigned *dst = dst_row;
  14339.       const uint8_t *src = src_row;
  14340.       for(x = 0; x < width; x += 1) {
  14341.          uint16_t value = *(const uint16_t *)src;
  14342.          uint16_t rgb;
  14343.          uint16_t a;
  14344.          rgb = (value) & 0xff;
  14345.          a = value >> 8;
  14346.          dst[0] = (unsigned)rgb; /* r */
  14347.          dst[1] = (unsigned)rgb; /* g */
  14348.          dst[2] = (unsigned)rgb; /* b */
  14349.          dst[3] = (unsigned)a; /* a */
  14350.          src += 2;
  14351.          dst += 4;
  14352.       }
  14353.       src_row += src_stride;
  14354.       dst_row += dst_stride/sizeof(*dst_row);
  14355.    }
  14356. }
  14357.  
  14358. static INLINE void
  14359. util_format_l8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14360. {
  14361.    unsigned x, y;
  14362.    for(y = 0; y < height; y += 1) {
  14363.       const unsigned *src = src_row;
  14364.       uint8_t *dst = dst_row;
  14365.       for(x = 0; x < width; x += 1) {
  14366.          uint16_t value = 0;
  14367.          value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
  14368.          value |= ((uint8_t)MIN2(src[3], 255)) << 8;
  14369.          *(uint16_t *)dst = value;
  14370.          src += 4;
  14371.          dst += 2;
  14372.       }
  14373.       dst_row += dst_stride;
  14374.       src_row += src_stride/sizeof(*src_row);
  14375.    }
  14376. }
  14377.  
  14378. static INLINE void
  14379. util_format_l8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  14380. {
  14381.          uint16_t value = *(const uint16_t *)src;
  14382.          uint16_t rgb;
  14383.          uint16_t a;
  14384.          rgb = (value) & 0xff;
  14385.          a = value >> 8;
  14386.          dst[0] = (unsigned)rgb; /* r */
  14387.          dst[1] = (unsigned)rgb; /* g */
  14388.          dst[2] = (unsigned)rgb; /* b */
  14389.          dst[3] = (unsigned)a; /* a */
  14390. }
  14391.  
  14392. static INLINE void
  14393. util_format_l8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14394. {
  14395.    unsigned x, y;
  14396.    for(y = 0; y < height; y += 1) {
  14397.       int *dst = dst_row;
  14398.       const uint8_t *src = src_row;
  14399.       for(x = 0; x < width; x += 1) {
  14400.          uint16_t value = *(const uint16_t *)src;
  14401.          uint16_t rgb;
  14402.          uint16_t a;
  14403.          rgb = (value) & 0xff;
  14404.          a = value >> 8;
  14405.          dst[0] = (int)rgb; /* r */
  14406.          dst[1] = (int)rgb; /* g */
  14407.          dst[2] = (int)rgb; /* b */
  14408.          dst[3] = (int)a; /* a */
  14409.          src += 2;
  14410.          dst += 4;
  14411.       }
  14412.       src_row += src_stride;
  14413.       dst_row += dst_stride/sizeof(*dst_row);
  14414.    }
  14415. }
  14416.  
  14417. static INLINE void
  14418. util_format_l8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14419. {
  14420.    unsigned x, y;
  14421.    for(y = 0; y < height; y += 1) {
  14422.       const int *src = src_row;
  14423.       uint8_t *dst = dst_row;
  14424.       for(x = 0; x < width; x += 1) {
  14425.          uint16_t value = 0;
  14426.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  14427.          value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8;
  14428.          *(uint16_t *)dst = value;
  14429.          src += 4;
  14430.          dst += 2;
  14431.       }
  14432.       dst_row += dst_stride;
  14433.       src_row += src_stride/sizeof(*src_row);
  14434.    }
  14435. }
  14436.  
  14437. union util_format_a8_sint {
  14438.    uint8_t value;
  14439.    struct {
  14440.       int8_t a;
  14441.    } chan;
  14442. };
  14443.  
  14444. static INLINE void
  14445. util_format_a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14446. {
  14447.    unsigned x, y;
  14448.    for(y = 0; y < height; y += 1) {
  14449.       int *dst = dst_row;
  14450.       const uint8_t *src = src_row;
  14451.       for(x = 0; x < width; x += 1) {
  14452.          uint8_t value = *(const uint8_t *)src;
  14453.          int8_t a;
  14454.          a = (int8_t)(value) ;
  14455.          dst[0] = 0; /* r */
  14456.          dst[1] = 0; /* g */
  14457.          dst[2] = 0; /* b */
  14458.          dst[3] = (int)a; /* a */
  14459.          src += 1;
  14460.          dst += 4;
  14461.       }
  14462.       src_row += src_stride;
  14463.       dst_row += dst_stride/sizeof(*dst_row);
  14464.    }
  14465. }
  14466.  
  14467. static INLINE void
  14468. util_format_a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14469. {
  14470.    unsigned x, y;
  14471.    for(y = 0; y < height; y += 1) {
  14472.       const int *src = src_row;
  14473.       uint8_t *dst = dst_row;
  14474.       for(x = 0; x < width; x += 1) {
  14475.          uint8_t value = 0;
  14476.          value |= (uint8_t)((int8_t)CLAMP(src[3], -128, 127)) ;
  14477.          *(uint8_t *)dst = value;
  14478.          src += 4;
  14479.          dst += 1;
  14480.       }
  14481.       dst_row += dst_stride;
  14482.       src_row += src_stride/sizeof(*src_row);
  14483.    }
  14484. }
  14485.  
  14486. static INLINE void
  14487. util_format_a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  14488. {
  14489.          uint8_t value = *(const uint8_t *)src;
  14490.          int8_t a;
  14491.          a = (int8_t)(value) ;
  14492.          dst[0] = 0; /* r */
  14493.          dst[1] = 0; /* g */
  14494.          dst[2] = 0; /* b */
  14495.          dst[3] = (int)a; /* a */
  14496. }
  14497.  
  14498. static INLINE void
  14499. util_format_a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14500. {
  14501.    unsigned x, y;
  14502.    for(y = 0; y < height; y += 1) {
  14503.       unsigned *dst = dst_row;
  14504.       const uint8_t *src = src_row;
  14505.       for(x = 0; x < width; x += 1) {
  14506.          uint8_t value = *(const uint8_t *)src;
  14507.          int8_t a;
  14508.          a = (int8_t)(value) ;
  14509.          dst[0] = 0; /* r */
  14510.          dst[1] = 0; /* g */
  14511.          dst[2] = 0; /* b */
  14512.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  14513.          src += 1;
  14514.          dst += 4;
  14515.       }
  14516.       src_row += src_stride;
  14517.       dst_row += dst_stride/sizeof(*dst_row);
  14518.    }
  14519. }
  14520.  
  14521. static INLINE void
  14522. util_format_a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14523. {
  14524.    unsigned x, y;
  14525.    for(y = 0; y < height; y += 1) {
  14526.       const unsigned *src = src_row;
  14527.       uint8_t *dst = dst_row;
  14528.       for(x = 0; x < width; x += 1) {
  14529.          uint8_t value = 0;
  14530.          value |= (uint8_t)((int8_t)MIN2(src[3], 127)) ;
  14531.          *(uint8_t *)dst = value;
  14532.          src += 4;
  14533.          dst += 1;
  14534.       }
  14535.       dst_row += dst_stride;
  14536.       src_row += src_stride/sizeof(*src_row);
  14537.    }
  14538. }
  14539.  
  14540. union util_format_i8_sint {
  14541.    uint8_t value;
  14542.    struct {
  14543.       int8_t rgba;
  14544.    } chan;
  14545. };
  14546.  
  14547. static INLINE void
  14548. util_format_i8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14549. {
  14550.    unsigned x, y;
  14551.    for(y = 0; y < height; y += 1) {
  14552.       int *dst = dst_row;
  14553.       const uint8_t *src = src_row;
  14554.       for(x = 0; x < width; x += 1) {
  14555.          uint8_t value = *(const uint8_t *)src;
  14556.          int8_t rgba;
  14557.          rgba = (int8_t)(value) ;
  14558.          dst[0] = (int)rgba; /* r */
  14559.          dst[1] = (int)rgba; /* g */
  14560.          dst[2] = (int)rgba; /* b */
  14561.          dst[3] = (int)rgba; /* a */
  14562.          src += 1;
  14563.          dst += 4;
  14564.       }
  14565.       src_row += src_stride;
  14566.       dst_row += dst_stride/sizeof(*dst_row);
  14567.    }
  14568. }
  14569.  
  14570. static INLINE void
  14571. util_format_i8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14572. {
  14573.    unsigned x, y;
  14574.    for(y = 0; y < height; y += 1) {
  14575.       const int *src = src_row;
  14576.       uint8_t *dst = dst_row;
  14577.       for(x = 0; x < width; x += 1) {
  14578.          uint8_t value = 0;
  14579.          value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
  14580.          *(uint8_t *)dst = value;
  14581.          src += 4;
  14582.          dst += 1;
  14583.       }
  14584.       dst_row += dst_stride;
  14585.       src_row += src_stride/sizeof(*src_row);
  14586.    }
  14587. }
  14588.  
  14589. static INLINE void
  14590. util_format_i8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  14591. {
  14592.          uint8_t value = *(const uint8_t *)src;
  14593.          int8_t rgba;
  14594.          rgba = (int8_t)(value) ;
  14595.          dst[0] = (int)rgba; /* r */
  14596.          dst[1] = (int)rgba; /* g */
  14597.          dst[2] = (int)rgba; /* b */
  14598.          dst[3] = (int)rgba; /* a */
  14599. }
  14600.  
  14601. static INLINE void
  14602. util_format_i8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14603. {
  14604.    unsigned x, y;
  14605.    for(y = 0; y < height; y += 1) {
  14606.       unsigned *dst = dst_row;
  14607.       const uint8_t *src = src_row;
  14608.       for(x = 0; x < width; x += 1) {
  14609.          uint8_t value = *(const uint8_t *)src;
  14610.          int8_t rgba;
  14611.          rgba = (int8_t)(value) ;
  14612.          dst[0] = (unsigned)MAX2(rgba, 0); /* r */
  14613.          dst[1] = (unsigned)MAX2(rgba, 0); /* g */
  14614.          dst[2] = (unsigned)MAX2(rgba, 0); /* b */
  14615.          dst[3] = (unsigned)MAX2(rgba, 0); /* a */
  14616.          src += 1;
  14617.          dst += 4;
  14618.       }
  14619.       src_row += src_stride;
  14620.       dst_row += dst_stride/sizeof(*dst_row);
  14621.    }
  14622. }
  14623.  
  14624. static INLINE void
  14625. util_format_i8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14626. {
  14627.    unsigned x, y;
  14628.    for(y = 0; y < height; y += 1) {
  14629.       const unsigned *src = src_row;
  14630.       uint8_t *dst = dst_row;
  14631.       for(x = 0; x < width; x += 1) {
  14632.          uint8_t value = 0;
  14633.          value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
  14634.          *(uint8_t *)dst = value;
  14635.          src += 4;
  14636.          dst += 1;
  14637.       }
  14638.       dst_row += dst_stride;
  14639.       src_row += src_stride/sizeof(*src_row);
  14640.    }
  14641. }
  14642.  
  14643. union util_format_l8_sint {
  14644.    uint8_t value;
  14645.    struct {
  14646.       int8_t rgb;
  14647.    } chan;
  14648. };
  14649.  
  14650. static INLINE void
  14651. util_format_l8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14652. {
  14653.    unsigned x, y;
  14654.    for(y = 0; y < height; y += 1) {
  14655.       int *dst = dst_row;
  14656.       const uint8_t *src = src_row;
  14657.       for(x = 0; x < width; x += 1) {
  14658.          uint8_t value = *(const uint8_t *)src;
  14659.          int8_t rgb;
  14660.          rgb = (int8_t)(value) ;
  14661.          dst[0] = (int)rgb; /* r */
  14662.          dst[1] = (int)rgb; /* g */
  14663.          dst[2] = (int)rgb; /* b */
  14664.          dst[3] = 1; /* a */
  14665.          src += 1;
  14666.          dst += 4;
  14667.       }
  14668.       src_row += src_stride;
  14669.       dst_row += dst_stride/sizeof(*dst_row);
  14670.    }
  14671. }
  14672.  
  14673. static INLINE void
  14674. util_format_l8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14675. {
  14676.    unsigned x, y;
  14677.    for(y = 0; y < height; y += 1) {
  14678.       const int *src = src_row;
  14679.       uint8_t *dst = dst_row;
  14680.       for(x = 0; x < width; x += 1) {
  14681.          uint8_t value = 0;
  14682.          value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ;
  14683.          *(uint8_t *)dst = value;
  14684.          src += 4;
  14685.          dst += 1;
  14686.       }
  14687.       dst_row += dst_stride;
  14688.       src_row += src_stride/sizeof(*src_row);
  14689.    }
  14690. }
  14691.  
  14692. static INLINE void
  14693. util_format_l8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  14694. {
  14695.          uint8_t value = *(const uint8_t *)src;
  14696.          int8_t rgb;
  14697.          rgb = (int8_t)(value) ;
  14698.          dst[0] = (int)rgb; /* r */
  14699.          dst[1] = (int)rgb; /* g */
  14700.          dst[2] = (int)rgb; /* b */
  14701.          dst[3] = 1; /* a */
  14702. }
  14703.  
  14704. static INLINE void
  14705. util_format_l8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14706. {
  14707.    unsigned x, y;
  14708.    for(y = 0; y < height; y += 1) {
  14709.       unsigned *dst = dst_row;
  14710.       const uint8_t *src = src_row;
  14711.       for(x = 0; x < width; x += 1) {
  14712.          uint8_t value = *(const uint8_t *)src;
  14713.          int8_t rgb;
  14714.          rgb = (int8_t)(value) ;
  14715.          dst[0] = (unsigned)MAX2(rgb, 0); /* r */
  14716.          dst[1] = (unsigned)MAX2(rgb, 0); /* g */
  14717.          dst[2] = (unsigned)MAX2(rgb, 0); /* b */
  14718.          dst[3] = 1; /* a */
  14719.          src += 1;
  14720.          dst += 4;
  14721.       }
  14722.       src_row += src_stride;
  14723.       dst_row += dst_stride/sizeof(*dst_row);
  14724.    }
  14725. }
  14726.  
  14727. static INLINE void
  14728. util_format_l8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14729. {
  14730.    unsigned x, y;
  14731.    for(y = 0; y < height; y += 1) {
  14732.       const unsigned *src = src_row;
  14733.       uint8_t *dst = dst_row;
  14734.       for(x = 0; x < width; x += 1) {
  14735.          uint8_t value = 0;
  14736.          value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ;
  14737.          *(uint8_t *)dst = value;
  14738.          src += 4;
  14739.          dst += 1;
  14740.       }
  14741.       dst_row += dst_stride;
  14742.       src_row += src_stride/sizeof(*src_row);
  14743.    }
  14744. }
  14745.  
  14746. union util_format_l8a8_sint {
  14747.    uint16_t value;
  14748.    struct {
  14749.       int8_t rgb;
  14750.       int8_t a;
  14751.    } chan;
  14752. };
  14753.  
  14754. static INLINE void
  14755. util_format_l8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14756. {
  14757.    unsigned x, y;
  14758.    for(y = 0; y < height; y += 1) {
  14759.       int *dst = dst_row;
  14760.       const uint8_t *src = src_row;
  14761.       for(x = 0; x < width; x += 1) {
  14762.          uint16_t value = *(const uint16_t *)src;
  14763.          int16_t rgb;
  14764.          int16_t a;
  14765.          rgb = ((int16_t)(value << 8) ) >> 8;
  14766.          a = ((int16_t)(value) ) >> 8;
  14767.          dst[0] = (int)rgb; /* r */
  14768.          dst[1] = (int)rgb; /* g */
  14769.          dst[2] = (int)rgb; /* b */
  14770.          dst[3] = (int)a; /* a */
  14771.          src += 2;
  14772.          dst += 4;
  14773.       }
  14774.       src_row += src_stride;
  14775.       dst_row += dst_stride/sizeof(*dst_row);
  14776.    }
  14777. }
  14778.  
  14779. static INLINE void
  14780. util_format_l8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14781. {
  14782.    unsigned x, y;
  14783.    for(y = 0; y < height; y += 1) {
  14784.       const int *src = src_row;
  14785.       uint8_t *dst = dst_row;
  14786.       for(x = 0; x < width; x += 1) {
  14787.          uint16_t value = 0;
  14788.          value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  14789.          value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ;
  14790.          *(uint16_t *)dst = value;
  14791.          src += 4;
  14792.          dst += 2;
  14793.       }
  14794.       dst_row += dst_stride;
  14795.       src_row += src_stride/sizeof(*src_row);
  14796.    }
  14797. }
  14798.  
  14799. static INLINE void
  14800. util_format_l8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  14801. {
  14802.          uint16_t value = *(const uint16_t *)src;
  14803.          int16_t rgb;
  14804.          int16_t a;
  14805.          rgb = ((int16_t)(value << 8) ) >> 8;
  14806.          a = ((int16_t)(value) ) >> 8;
  14807.          dst[0] = (int)rgb; /* r */
  14808.          dst[1] = (int)rgb; /* g */
  14809.          dst[2] = (int)rgb; /* b */
  14810.          dst[3] = (int)a; /* a */
  14811. }
  14812.  
  14813. static INLINE void
  14814. util_format_l8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14815. {
  14816.    unsigned x, y;
  14817.    for(y = 0; y < height; y += 1) {
  14818.       unsigned *dst = dst_row;
  14819.       const uint8_t *src = src_row;
  14820.       for(x = 0; x < width; x += 1) {
  14821.          uint16_t value = *(const uint16_t *)src;
  14822.          int16_t rgb;
  14823.          int16_t a;
  14824.          rgb = ((int16_t)(value << 8) ) >> 8;
  14825.          a = ((int16_t)(value) ) >> 8;
  14826.          dst[0] = (unsigned)MAX2(rgb, 0); /* r */
  14827.          dst[1] = (unsigned)MAX2(rgb, 0); /* g */
  14828.          dst[2] = (unsigned)MAX2(rgb, 0); /* b */
  14829.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  14830.          src += 2;
  14831.          dst += 4;
  14832.       }
  14833.       src_row += src_stride;
  14834.       dst_row += dst_stride/sizeof(*dst_row);
  14835.    }
  14836. }
  14837.  
  14838. static INLINE void
  14839. util_format_l8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14840. {
  14841.    unsigned x, y;
  14842.    for(y = 0; y < height; y += 1) {
  14843.       const unsigned *src = src_row;
  14844.       uint8_t *dst = dst_row;
  14845.       for(x = 0; x < width; x += 1) {
  14846.          uint16_t value = 0;
  14847.          value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
  14848.          value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ;
  14849.          *(uint16_t *)dst = value;
  14850.          src += 4;
  14851.          dst += 2;
  14852.       }
  14853.       dst_row += dst_stride;
  14854.       src_row += src_stride/sizeof(*src_row);
  14855.    }
  14856. }
  14857.  
  14858. union util_format_a16_uint {
  14859.    uint16_t value;
  14860.    struct {
  14861.       uint16_t a;
  14862.    } chan;
  14863. };
  14864.  
  14865. static INLINE void
  14866. util_format_a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14867. {
  14868.    unsigned x, y;
  14869.    for(y = 0; y < height; y += 1) {
  14870.       unsigned *dst = dst_row;
  14871.       const uint8_t *src = src_row;
  14872.       for(x = 0; x < width; x += 1) {
  14873.          uint16_t value = *(const uint16_t *)src;
  14874.          uint16_t a;
  14875.          a = value;
  14876.          dst[0] = 0; /* r */
  14877.          dst[1] = 0; /* g */
  14878.          dst[2] = 0; /* b */
  14879.          dst[3] = (unsigned)a; /* a */
  14880.          src += 2;
  14881.          dst += 4;
  14882.       }
  14883.       src_row += src_stride;
  14884.       dst_row += dst_stride/sizeof(*dst_row);
  14885.    }
  14886. }
  14887.  
  14888. static INLINE void
  14889. util_format_a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14890. {
  14891.    unsigned x, y;
  14892.    for(y = 0; y < height; y += 1) {
  14893.       const unsigned *src = src_row;
  14894.       uint8_t *dst = dst_row;
  14895.       for(x = 0; x < width; x += 1) {
  14896.          uint16_t value = 0;
  14897.          value |= (uint16_t)MIN2(src[3], 65535);
  14898.          *(uint16_t *)dst = value;
  14899.          src += 4;
  14900.          dst += 2;
  14901.       }
  14902.       dst_row += dst_stride;
  14903.       src_row += src_stride/sizeof(*src_row);
  14904.    }
  14905. }
  14906.  
  14907. static INLINE void
  14908. util_format_a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  14909. {
  14910.          uint16_t value = *(const uint16_t *)src;
  14911.          uint16_t a;
  14912.          a = value;
  14913.          dst[0] = 0; /* r */
  14914.          dst[1] = 0; /* g */
  14915.          dst[2] = 0; /* b */
  14916.          dst[3] = (unsigned)a; /* a */
  14917. }
  14918.  
  14919. static INLINE void
  14920. util_format_a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14921. {
  14922.    unsigned x, y;
  14923.    for(y = 0; y < height; y += 1) {
  14924.       int *dst = dst_row;
  14925.       const uint8_t *src = src_row;
  14926.       for(x = 0; x < width; x += 1) {
  14927.          uint16_t value = *(const uint16_t *)src;
  14928.          uint16_t a;
  14929.          a = value;
  14930.          dst[0] = 0; /* r */
  14931.          dst[1] = 0; /* g */
  14932.          dst[2] = 0; /* b */
  14933.          dst[3] = (int)a; /* a */
  14934.          src += 2;
  14935.          dst += 4;
  14936.       }
  14937.       src_row += src_stride;
  14938.       dst_row += dst_stride/sizeof(*dst_row);
  14939.    }
  14940. }
  14941.  
  14942. static INLINE void
  14943. util_format_a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  14944. {
  14945.    unsigned x, y;
  14946.    for(y = 0; y < height; y += 1) {
  14947.       const int *src = src_row;
  14948.       uint8_t *dst = dst_row;
  14949.       for(x = 0; x < width; x += 1) {
  14950.          uint16_t value = 0;
  14951.          value |= (uint16_t)CLAMP(src[3], 0, 65535);
  14952.          *(uint16_t *)dst = value;
  14953.          src += 4;
  14954.          dst += 2;
  14955.       }
  14956.       dst_row += dst_stride;
  14957.       src_row += src_stride/sizeof(*src_row);
  14958.    }
  14959. }
  14960.  
  14961. union util_format_i16_uint {
  14962.    uint16_t value;
  14963.    struct {
  14964.       uint16_t rgba;
  14965.    } chan;
  14966. };
  14967.  
  14968. static INLINE void
  14969. util_format_i16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  14970. {
  14971.    unsigned x, y;
  14972.    for(y = 0; y < height; y += 1) {
  14973.       unsigned *dst = dst_row;
  14974.       const uint8_t *src = src_row;
  14975.       for(x = 0; x < width; x += 1) {
  14976.          uint16_t value = *(const uint16_t *)src;
  14977.          uint16_t rgba;
  14978.          rgba = value;
  14979.          dst[0] = (unsigned)rgba; /* r */
  14980.          dst[1] = (unsigned)rgba; /* g */
  14981.          dst[2] = (unsigned)rgba; /* b */
  14982.          dst[3] = (unsigned)rgba; /* a */
  14983.          src += 2;
  14984.          dst += 4;
  14985.       }
  14986.       src_row += src_stride;
  14987.       dst_row += dst_stride/sizeof(*dst_row);
  14988.    }
  14989. }
  14990.  
  14991. static INLINE void
  14992. util_format_i16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  14993. {
  14994.    unsigned x, y;
  14995.    for(y = 0; y < height; y += 1) {
  14996.       const unsigned *src = src_row;
  14997.       uint8_t *dst = dst_row;
  14998.       for(x = 0; x < width; x += 1) {
  14999.          uint16_t value = 0;
  15000.          value |= (uint16_t)MIN2(src[0], 65535);
  15001.          *(uint16_t *)dst = value;
  15002.          src += 4;
  15003.          dst += 2;
  15004.       }
  15005.       dst_row += dst_stride;
  15006.       src_row += src_stride/sizeof(*src_row);
  15007.    }
  15008. }
  15009.  
  15010. static INLINE void
  15011. util_format_i16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15012. {
  15013.          uint16_t value = *(const uint16_t *)src;
  15014.          uint16_t rgba;
  15015.          rgba = value;
  15016.          dst[0] = (unsigned)rgba; /* r */
  15017.          dst[1] = (unsigned)rgba; /* g */
  15018.          dst[2] = (unsigned)rgba; /* b */
  15019.          dst[3] = (unsigned)rgba; /* a */
  15020. }
  15021.  
  15022. static INLINE void
  15023. util_format_i16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15024. {
  15025.    unsigned x, y;
  15026.    for(y = 0; y < height; y += 1) {
  15027.       int *dst = dst_row;
  15028.       const uint8_t *src = src_row;
  15029.       for(x = 0; x < width; x += 1) {
  15030.          uint16_t value = *(const uint16_t *)src;
  15031.          uint16_t rgba;
  15032.          rgba = value;
  15033.          dst[0] = (int)rgba; /* r */
  15034.          dst[1] = (int)rgba; /* g */
  15035.          dst[2] = (int)rgba; /* b */
  15036.          dst[3] = (int)rgba; /* a */
  15037.          src += 2;
  15038.          dst += 4;
  15039.       }
  15040.       src_row += src_stride;
  15041.       dst_row += dst_stride/sizeof(*dst_row);
  15042.    }
  15043. }
  15044.  
  15045. static INLINE void
  15046. util_format_i16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15047. {
  15048.    unsigned x, y;
  15049.    for(y = 0; y < height; y += 1) {
  15050.       const int *src = src_row;
  15051.       uint8_t *dst = dst_row;
  15052.       for(x = 0; x < width; x += 1) {
  15053.          uint16_t value = 0;
  15054.          value |= (uint16_t)CLAMP(src[0], 0, 65535);
  15055.          *(uint16_t *)dst = value;
  15056.          src += 4;
  15057.          dst += 2;
  15058.       }
  15059.       dst_row += dst_stride;
  15060.       src_row += src_stride/sizeof(*src_row);
  15061.    }
  15062. }
  15063.  
  15064. union util_format_l16_uint {
  15065.    uint16_t value;
  15066.    struct {
  15067.       uint16_t rgb;
  15068.    } chan;
  15069. };
  15070.  
  15071. static INLINE void
  15072. util_format_l16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15073. {
  15074.    unsigned x, y;
  15075.    for(y = 0; y < height; y += 1) {
  15076.       unsigned *dst = dst_row;
  15077.       const uint8_t *src = src_row;
  15078.       for(x = 0; x < width; x += 1) {
  15079.          uint16_t value = *(const uint16_t *)src;
  15080.          uint16_t rgb;
  15081.          rgb = value;
  15082.          dst[0] = (unsigned)rgb; /* r */
  15083.          dst[1] = (unsigned)rgb; /* g */
  15084.          dst[2] = (unsigned)rgb; /* b */
  15085.          dst[3] = 1; /* a */
  15086.          src += 2;
  15087.          dst += 4;
  15088.       }
  15089.       src_row += src_stride;
  15090.       dst_row += dst_stride/sizeof(*dst_row);
  15091.    }
  15092. }
  15093.  
  15094. static INLINE void
  15095. util_format_l16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15096. {
  15097.    unsigned x, y;
  15098.    for(y = 0; y < height; y += 1) {
  15099.       const unsigned *src = src_row;
  15100.       uint8_t *dst = dst_row;
  15101.       for(x = 0; x < width; x += 1) {
  15102.          uint16_t value = 0;
  15103.          value |= (uint16_t)MIN2(src[0], 65535);
  15104.          *(uint16_t *)dst = value;
  15105.          src += 4;
  15106.          dst += 2;
  15107.       }
  15108.       dst_row += dst_stride;
  15109.       src_row += src_stride/sizeof(*src_row);
  15110.    }
  15111. }
  15112.  
  15113. static INLINE void
  15114. util_format_l16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15115. {
  15116.          uint16_t value = *(const uint16_t *)src;
  15117.          uint16_t rgb;
  15118.          rgb = value;
  15119.          dst[0] = (unsigned)rgb; /* r */
  15120.          dst[1] = (unsigned)rgb; /* g */
  15121.          dst[2] = (unsigned)rgb; /* b */
  15122.          dst[3] = 1; /* a */
  15123. }
  15124.  
  15125. static INLINE void
  15126. util_format_l16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15127. {
  15128.    unsigned x, y;
  15129.    for(y = 0; y < height; y += 1) {
  15130.       int *dst = dst_row;
  15131.       const uint8_t *src = src_row;
  15132.       for(x = 0; x < width; x += 1) {
  15133.          uint16_t value = *(const uint16_t *)src;
  15134.          uint16_t rgb;
  15135.          rgb = value;
  15136.          dst[0] = (int)rgb; /* r */
  15137.          dst[1] = (int)rgb; /* g */
  15138.          dst[2] = (int)rgb; /* b */
  15139.          dst[3] = 1; /* a */
  15140.          src += 2;
  15141.          dst += 4;
  15142.       }
  15143.       src_row += src_stride;
  15144.       dst_row += dst_stride/sizeof(*dst_row);
  15145.    }
  15146. }
  15147.  
  15148. static INLINE void
  15149. util_format_l16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15150. {
  15151.    unsigned x, y;
  15152.    for(y = 0; y < height; y += 1) {
  15153.       const int *src = src_row;
  15154.       uint8_t *dst = dst_row;
  15155.       for(x = 0; x < width; x += 1) {
  15156.          uint16_t value = 0;
  15157.          value |= (uint16_t)CLAMP(src[0], 0, 65535);
  15158.          *(uint16_t *)dst = value;
  15159.          src += 4;
  15160.          dst += 2;
  15161.       }
  15162.       dst_row += dst_stride;
  15163.       src_row += src_stride/sizeof(*src_row);
  15164.    }
  15165. }
  15166.  
  15167. union util_format_l16a16_uint {
  15168.    uint32_t value;
  15169.    struct {
  15170.       uint16_t rgb;
  15171.       uint16_t a;
  15172.    } chan;
  15173. };
  15174.  
  15175. static INLINE void
  15176. util_format_l16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15177. {
  15178.    unsigned x, y;
  15179.    for(y = 0; y < height; y += 1) {
  15180.       unsigned *dst = dst_row;
  15181.       const uint8_t *src = src_row;
  15182.       for(x = 0; x < width; x += 1) {
  15183.          uint32_t value = *(const uint32_t *)src;
  15184.          uint32_t rgb;
  15185.          uint32_t a;
  15186.          rgb = (value) & 0xffff;
  15187.          a = value >> 16;
  15188.          dst[0] = (unsigned)rgb; /* r */
  15189.          dst[1] = (unsigned)rgb; /* g */
  15190.          dst[2] = (unsigned)rgb; /* b */
  15191.          dst[3] = (unsigned)a; /* a */
  15192.          src += 4;
  15193.          dst += 4;
  15194.       }
  15195.       src_row += src_stride;
  15196.       dst_row += dst_stride/sizeof(*dst_row);
  15197.    }
  15198. }
  15199.  
  15200. static INLINE void
  15201. util_format_l16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15202. {
  15203.    unsigned x, y;
  15204.    for(y = 0; y < height; y += 1) {
  15205.       const unsigned *src = src_row;
  15206.       uint8_t *dst = dst_row;
  15207.       for(x = 0; x < width; x += 1) {
  15208.          uint32_t value = 0;
  15209.          value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
  15210.          value |= ((uint16_t)MIN2(src[3], 65535)) << 16;
  15211.          *(uint32_t *)dst = value;
  15212.          src += 4;
  15213.          dst += 4;
  15214.       }
  15215.       dst_row += dst_stride;
  15216.       src_row += src_stride/sizeof(*src_row);
  15217.    }
  15218. }
  15219.  
  15220. static INLINE void
  15221. util_format_l16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15222. {
  15223.          uint32_t value = *(const uint32_t *)src;
  15224.          uint32_t rgb;
  15225.          uint32_t a;
  15226.          rgb = (value) & 0xffff;
  15227.          a = value >> 16;
  15228.          dst[0] = (unsigned)rgb; /* r */
  15229.          dst[1] = (unsigned)rgb; /* g */
  15230.          dst[2] = (unsigned)rgb; /* b */
  15231.          dst[3] = (unsigned)a; /* a */
  15232. }
  15233.  
  15234. static INLINE void
  15235. util_format_l16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15236. {
  15237.    unsigned x, y;
  15238.    for(y = 0; y < height; y += 1) {
  15239.       int *dst = dst_row;
  15240.       const uint8_t *src = src_row;
  15241.       for(x = 0; x < width; x += 1) {
  15242.          uint32_t value = *(const uint32_t *)src;
  15243.          uint32_t rgb;
  15244.          uint32_t a;
  15245.          rgb = (value) & 0xffff;
  15246.          a = value >> 16;
  15247.          dst[0] = (int)rgb; /* r */
  15248.          dst[1] = (int)rgb; /* g */
  15249.          dst[2] = (int)rgb; /* b */
  15250.          dst[3] = (int)a; /* a */
  15251.          src += 4;
  15252.          dst += 4;
  15253.       }
  15254.       src_row += src_stride;
  15255.       dst_row += dst_stride/sizeof(*dst_row);
  15256.    }
  15257. }
  15258.  
  15259. static INLINE void
  15260. util_format_l16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15261. {
  15262.    unsigned x, y;
  15263.    for(y = 0; y < height; y += 1) {
  15264.       const int *src = src_row;
  15265.       uint8_t *dst = dst_row;
  15266.       for(x = 0; x < width; x += 1) {
  15267.          uint32_t value = 0;
  15268.          value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
  15269.          value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16;
  15270.          *(uint32_t *)dst = value;
  15271.          src += 4;
  15272.          dst += 4;
  15273.       }
  15274.       dst_row += dst_stride;
  15275.       src_row += src_stride/sizeof(*src_row);
  15276.    }
  15277. }
  15278.  
  15279. union util_format_a16_sint {
  15280.    uint16_t value;
  15281.    struct {
  15282.       int16_t a;
  15283.    } chan;
  15284. };
  15285.  
  15286. static INLINE void
  15287. util_format_a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15288. {
  15289.    unsigned x, y;
  15290.    for(y = 0; y < height; y += 1) {
  15291.       int *dst = dst_row;
  15292.       const uint8_t *src = src_row;
  15293.       for(x = 0; x < width; x += 1) {
  15294.          uint16_t value = *(const uint16_t *)src;
  15295.          int16_t a;
  15296.          a = (int16_t)(value) ;
  15297.          dst[0] = 0; /* r */
  15298.          dst[1] = 0; /* g */
  15299.          dst[2] = 0; /* b */
  15300.          dst[3] = (int)a; /* a */
  15301.          src += 2;
  15302.          dst += 4;
  15303.       }
  15304.       src_row += src_stride;
  15305.       dst_row += dst_stride/sizeof(*dst_row);
  15306.    }
  15307. }
  15308.  
  15309. static INLINE void
  15310. util_format_a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15311. {
  15312.    unsigned x, y;
  15313.    for(y = 0; y < height; y += 1) {
  15314.       const int *src = src_row;
  15315.       uint8_t *dst = dst_row;
  15316.       for(x = 0; x < width; x += 1) {
  15317.          uint16_t value = 0;
  15318.          value |= (uint16_t)((int16_t)CLAMP(src[3], -32768, 32767)) ;
  15319.          *(uint16_t *)dst = value;
  15320.          src += 4;
  15321.          dst += 2;
  15322.       }
  15323.       dst_row += dst_stride;
  15324.       src_row += src_stride/sizeof(*src_row);
  15325.    }
  15326. }
  15327.  
  15328. static INLINE void
  15329. util_format_a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  15330. {
  15331.          uint16_t value = *(const uint16_t *)src;
  15332.          int16_t a;
  15333.          a = (int16_t)(value) ;
  15334.          dst[0] = 0; /* r */
  15335.          dst[1] = 0; /* g */
  15336.          dst[2] = 0; /* b */
  15337.          dst[3] = (int)a; /* a */
  15338. }
  15339.  
  15340. static INLINE void
  15341. util_format_a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15342. {
  15343.    unsigned x, y;
  15344.    for(y = 0; y < height; y += 1) {
  15345.       unsigned *dst = dst_row;
  15346.       const uint8_t *src = src_row;
  15347.       for(x = 0; x < width; x += 1) {
  15348.          uint16_t value = *(const uint16_t *)src;
  15349.          int16_t a;
  15350.          a = (int16_t)(value) ;
  15351.          dst[0] = 0; /* r */
  15352.          dst[1] = 0; /* g */
  15353.          dst[2] = 0; /* b */
  15354.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  15355.          src += 2;
  15356.          dst += 4;
  15357.       }
  15358.       src_row += src_stride;
  15359.       dst_row += dst_stride/sizeof(*dst_row);
  15360.    }
  15361. }
  15362.  
  15363. static INLINE void
  15364. util_format_a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15365. {
  15366.    unsigned x, y;
  15367.    for(y = 0; y < height; y += 1) {
  15368.       const unsigned *src = src_row;
  15369.       uint8_t *dst = dst_row;
  15370.       for(x = 0; x < width; x += 1) {
  15371.          uint16_t value = 0;
  15372.          value |= (uint16_t)((int16_t)MIN2(src[3], 32767)) ;
  15373.          *(uint16_t *)dst = value;
  15374.          src += 4;
  15375.          dst += 2;
  15376.       }
  15377.       dst_row += dst_stride;
  15378.       src_row += src_stride/sizeof(*src_row);
  15379.    }
  15380. }
  15381.  
  15382. union util_format_i16_sint {
  15383.    uint16_t value;
  15384.    struct {
  15385.       int16_t rgba;
  15386.    } chan;
  15387. };
  15388.  
  15389. static INLINE void
  15390. util_format_i16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15391. {
  15392.    unsigned x, y;
  15393.    for(y = 0; y < height; y += 1) {
  15394.       int *dst = dst_row;
  15395.       const uint8_t *src = src_row;
  15396.       for(x = 0; x < width; x += 1) {
  15397.          uint16_t value = *(const uint16_t *)src;
  15398.          int16_t rgba;
  15399.          rgba = (int16_t)(value) ;
  15400.          dst[0] = (int)rgba; /* r */
  15401.          dst[1] = (int)rgba; /* g */
  15402.          dst[2] = (int)rgba; /* b */
  15403.          dst[3] = (int)rgba; /* a */
  15404.          src += 2;
  15405.          dst += 4;
  15406.       }
  15407.       src_row += src_stride;
  15408.       dst_row += dst_stride/sizeof(*dst_row);
  15409.    }
  15410. }
  15411.  
  15412. static INLINE void
  15413. util_format_i16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15414. {
  15415.    unsigned x, y;
  15416.    for(y = 0; y < height; y += 1) {
  15417.       const int *src = src_row;
  15418.       uint8_t *dst = dst_row;
  15419.       for(x = 0; x < width; x += 1) {
  15420.          uint16_t value = 0;
  15421.          value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
  15422.          *(uint16_t *)dst = value;
  15423.          src += 4;
  15424.          dst += 2;
  15425.       }
  15426.       dst_row += dst_stride;
  15427.       src_row += src_stride/sizeof(*src_row);
  15428.    }
  15429. }
  15430.  
  15431. static INLINE void
  15432. util_format_i16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  15433. {
  15434.          uint16_t value = *(const uint16_t *)src;
  15435.          int16_t rgba;
  15436.          rgba = (int16_t)(value) ;
  15437.          dst[0] = (int)rgba; /* r */
  15438.          dst[1] = (int)rgba; /* g */
  15439.          dst[2] = (int)rgba; /* b */
  15440.          dst[3] = (int)rgba; /* a */
  15441. }
  15442.  
  15443. static INLINE void
  15444. util_format_i16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15445. {
  15446.    unsigned x, y;
  15447.    for(y = 0; y < height; y += 1) {
  15448.       unsigned *dst = dst_row;
  15449.       const uint8_t *src = src_row;
  15450.       for(x = 0; x < width; x += 1) {
  15451.          uint16_t value = *(const uint16_t *)src;
  15452.          int16_t rgba;
  15453.          rgba = (int16_t)(value) ;
  15454.          dst[0] = (unsigned)MAX2(rgba, 0); /* r */
  15455.          dst[1] = (unsigned)MAX2(rgba, 0); /* g */
  15456.          dst[2] = (unsigned)MAX2(rgba, 0); /* b */
  15457.          dst[3] = (unsigned)MAX2(rgba, 0); /* a */
  15458.          src += 2;
  15459.          dst += 4;
  15460.       }
  15461.       src_row += src_stride;
  15462.       dst_row += dst_stride/sizeof(*dst_row);
  15463.    }
  15464. }
  15465.  
  15466. static INLINE void
  15467. util_format_i16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15468. {
  15469.    unsigned x, y;
  15470.    for(y = 0; y < height; y += 1) {
  15471.       const unsigned *src = src_row;
  15472.       uint8_t *dst = dst_row;
  15473.       for(x = 0; x < width; x += 1) {
  15474.          uint16_t value = 0;
  15475.          value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
  15476.          *(uint16_t *)dst = value;
  15477.          src += 4;
  15478.          dst += 2;
  15479.       }
  15480.       dst_row += dst_stride;
  15481.       src_row += src_stride/sizeof(*src_row);
  15482.    }
  15483. }
  15484.  
  15485. union util_format_l16_sint {
  15486.    uint16_t value;
  15487.    struct {
  15488.       int16_t rgb;
  15489.    } chan;
  15490. };
  15491.  
  15492. static INLINE void
  15493. util_format_l16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15494. {
  15495.    unsigned x, y;
  15496.    for(y = 0; y < height; y += 1) {
  15497.       int *dst = dst_row;
  15498.       const uint8_t *src = src_row;
  15499.       for(x = 0; x < width; x += 1) {
  15500.          uint16_t value = *(const uint16_t *)src;
  15501.          int16_t rgb;
  15502.          rgb = (int16_t)(value) ;
  15503.          dst[0] = (int)rgb; /* r */
  15504.          dst[1] = (int)rgb; /* g */
  15505.          dst[2] = (int)rgb; /* b */
  15506.          dst[3] = 1; /* a */
  15507.          src += 2;
  15508.          dst += 4;
  15509.       }
  15510.       src_row += src_stride;
  15511.       dst_row += dst_stride/sizeof(*dst_row);
  15512.    }
  15513. }
  15514.  
  15515. static INLINE void
  15516. util_format_l16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15517. {
  15518.    unsigned x, y;
  15519.    for(y = 0; y < height; y += 1) {
  15520.       const int *src = src_row;
  15521.       uint8_t *dst = dst_row;
  15522.       for(x = 0; x < width; x += 1) {
  15523.          uint16_t value = 0;
  15524.          value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ;
  15525.          *(uint16_t *)dst = value;
  15526.          src += 4;
  15527.          dst += 2;
  15528.       }
  15529.       dst_row += dst_stride;
  15530.       src_row += src_stride/sizeof(*src_row);
  15531.    }
  15532. }
  15533.  
  15534. static INLINE void
  15535. util_format_l16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  15536. {
  15537.          uint16_t value = *(const uint16_t *)src;
  15538.          int16_t rgb;
  15539.          rgb = (int16_t)(value) ;
  15540.          dst[0] = (int)rgb; /* r */
  15541.          dst[1] = (int)rgb; /* g */
  15542.          dst[2] = (int)rgb; /* b */
  15543.          dst[3] = 1; /* a */
  15544. }
  15545.  
  15546. static INLINE void
  15547. util_format_l16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15548. {
  15549.    unsigned x, y;
  15550.    for(y = 0; y < height; y += 1) {
  15551.       unsigned *dst = dst_row;
  15552.       const uint8_t *src = src_row;
  15553.       for(x = 0; x < width; x += 1) {
  15554.          uint16_t value = *(const uint16_t *)src;
  15555.          int16_t rgb;
  15556.          rgb = (int16_t)(value) ;
  15557.          dst[0] = (unsigned)MAX2(rgb, 0); /* r */
  15558.          dst[1] = (unsigned)MAX2(rgb, 0); /* g */
  15559.          dst[2] = (unsigned)MAX2(rgb, 0); /* b */
  15560.          dst[3] = 1; /* a */
  15561.          src += 2;
  15562.          dst += 4;
  15563.       }
  15564.       src_row += src_stride;
  15565.       dst_row += dst_stride/sizeof(*dst_row);
  15566.    }
  15567. }
  15568.  
  15569. static INLINE void
  15570. util_format_l16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15571. {
  15572.    unsigned x, y;
  15573.    for(y = 0; y < height; y += 1) {
  15574.       const unsigned *src = src_row;
  15575.       uint8_t *dst = dst_row;
  15576.       for(x = 0; x < width; x += 1) {
  15577.          uint16_t value = 0;
  15578.          value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ;
  15579.          *(uint16_t *)dst = value;
  15580.          src += 4;
  15581.          dst += 2;
  15582.       }
  15583.       dst_row += dst_stride;
  15584.       src_row += src_stride/sizeof(*src_row);
  15585.    }
  15586. }
  15587.  
  15588. union util_format_l16a16_sint {
  15589.    uint32_t value;
  15590.    struct {
  15591.       int16_t rgb;
  15592.       int16_t a;
  15593.    } chan;
  15594. };
  15595.  
  15596. static INLINE void
  15597. util_format_l16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15598. {
  15599.    unsigned x, y;
  15600.    for(y = 0; y < height; y += 1) {
  15601.       int *dst = dst_row;
  15602.       const uint8_t *src = src_row;
  15603.       for(x = 0; x < width; x += 1) {
  15604.          uint32_t value = *(const uint32_t *)src;
  15605.          int32_t rgb;
  15606.          int32_t a;
  15607.          rgb = ((int32_t)(value << 16) ) >> 16;
  15608.          a = ((int32_t)(value) ) >> 16;
  15609.          dst[0] = (int)rgb; /* r */
  15610.          dst[1] = (int)rgb; /* g */
  15611.          dst[2] = (int)rgb; /* b */
  15612.          dst[3] = (int)a; /* a */
  15613.          src += 4;
  15614.          dst += 4;
  15615.       }
  15616.       src_row += src_stride;
  15617.       dst_row += dst_stride/sizeof(*dst_row);
  15618.    }
  15619. }
  15620.  
  15621. static INLINE void
  15622. util_format_l16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15623. {
  15624.    unsigned x, y;
  15625.    for(y = 0; y < height; y += 1) {
  15626.       const int *src = src_row;
  15627.       uint8_t *dst = dst_row;
  15628.       for(x = 0; x < width; x += 1) {
  15629.          uint32_t value = 0;
  15630.          value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
  15631.          value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ;
  15632.          *(uint32_t *)dst = value;
  15633.          src += 4;
  15634.          dst += 4;
  15635.       }
  15636.       dst_row += dst_stride;
  15637.       src_row += src_stride/sizeof(*src_row);
  15638.    }
  15639. }
  15640.  
  15641. static INLINE void
  15642. util_format_l16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  15643. {
  15644.          uint32_t value = *(const uint32_t *)src;
  15645.          int32_t rgb;
  15646.          int32_t a;
  15647.          rgb = ((int32_t)(value << 16) ) >> 16;
  15648.          a = ((int32_t)(value) ) >> 16;
  15649.          dst[0] = (int)rgb; /* r */
  15650.          dst[1] = (int)rgb; /* g */
  15651.          dst[2] = (int)rgb; /* b */
  15652.          dst[3] = (int)a; /* a */
  15653. }
  15654.  
  15655. static INLINE void
  15656. util_format_l16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15657. {
  15658.    unsigned x, y;
  15659.    for(y = 0; y < height; y += 1) {
  15660.       unsigned *dst = dst_row;
  15661.       const uint8_t *src = src_row;
  15662.       for(x = 0; x < width; x += 1) {
  15663.          uint32_t value = *(const uint32_t *)src;
  15664.          int32_t rgb;
  15665.          int32_t a;
  15666.          rgb = ((int32_t)(value << 16) ) >> 16;
  15667.          a = ((int32_t)(value) ) >> 16;
  15668.          dst[0] = (unsigned)MAX2(rgb, 0); /* r */
  15669.          dst[1] = (unsigned)MAX2(rgb, 0); /* g */
  15670.          dst[2] = (unsigned)MAX2(rgb, 0); /* b */
  15671.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  15672.          src += 4;
  15673.          dst += 4;
  15674.       }
  15675.       src_row += src_stride;
  15676.       dst_row += dst_stride/sizeof(*dst_row);
  15677.    }
  15678. }
  15679.  
  15680. static INLINE void
  15681. util_format_l16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15682. {
  15683.    unsigned x, y;
  15684.    for(y = 0; y < height; y += 1) {
  15685.       const unsigned *src = src_row;
  15686.       uint8_t *dst = dst_row;
  15687.       for(x = 0; x < width; x += 1) {
  15688.          uint32_t value = 0;
  15689.          value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
  15690.          value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ;
  15691.          *(uint32_t *)dst = value;
  15692.          src += 4;
  15693.          dst += 4;
  15694.       }
  15695.       dst_row += dst_stride;
  15696.       src_row += src_stride/sizeof(*src_row);
  15697.    }
  15698. }
  15699.  
  15700. union util_format_a32_uint {
  15701.    uint32_t value;
  15702.    struct {
  15703.       uint32_t a;
  15704.    } chan;
  15705. };
  15706.  
  15707. static INLINE void
  15708. util_format_a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15709. {
  15710.    unsigned x, y;
  15711.    for(y = 0; y < height; y += 1) {
  15712.       unsigned *dst = dst_row;
  15713.       const uint8_t *src = src_row;
  15714.       for(x = 0; x < width; x += 1) {
  15715.          uint32_t value = *(const uint32_t *)src;
  15716.          uint32_t a;
  15717.          a = value;
  15718.          dst[0] = 0; /* r */
  15719.          dst[1] = 0; /* g */
  15720.          dst[2] = 0; /* b */
  15721.          dst[3] = a; /* a */
  15722.          src += 4;
  15723.          dst += 4;
  15724.       }
  15725.       src_row += src_stride;
  15726.       dst_row += dst_stride/sizeof(*dst_row);
  15727.    }
  15728. }
  15729.  
  15730. static INLINE void
  15731. util_format_a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15732. {
  15733.    unsigned x, y;
  15734.    for(y = 0; y < height; y += 1) {
  15735.       const unsigned *src = src_row;
  15736.       uint8_t *dst = dst_row;
  15737.       for(x = 0; x < width; x += 1) {
  15738.          uint32_t value = 0;
  15739.          value |= src[3];
  15740.          *(uint32_t *)dst = value;
  15741.          src += 4;
  15742.          dst += 4;
  15743.       }
  15744.       dst_row += dst_stride;
  15745.       src_row += src_stride/sizeof(*src_row);
  15746.    }
  15747. }
  15748.  
  15749. static INLINE void
  15750. util_format_a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15751. {
  15752.          uint32_t value = *(const uint32_t *)src;
  15753.          uint32_t a;
  15754.          a = value;
  15755.          dst[0] = 0; /* r */
  15756.          dst[1] = 0; /* g */
  15757.          dst[2] = 0; /* b */
  15758.          dst[3] = a; /* a */
  15759. }
  15760.  
  15761. static INLINE void
  15762. util_format_a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15763. {
  15764.    unsigned x, y;
  15765.    for(y = 0; y < height; y += 1) {
  15766.       int *dst = dst_row;
  15767.       const uint8_t *src = src_row;
  15768.       for(x = 0; x < width; x += 1) {
  15769.          uint32_t value = *(const uint32_t *)src;
  15770.          uint32_t a;
  15771.          a = value;
  15772.          dst[0] = 0; /* r */
  15773.          dst[1] = 0; /* g */
  15774.          dst[2] = 0; /* b */
  15775.          dst[3] = (int)MIN2(a, 2147483647); /* a */
  15776.          src += 4;
  15777.          dst += 4;
  15778.       }
  15779.       src_row += src_stride;
  15780.       dst_row += dst_stride/sizeof(*dst_row);
  15781.    }
  15782. }
  15783.  
  15784. static INLINE void
  15785. util_format_a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15786. {
  15787.    unsigned x, y;
  15788.    for(y = 0; y < height; y += 1) {
  15789.       const int *src = src_row;
  15790.       uint8_t *dst = dst_row;
  15791.       for(x = 0; x < width; x += 1) {
  15792.          uint32_t value = 0;
  15793.          value |= (uint32_t)MAX2(src[3], 0);
  15794.          *(uint32_t *)dst = value;
  15795.          src += 4;
  15796.          dst += 4;
  15797.       }
  15798.       dst_row += dst_stride;
  15799.       src_row += src_stride/sizeof(*src_row);
  15800.    }
  15801. }
  15802.  
  15803. union util_format_i32_uint {
  15804.    uint32_t value;
  15805.    struct {
  15806.       uint32_t rgba;
  15807.    } chan;
  15808. };
  15809.  
  15810. static INLINE void
  15811. util_format_i32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15812. {
  15813.    unsigned x, y;
  15814.    for(y = 0; y < height; y += 1) {
  15815.       unsigned *dst = dst_row;
  15816.       const uint8_t *src = src_row;
  15817.       for(x = 0; x < width; x += 1) {
  15818.          uint32_t value = *(const uint32_t *)src;
  15819.          uint32_t rgba;
  15820.          rgba = value;
  15821.          dst[0] = rgba; /* r */
  15822.          dst[1] = rgba; /* g */
  15823.          dst[2] = rgba; /* b */
  15824.          dst[3] = rgba; /* a */
  15825.          src += 4;
  15826.          dst += 4;
  15827.       }
  15828.       src_row += src_stride;
  15829.       dst_row += dst_stride/sizeof(*dst_row);
  15830.    }
  15831. }
  15832.  
  15833. static INLINE void
  15834. util_format_i32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15835. {
  15836.    unsigned x, y;
  15837.    for(y = 0; y < height; y += 1) {
  15838.       const unsigned *src = src_row;
  15839.       uint8_t *dst = dst_row;
  15840.       for(x = 0; x < width; x += 1) {
  15841.          uint32_t value = 0;
  15842.          value |= src[0];
  15843.          *(uint32_t *)dst = value;
  15844.          src += 4;
  15845.          dst += 4;
  15846.       }
  15847.       dst_row += dst_stride;
  15848.       src_row += src_stride/sizeof(*src_row);
  15849.    }
  15850. }
  15851.  
  15852. static INLINE void
  15853. util_format_i32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15854. {
  15855.          uint32_t value = *(const uint32_t *)src;
  15856.          uint32_t rgba;
  15857.          rgba = value;
  15858.          dst[0] = rgba; /* r */
  15859.          dst[1] = rgba; /* g */
  15860.          dst[2] = rgba; /* b */
  15861.          dst[3] = rgba; /* a */
  15862. }
  15863.  
  15864. static INLINE void
  15865. util_format_i32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15866. {
  15867.    unsigned x, y;
  15868.    for(y = 0; y < height; y += 1) {
  15869.       int *dst = dst_row;
  15870.       const uint8_t *src = src_row;
  15871.       for(x = 0; x < width; x += 1) {
  15872.          uint32_t value = *(const uint32_t *)src;
  15873.          uint32_t rgba;
  15874.          rgba = value;
  15875.          dst[0] = (int)MIN2(rgba, 2147483647); /* r */
  15876.          dst[1] = (int)MIN2(rgba, 2147483647); /* g */
  15877.          dst[2] = (int)MIN2(rgba, 2147483647); /* b */
  15878.          dst[3] = (int)MIN2(rgba, 2147483647); /* a */
  15879.          src += 4;
  15880.          dst += 4;
  15881.       }
  15882.       src_row += src_stride;
  15883.       dst_row += dst_stride/sizeof(*dst_row);
  15884.    }
  15885. }
  15886.  
  15887. static INLINE void
  15888. util_format_i32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15889. {
  15890.    unsigned x, y;
  15891.    for(y = 0; y < height; y += 1) {
  15892.       const int *src = src_row;
  15893.       uint8_t *dst = dst_row;
  15894.       for(x = 0; x < width; x += 1) {
  15895.          uint32_t value = 0;
  15896.          value |= (uint32_t)MAX2(src[0], 0);
  15897.          *(uint32_t *)dst = value;
  15898.          src += 4;
  15899.          dst += 4;
  15900.       }
  15901.       dst_row += dst_stride;
  15902.       src_row += src_stride/sizeof(*src_row);
  15903.    }
  15904. }
  15905.  
  15906. union util_format_l32_uint {
  15907.    uint32_t value;
  15908.    struct {
  15909.       uint32_t rgb;
  15910.    } chan;
  15911. };
  15912.  
  15913. static INLINE void
  15914. util_format_l32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15915. {
  15916.    unsigned x, y;
  15917.    for(y = 0; y < height; y += 1) {
  15918.       unsigned *dst = dst_row;
  15919.       const uint8_t *src = src_row;
  15920.       for(x = 0; x < width; x += 1) {
  15921.          uint32_t value = *(const uint32_t *)src;
  15922.          uint32_t rgb;
  15923.          rgb = value;
  15924.          dst[0] = rgb; /* r */
  15925.          dst[1] = rgb; /* g */
  15926.          dst[2] = rgb; /* b */
  15927.          dst[3] = 1; /* a */
  15928.          src += 4;
  15929.          dst += 4;
  15930.       }
  15931.       src_row += src_stride;
  15932.       dst_row += dst_stride/sizeof(*dst_row);
  15933.    }
  15934. }
  15935.  
  15936. static INLINE void
  15937. util_format_l32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  15938. {
  15939.    unsigned x, y;
  15940.    for(y = 0; y < height; y += 1) {
  15941.       const unsigned *src = src_row;
  15942.       uint8_t *dst = dst_row;
  15943.       for(x = 0; x < width; x += 1) {
  15944.          uint32_t value = 0;
  15945.          value |= src[0];
  15946.          *(uint32_t *)dst = value;
  15947.          src += 4;
  15948.          dst += 4;
  15949.       }
  15950.       dst_row += dst_stride;
  15951.       src_row += src_stride/sizeof(*src_row);
  15952.    }
  15953. }
  15954.  
  15955. static INLINE void
  15956. util_format_l32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  15957. {
  15958.          uint32_t value = *(const uint32_t *)src;
  15959.          uint32_t rgb;
  15960.          rgb = value;
  15961.          dst[0] = rgb; /* r */
  15962.          dst[1] = rgb; /* g */
  15963.          dst[2] = rgb; /* b */
  15964.          dst[3] = 1; /* a */
  15965. }
  15966.  
  15967. static INLINE void
  15968. util_format_l32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  15969. {
  15970.    unsigned x, y;
  15971.    for(y = 0; y < height; y += 1) {
  15972.       int *dst = dst_row;
  15973.       const uint8_t *src = src_row;
  15974.       for(x = 0; x < width; x += 1) {
  15975.          uint32_t value = *(const uint32_t *)src;
  15976.          uint32_t rgb;
  15977.          rgb = value;
  15978.          dst[0] = (int)MIN2(rgb, 2147483647); /* r */
  15979.          dst[1] = (int)MIN2(rgb, 2147483647); /* g */
  15980.          dst[2] = (int)MIN2(rgb, 2147483647); /* b */
  15981.          dst[3] = 1; /* a */
  15982.          src += 4;
  15983.          dst += 4;
  15984.       }
  15985.       src_row += src_stride;
  15986.       dst_row += dst_stride/sizeof(*dst_row);
  15987.    }
  15988. }
  15989.  
  15990. static INLINE void
  15991. util_format_l32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  15992. {
  15993.    unsigned x, y;
  15994.    for(y = 0; y < height; y += 1) {
  15995.       const int *src = src_row;
  15996.       uint8_t *dst = dst_row;
  15997.       for(x = 0; x < width; x += 1) {
  15998.          uint32_t value = 0;
  15999.          value |= (uint32_t)MAX2(src[0], 0);
  16000.          *(uint32_t *)dst = value;
  16001.          src += 4;
  16002.          dst += 4;
  16003.       }
  16004.       dst_row += dst_stride;
  16005.       src_row += src_stride/sizeof(*src_row);
  16006.    }
  16007. }
  16008.  
  16009. union util_format_l32a32_uint {
  16010.    uint64_t value;
  16011.    struct {
  16012.       uint32_t rgb;
  16013.       uint32_t a;
  16014.    } chan;
  16015. };
  16016.  
  16017. static INLINE void
  16018. util_format_l32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16019. {
  16020.    unsigned x, y;
  16021.    for(y = 0; y < height; y += 1) {
  16022.       unsigned *dst = dst_row;
  16023.       const uint8_t *src = src_row;
  16024.       for(x = 0; x < width; x += 1) {
  16025.          union util_format_l32a32_uint pixel;
  16026.          memcpy(&pixel, src, sizeof pixel);
  16027.          dst[0] = pixel.chan.rgb; /* r */
  16028.          dst[1] = pixel.chan.rgb; /* g */
  16029.          dst[2] = pixel.chan.rgb; /* b */
  16030.          dst[3] = pixel.chan.a; /* a */
  16031.          src += 8;
  16032.          dst += 4;
  16033.       }
  16034.       src_row += src_stride;
  16035.       dst_row += dst_stride/sizeof(*dst_row);
  16036.    }
  16037. }
  16038.  
  16039. static INLINE void
  16040. util_format_l32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16041. {
  16042.    unsigned x, y;
  16043.    for(y = 0; y < height; y += 1) {
  16044.       const unsigned *src = src_row;
  16045.       uint8_t *dst = dst_row;
  16046.       for(x = 0; x < width; x += 1) {
  16047.          union util_format_l32a32_uint pixel;
  16048.          pixel.chan.rgb = src[0];
  16049.          pixel.chan.a = src[3];
  16050.          memcpy(dst, &pixel, sizeof pixel);
  16051.          src += 4;
  16052.          dst += 8;
  16053.       }
  16054.       dst_row += dst_stride;
  16055.       src_row += src_stride/sizeof(*src_row);
  16056.    }
  16057. }
  16058.  
  16059. static INLINE void
  16060. util_format_l32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  16061. {
  16062.          union util_format_l32a32_uint pixel;
  16063.          memcpy(&pixel, src, sizeof pixel);
  16064.          dst[0] = pixel.chan.rgb; /* r */
  16065.          dst[1] = pixel.chan.rgb; /* g */
  16066.          dst[2] = pixel.chan.rgb; /* b */
  16067.          dst[3] = pixel.chan.a; /* a */
  16068. }
  16069.  
  16070. static INLINE void
  16071. util_format_l32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16072. {
  16073.    unsigned x, y;
  16074.    for(y = 0; y < height; y += 1) {
  16075.       int *dst = dst_row;
  16076.       const uint8_t *src = src_row;
  16077.       for(x = 0; x < width; x += 1) {
  16078.          union util_format_l32a32_uint pixel;
  16079.          memcpy(&pixel, src, sizeof pixel);
  16080.          dst[0] = (int)MIN2(pixel.chan.rgb, 2147483647); /* r */
  16081.          dst[1] = (int)MIN2(pixel.chan.rgb, 2147483647); /* g */
  16082.          dst[2] = (int)MIN2(pixel.chan.rgb, 2147483647); /* b */
  16083.          dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
  16084.          src += 8;
  16085.          dst += 4;
  16086.       }
  16087.       src_row += src_stride;
  16088.       dst_row += dst_stride/sizeof(*dst_row);
  16089.    }
  16090. }
  16091.  
  16092. static INLINE void
  16093. util_format_l32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16094. {
  16095.    unsigned x, y;
  16096.    for(y = 0; y < height; y += 1) {
  16097.       const int *src = src_row;
  16098.       uint8_t *dst = dst_row;
  16099.       for(x = 0; x < width; x += 1) {
  16100.          union util_format_l32a32_uint pixel;
  16101.          pixel.chan.rgb = (uint32_t)MAX2(src[0], 0);
  16102.          pixel.chan.a = (uint32_t)MAX2(src[3], 0);
  16103.          memcpy(dst, &pixel, sizeof pixel);
  16104.          src += 4;
  16105.          dst += 8;
  16106.       }
  16107.       dst_row += dst_stride;
  16108.       src_row += src_stride/sizeof(*src_row);
  16109.    }
  16110. }
  16111.  
  16112. union util_format_a32_sint {
  16113.    uint32_t value;
  16114.    struct {
  16115.       int32_t a;
  16116.    } chan;
  16117. };
  16118.  
  16119. static INLINE void
  16120. util_format_a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16121. {
  16122.    unsigned x, y;
  16123.    for(y = 0; y < height; y += 1) {
  16124.       int *dst = dst_row;
  16125.       const uint8_t *src = src_row;
  16126.       for(x = 0; x < width; x += 1) {
  16127.          uint32_t value = *(const uint32_t *)src;
  16128.          int32_t a;
  16129.          a = (int32_t)(value) ;
  16130.          dst[0] = 0; /* r */
  16131.          dst[1] = 0; /* g */
  16132.          dst[2] = 0; /* b */
  16133.          dst[3] = a; /* a */
  16134.          src += 4;
  16135.          dst += 4;
  16136.       }
  16137.       src_row += src_stride;
  16138.       dst_row += dst_stride/sizeof(*dst_row);
  16139.    }
  16140. }
  16141.  
  16142. static INLINE void
  16143. util_format_a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16144. {
  16145.    unsigned x, y;
  16146.    for(y = 0; y < height; y += 1) {
  16147.       const int *src = src_row;
  16148.       uint8_t *dst = dst_row;
  16149.       for(x = 0; x < width; x += 1) {
  16150.          uint32_t value = 0;
  16151.          value |= (uint32_t)(src[3]) ;
  16152.          *(uint32_t *)dst = value;
  16153.          src += 4;
  16154.          dst += 4;
  16155.       }
  16156.       dst_row += dst_stride;
  16157.       src_row += src_stride/sizeof(*src_row);
  16158.    }
  16159. }
  16160.  
  16161. static INLINE void
  16162. util_format_a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  16163. {
  16164.          uint32_t value = *(const uint32_t *)src;
  16165.          int32_t a;
  16166.          a = (int32_t)(value) ;
  16167.          dst[0] = 0; /* r */
  16168.          dst[1] = 0; /* g */
  16169.          dst[2] = 0; /* b */
  16170.          dst[3] = a; /* a */
  16171. }
  16172.  
  16173. static INLINE void
  16174. util_format_a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16175. {
  16176.    unsigned x, y;
  16177.    for(y = 0; y < height; y += 1) {
  16178.       unsigned *dst = dst_row;
  16179.       const uint8_t *src = src_row;
  16180.       for(x = 0; x < width; x += 1) {
  16181.          uint32_t value = *(const uint32_t *)src;
  16182.          int32_t a;
  16183.          a = (int32_t)(value) ;
  16184.          dst[0] = 0; /* r */
  16185.          dst[1] = 0; /* g */
  16186.          dst[2] = 0; /* b */
  16187.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  16188.          src += 4;
  16189.          dst += 4;
  16190.       }
  16191.       src_row += src_stride;
  16192.       dst_row += dst_stride/sizeof(*dst_row);
  16193.    }
  16194. }
  16195.  
  16196. static INLINE void
  16197. util_format_a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16198. {
  16199.    unsigned x, y;
  16200.    for(y = 0; y < height; y += 1) {
  16201.       const unsigned *src = src_row;
  16202.       uint8_t *dst = dst_row;
  16203.       for(x = 0; x < width; x += 1) {
  16204.          uint32_t value = 0;
  16205.          value |= (uint32_t)((int32_t)MIN2(src[3], 2147483647)) ;
  16206.          *(uint32_t *)dst = value;
  16207.          src += 4;
  16208.          dst += 4;
  16209.       }
  16210.       dst_row += dst_stride;
  16211.       src_row += src_stride/sizeof(*src_row);
  16212.    }
  16213. }
  16214.  
  16215. union util_format_i32_sint {
  16216.    uint32_t value;
  16217.    struct {
  16218.       int32_t rgba;
  16219.    } chan;
  16220. };
  16221.  
  16222. static INLINE void
  16223. util_format_i32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16224. {
  16225.    unsigned x, y;
  16226.    for(y = 0; y < height; y += 1) {
  16227.       int *dst = dst_row;
  16228.       const uint8_t *src = src_row;
  16229.       for(x = 0; x < width; x += 1) {
  16230.          uint32_t value = *(const uint32_t *)src;
  16231.          int32_t rgba;
  16232.          rgba = (int32_t)(value) ;
  16233.          dst[0] = rgba; /* r */
  16234.          dst[1] = rgba; /* g */
  16235.          dst[2] = rgba; /* b */
  16236.          dst[3] = rgba; /* a */
  16237.          src += 4;
  16238.          dst += 4;
  16239.       }
  16240.       src_row += src_stride;
  16241.       dst_row += dst_stride/sizeof(*dst_row);
  16242.    }
  16243. }
  16244.  
  16245. static INLINE void
  16246. util_format_i32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16247. {
  16248.    unsigned x, y;
  16249.    for(y = 0; y < height; y += 1) {
  16250.       const int *src = src_row;
  16251.       uint8_t *dst = dst_row;
  16252.       for(x = 0; x < width; x += 1) {
  16253.          uint32_t value = 0;
  16254.          value |= (uint32_t)(src[0]) ;
  16255.          *(uint32_t *)dst = value;
  16256.          src += 4;
  16257.          dst += 4;
  16258.       }
  16259.       dst_row += dst_stride;
  16260.       src_row += src_stride/sizeof(*src_row);
  16261.    }
  16262. }
  16263.  
  16264. static INLINE void
  16265. util_format_i32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  16266. {
  16267.          uint32_t value = *(const uint32_t *)src;
  16268.          int32_t rgba;
  16269.          rgba = (int32_t)(value) ;
  16270.          dst[0] = rgba; /* r */
  16271.          dst[1] = rgba; /* g */
  16272.          dst[2] = rgba; /* b */
  16273.          dst[3] = rgba; /* a */
  16274. }
  16275.  
  16276. static INLINE void
  16277. util_format_i32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16278. {
  16279.    unsigned x, y;
  16280.    for(y = 0; y < height; y += 1) {
  16281.       unsigned *dst = dst_row;
  16282.       const uint8_t *src = src_row;
  16283.       for(x = 0; x < width; x += 1) {
  16284.          uint32_t value = *(const uint32_t *)src;
  16285.          int32_t rgba;
  16286.          rgba = (int32_t)(value) ;
  16287.          dst[0] = (unsigned)MAX2(rgba, 0); /* r */
  16288.          dst[1] = (unsigned)MAX2(rgba, 0); /* g */
  16289.          dst[2] = (unsigned)MAX2(rgba, 0); /* b */
  16290.          dst[3] = (unsigned)MAX2(rgba, 0); /* a */
  16291.          src += 4;
  16292.          dst += 4;
  16293.       }
  16294.       src_row += src_stride;
  16295.       dst_row += dst_stride/sizeof(*dst_row);
  16296.    }
  16297. }
  16298.  
  16299. static INLINE void
  16300. util_format_i32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16301. {
  16302.    unsigned x, y;
  16303.    for(y = 0; y < height; y += 1) {
  16304.       const unsigned *src = src_row;
  16305.       uint8_t *dst = dst_row;
  16306.       for(x = 0; x < width; x += 1) {
  16307.          uint32_t value = 0;
  16308.          value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
  16309.          *(uint32_t *)dst = value;
  16310.          src += 4;
  16311.          dst += 4;
  16312.       }
  16313.       dst_row += dst_stride;
  16314.       src_row += src_stride/sizeof(*src_row);
  16315.    }
  16316. }
  16317.  
  16318. union util_format_l32_sint {
  16319.    uint32_t value;
  16320.    struct {
  16321.       int32_t rgb;
  16322.    } chan;
  16323. };
  16324.  
  16325. static INLINE void
  16326. util_format_l32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16327. {
  16328.    unsigned x, y;
  16329.    for(y = 0; y < height; y += 1) {
  16330.       int *dst = dst_row;
  16331.       const uint8_t *src = src_row;
  16332.       for(x = 0; x < width; x += 1) {
  16333.          uint32_t value = *(const uint32_t *)src;
  16334.          int32_t rgb;
  16335.          rgb = (int32_t)(value) ;
  16336.          dst[0] = rgb; /* r */
  16337.          dst[1] = rgb; /* g */
  16338.          dst[2] = rgb; /* b */
  16339.          dst[3] = 1; /* a */
  16340.          src += 4;
  16341.          dst += 4;
  16342.       }
  16343.       src_row += src_stride;
  16344.       dst_row += dst_stride/sizeof(*dst_row);
  16345.    }
  16346. }
  16347.  
  16348. static INLINE void
  16349. util_format_l32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16350. {
  16351.    unsigned x, y;
  16352.    for(y = 0; y < height; y += 1) {
  16353.       const int *src = src_row;
  16354.       uint8_t *dst = dst_row;
  16355.       for(x = 0; x < width; x += 1) {
  16356.          uint32_t value = 0;
  16357.          value |= (uint32_t)(src[0]) ;
  16358.          *(uint32_t *)dst = value;
  16359.          src += 4;
  16360.          dst += 4;
  16361.       }
  16362.       dst_row += dst_stride;
  16363.       src_row += src_stride/sizeof(*src_row);
  16364.    }
  16365. }
  16366.  
  16367. static INLINE void
  16368. util_format_l32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  16369. {
  16370.          uint32_t value = *(const uint32_t *)src;
  16371.          int32_t rgb;
  16372.          rgb = (int32_t)(value) ;
  16373.          dst[0] = rgb; /* r */
  16374.          dst[1] = rgb; /* g */
  16375.          dst[2] = rgb; /* b */
  16376.          dst[3] = 1; /* a */
  16377. }
  16378.  
  16379. static INLINE void
  16380. util_format_l32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16381. {
  16382.    unsigned x, y;
  16383.    for(y = 0; y < height; y += 1) {
  16384.       unsigned *dst = dst_row;
  16385.       const uint8_t *src = src_row;
  16386.       for(x = 0; x < width; x += 1) {
  16387.          uint32_t value = *(const uint32_t *)src;
  16388.          int32_t rgb;
  16389.          rgb = (int32_t)(value) ;
  16390.          dst[0] = (unsigned)MAX2(rgb, 0); /* r */
  16391.          dst[1] = (unsigned)MAX2(rgb, 0); /* g */
  16392.          dst[2] = (unsigned)MAX2(rgb, 0); /* b */
  16393.          dst[3] = 1; /* a */
  16394.          src += 4;
  16395.          dst += 4;
  16396.       }
  16397.       src_row += src_stride;
  16398.       dst_row += dst_stride/sizeof(*dst_row);
  16399.    }
  16400. }
  16401.  
  16402. static INLINE void
  16403. util_format_l32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16404. {
  16405.    unsigned x, y;
  16406.    for(y = 0; y < height; y += 1) {
  16407.       const unsigned *src = src_row;
  16408.       uint8_t *dst = dst_row;
  16409.       for(x = 0; x < width; x += 1) {
  16410.          uint32_t value = 0;
  16411.          value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ;
  16412.          *(uint32_t *)dst = value;
  16413.          src += 4;
  16414.          dst += 4;
  16415.       }
  16416.       dst_row += dst_stride;
  16417.       src_row += src_stride/sizeof(*src_row);
  16418.    }
  16419. }
  16420.  
  16421. union util_format_l32a32_sint {
  16422.    uint64_t value;
  16423.    struct {
  16424.       int32_t rgb;
  16425.       int32_t a;
  16426.    } chan;
  16427. };
  16428.  
  16429. static INLINE void
  16430. util_format_l32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16431. {
  16432.    unsigned x, y;
  16433.    for(y = 0; y < height; y += 1) {
  16434.       int *dst = dst_row;
  16435.       const uint8_t *src = src_row;
  16436.       for(x = 0; x < width; x += 1) {
  16437.          union util_format_l32a32_sint pixel;
  16438.          memcpy(&pixel, src, sizeof pixel);
  16439.          dst[0] = pixel.chan.rgb; /* r */
  16440.          dst[1] = pixel.chan.rgb; /* g */
  16441.          dst[2] = pixel.chan.rgb; /* b */
  16442.          dst[3] = pixel.chan.a; /* a */
  16443.          src += 8;
  16444.          dst += 4;
  16445.       }
  16446.       src_row += src_stride;
  16447.       dst_row += dst_stride/sizeof(*dst_row);
  16448.    }
  16449. }
  16450.  
  16451. static INLINE void
  16452. util_format_l32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16453. {
  16454.    unsigned x, y;
  16455.    for(y = 0; y < height; y += 1) {
  16456.       const int *src = src_row;
  16457.       uint8_t *dst = dst_row;
  16458.       for(x = 0; x < width; x += 1) {
  16459.          union util_format_l32a32_sint pixel;
  16460.          pixel.chan.rgb = src[0];
  16461.          pixel.chan.a = src[3];
  16462.          memcpy(dst, &pixel, sizeof pixel);
  16463.          src += 4;
  16464.          dst += 8;
  16465.       }
  16466.       dst_row += dst_stride;
  16467.       src_row += src_stride/sizeof(*src_row);
  16468.    }
  16469. }
  16470.  
  16471. static INLINE void
  16472. util_format_l32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  16473. {
  16474.          union util_format_l32a32_sint pixel;
  16475.          memcpy(&pixel, src, sizeof pixel);
  16476.          dst[0] = pixel.chan.rgb; /* r */
  16477.          dst[1] = pixel.chan.rgb; /* g */
  16478.          dst[2] = pixel.chan.rgb; /* b */
  16479.          dst[3] = pixel.chan.a; /* a */
  16480. }
  16481.  
  16482. static INLINE void
  16483. util_format_l32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16484. {
  16485.    unsigned x, y;
  16486.    for(y = 0; y < height; y += 1) {
  16487.       unsigned *dst = dst_row;
  16488.       const uint8_t *src = src_row;
  16489.       for(x = 0; x < width; x += 1) {
  16490.          union util_format_l32a32_sint pixel;
  16491.          memcpy(&pixel, src, sizeof pixel);
  16492.          dst[0] = (unsigned)MAX2(pixel.chan.rgb, 0); /* r */
  16493.          dst[1] = (unsigned)MAX2(pixel.chan.rgb, 0); /* g */
  16494.          dst[2] = (unsigned)MAX2(pixel.chan.rgb, 0); /* b */
  16495.          dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
  16496.          src += 8;
  16497.          dst += 4;
  16498.       }
  16499.       src_row += src_stride;
  16500.       dst_row += dst_stride/sizeof(*dst_row);
  16501.    }
  16502. }
  16503.  
  16504. static INLINE void
  16505. util_format_l32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16506. {
  16507.    unsigned x, y;
  16508.    for(y = 0; y < height; y += 1) {
  16509.       const unsigned *src = src_row;
  16510.       uint8_t *dst = dst_row;
  16511.       for(x = 0; x < width; x += 1) {
  16512.          union util_format_l32a32_sint pixel;
  16513.          pixel.chan.rgb = (int32_t)MIN2(src[0], 2147483647);
  16514.          pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
  16515.          memcpy(dst, &pixel, sizeof pixel);
  16516.          src += 4;
  16517.          dst += 8;
  16518.       }
  16519.       dst_row += dst_stride;
  16520.       src_row += src_stride/sizeof(*src_row);
  16521.    }
  16522. }
  16523.  
  16524. union util_format_r8g8b8x8_snorm {
  16525.    uint32_t value;
  16526.    struct {
  16527.       int8_t r;
  16528.       int8_t g;
  16529.       int8_t b;
  16530.       uint8_t x;
  16531.    } chan;
  16532. };
  16533.  
  16534. static INLINE void
  16535. util_format_r8g8b8x8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16536. {
  16537.    unsigned x, y;
  16538.    for(y = 0; y < height; y += 1) {
  16539.       float *dst = dst_row;
  16540.       const uint8_t *src = src_row;
  16541.       for(x = 0; x < width; x += 1) {
  16542.          uint32_t value = *(const uint32_t *)src;
  16543.          int32_t r;
  16544.          int32_t g;
  16545.          int32_t b;
  16546.          r = ((int32_t)(value << 24) ) >> 24;
  16547.          g = ((int32_t)(value << 16) ) >> 24;
  16548.          b = ((int32_t)(value << 8) ) >> 24;
  16549.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  16550.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  16551.          dst[2] = (float)(b * (1.0f/0x7f)); /* b */
  16552.          dst[3] = 1; /* a */
  16553.          src += 4;
  16554.          dst += 4;
  16555.       }
  16556.       src_row += src_stride;
  16557.       dst_row += dst_stride/sizeof(*dst_row);
  16558.    }
  16559. }
  16560.  
  16561. static INLINE void
  16562. util_format_r8g8b8x8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  16563. {
  16564.    unsigned x, y;
  16565.    for(y = 0; y < height; y += 1) {
  16566.       const float *src = src_row;
  16567.       uint8_t *dst = dst_row;
  16568.       for(x = 0; x < width; x += 1) {
  16569.          uint32_t value = 0;
  16570.          value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  16571.          value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ;
  16572.          value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ;
  16573.          *(uint32_t *)dst = value;
  16574.          src += 4;
  16575.          dst += 4;
  16576.       }
  16577.       dst_row += dst_stride;
  16578.       src_row += src_stride/sizeof(*src_row);
  16579.    }
  16580. }
  16581.  
  16582. static INLINE void
  16583. util_format_r8g8b8x8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  16584. {
  16585.          uint32_t value = *(const uint32_t *)src;
  16586.          int32_t r;
  16587.          int32_t g;
  16588.          int32_t b;
  16589.          r = ((int32_t)(value << 24) ) >> 24;
  16590.          g = ((int32_t)(value << 16) ) >> 24;
  16591.          b = ((int32_t)(value << 8) ) >> 24;
  16592.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  16593.          dst[1] = (float)(g * (1.0f/0x7f)); /* g */
  16594.          dst[2] = (float)(b * (1.0f/0x7f)); /* b */
  16595.          dst[3] = 1; /* a */
  16596. }
  16597.  
  16598. static INLINE void
  16599. util_format_r8g8b8x8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16600. {
  16601.    unsigned x, y;
  16602.    for(y = 0; y < height; y += 1) {
  16603.       uint8_t *dst = dst_row;
  16604.       const uint8_t *src = src_row;
  16605.       for(x = 0; x < width; x += 1) {
  16606.          uint32_t value = *(const uint32_t *)src;
  16607.          int32_t r;
  16608.          int32_t g;
  16609.          int32_t b;
  16610.          r = ((int32_t)(value << 24) ) >> 24;
  16611.          g = ((int32_t)(value << 16) ) >> 24;
  16612.          b = ((int32_t)(value << 8) ) >> 24;
  16613.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  16614.          dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */
  16615.          dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */
  16616.          dst[3] = 255; /* a */
  16617.          src += 4;
  16618.          dst += 4;
  16619.       }
  16620.       src_row += src_stride;
  16621.       dst_row += dst_stride/sizeof(*dst_row);
  16622.    }
  16623. }
  16624.  
  16625. static INLINE void
  16626. util_format_r8g8b8x8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16627. {
  16628.    unsigned x, y;
  16629.    for(y = 0; y < height; y += 1) {
  16630.       const uint8_t *src = src_row;
  16631.       uint8_t *dst = dst_row;
  16632.       for(x = 0; x < width; x += 1) {
  16633.          uint32_t value = 0;
  16634.          value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
  16635.          value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ;
  16636.          value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ;
  16637.          *(uint32_t *)dst = value;
  16638.          src += 4;
  16639.          dst += 4;
  16640.       }
  16641.       dst_row += dst_stride;
  16642.       src_row += src_stride/sizeof(*src_row);
  16643.    }
  16644. }
  16645.  
  16646. union util_format_r8g8b8x8_srgb {
  16647.    uint32_t value;
  16648.    struct {
  16649.       uint8_t r;
  16650.       uint8_t g;
  16651.       uint8_t b;
  16652.       uint8_t x;
  16653.    } chan;
  16654. };
  16655.  
  16656. static INLINE void
  16657. util_format_r8g8b8x8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16658. {
  16659.    unsigned x, y;
  16660.    for(y = 0; y < height; y += 1) {
  16661.       float *dst = dst_row;
  16662.       const uint8_t *src = src_row;
  16663.       for(x = 0; x < width; x += 1) {
  16664.          uint32_t value = *(const uint32_t *)src;
  16665.          uint32_t r;
  16666.          uint32_t g;
  16667.          uint32_t b;
  16668.          r = (value) & 0xff;
  16669.          g = (value >> 8) & 0xff;
  16670.          b = (value >> 16) & 0xff;
  16671.          dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */
  16672.          dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */
  16673.          dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */
  16674.          dst[3] = 1; /* a */
  16675.          src += 4;
  16676.          dst += 4;
  16677.       }
  16678.       src_row += src_stride;
  16679.       dst_row += dst_stride/sizeof(*dst_row);
  16680.    }
  16681. }
  16682.  
  16683. static INLINE void
  16684. util_format_r8g8b8x8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  16685. {
  16686.    unsigned x, y;
  16687.    for(y = 0; y < height; y += 1) {
  16688.       const float *src = src_row;
  16689.       uint8_t *dst = dst_row;
  16690.       for(x = 0; x < width; x += 1) {
  16691.          uint32_t value = 0;
  16692.          value |= (util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff;
  16693.          value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8;
  16694.          value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 16;
  16695.          *(uint32_t *)dst = value;
  16696.          src += 4;
  16697.          dst += 4;
  16698.       }
  16699.       dst_row += dst_stride;
  16700.       src_row += src_stride/sizeof(*src_row);
  16701.    }
  16702. }
  16703.  
  16704. static INLINE void
  16705. util_format_r8g8b8x8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  16706. {
  16707.          uint32_t value = *(const uint32_t *)src;
  16708.          uint32_t r;
  16709.          uint32_t g;
  16710.          uint32_t b;
  16711.          r = (value) & 0xff;
  16712.          g = (value >> 8) & 0xff;
  16713.          b = (value >> 16) & 0xff;
  16714.          dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */
  16715.          dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */
  16716.          dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */
  16717.          dst[3] = 1; /* a */
  16718. }
  16719.  
  16720. static INLINE void
  16721. util_format_r8g8b8x8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16722. {
  16723.    unsigned x, y;
  16724.    for(y = 0; y < height; y += 1) {
  16725.       uint8_t *dst = dst_row;
  16726.       const uint8_t *src = src_row;
  16727.       for(x = 0; x < width; x += 1) {
  16728.          uint32_t value = *(const uint32_t *)src;
  16729.          uint32_t r;
  16730.          uint32_t g;
  16731.          uint32_t b;
  16732.          r = (value) & 0xff;
  16733.          g = (value >> 8) & 0xff;
  16734.          b = (value >> 16) & 0xff;
  16735.          dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */
  16736.          dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */
  16737.          dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */
  16738.          dst[3] = 255; /* a */
  16739.          src += 4;
  16740.          dst += 4;
  16741.       }
  16742.       src_row += src_stride;
  16743.       dst_row += dst_stride/sizeof(*dst_row);
  16744.    }
  16745. }
  16746.  
  16747. static INLINE void
  16748. util_format_r8g8b8x8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16749. {
  16750.    unsigned x, y;
  16751.    for(y = 0; y < height; y += 1) {
  16752.       const uint8_t *src = src_row;
  16753.       uint8_t *dst = dst_row;
  16754.       for(x = 0; x < width; x += 1) {
  16755.          uint32_t value = 0;
  16756.          value |= (util_format_linear_to_srgb_8unorm(src[0])) & 0xff;
  16757.          value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8;
  16758.          value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 16;
  16759.          *(uint32_t *)dst = value;
  16760.          src += 4;
  16761.          dst += 4;
  16762.       }
  16763.       dst_row += dst_stride;
  16764.       src_row += src_stride/sizeof(*src_row);
  16765.    }
  16766. }
  16767.  
  16768. union util_format_r8g8b8x8_uint {
  16769.    uint32_t value;
  16770.    struct {
  16771.       uint8_t r;
  16772.       uint8_t g;
  16773.       uint8_t b;
  16774.       uint8_t x;
  16775.    } chan;
  16776. };
  16777.  
  16778. static INLINE void
  16779. util_format_r8g8b8x8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16780. {
  16781.    unsigned x, y;
  16782.    for(y = 0; y < height; y += 1) {
  16783.       unsigned *dst = dst_row;
  16784.       const uint8_t *src = src_row;
  16785.       for(x = 0; x < width; x += 1) {
  16786.          uint32_t value = *(const uint32_t *)src;
  16787.          uint32_t r;
  16788.          uint32_t g;
  16789.          uint32_t b;
  16790.          r = (value) & 0xff;
  16791.          g = (value >> 8) & 0xff;
  16792.          b = (value >> 16) & 0xff;
  16793.          dst[0] = (unsigned)r; /* r */
  16794.          dst[1] = (unsigned)g; /* g */
  16795.          dst[2] = (unsigned)b; /* b */
  16796.          dst[3] = 1; /* a */
  16797.          src += 4;
  16798.          dst += 4;
  16799.       }
  16800.       src_row += src_stride;
  16801.       dst_row += dst_stride/sizeof(*dst_row);
  16802.    }
  16803. }
  16804.  
  16805. static INLINE void
  16806. util_format_r8g8b8x8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16807. {
  16808.    unsigned x, y;
  16809.    for(y = 0; y < height; y += 1) {
  16810.       const unsigned *src = src_row;
  16811.       uint8_t *dst = dst_row;
  16812.       for(x = 0; x < width; x += 1) {
  16813.          uint32_t value = 0;
  16814.          value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
  16815.          value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8;
  16816.          value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16;
  16817.          *(uint32_t *)dst = value;
  16818.          src += 4;
  16819.          dst += 4;
  16820.       }
  16821.       dst_row += dst_stride;
  16822.       src_row += src_stride/sizeof(*src_row);
  16823.    }
  16824. }
  16825.  
  16826. static INLINE void
  16827. util_format_r8g8b8x8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  16828. {
  16829.          uint32_t value = *(const uint32_t *)src;
  16830.          uint32_t r;
  16831.          uint32_t g;
  16832.          uint32_t b;
  16833.          r = (value) & 0xff;
  16834.          g = (value >> 8) & 0xff;
  16835.          b = (value >> 16) & 0xff;
  16836.          dst[0] = (unsigned)r; /* r */
  16837.          dst[1] = (unsigned)g; /* g */
  16838.          dst[2] = (unsigned)b; /* b */
  16839.          dst[3] = 1; /* a */
  16840. }
  16841.  
  16842. static INLINE void
  16843. util_format_r8g8b8x8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16844. {
  16845.    unsigned x, y;
  16846.    for(y = 0; y < height; y += 1) {
  16847.       int *dst = dst_row;
  16848.       const uint8_t *src = src_row;
  16849.       for(x = 0; x < width; x += 1) {
  16850.          uint32_t value = *(const uint32_t *)src;
  16851.          uint32_t r;
  16852.          uint32_t g;
  16853.          uint32_t b;
  16854.          r = (value) & 0xff;
  16855.          g = (value >> 8) & 0xff;
  16856.          b = (value >> 16) & 0xff;
  16857.          dst[0] = (int)r; /* r */
  16858.          dst[1] = (int)g; /* g */
  16859.          dst[2] = (int)b; /* b */
  16860.          dst[3] = 1; /* a */
  16861.          src += 4;
  16862.          dst += 4;
  16863.       }
  16864.       src_row += src_stride;
  16865.       dst_row += dst_stride/sizeof(*dst_row);
  16866.    }
  16867. }
  16868.  
  16869. static INLINE void
  16870. util_format_r8g8b8x8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16871. {
  16872.    unsigned x, y;
  16873.    for(y = 0; y < height; y += 1) {
  16874.       const int *src = src_row;
  16875.       uint8_t *dst = dst_row;
  16876.       for(x = 0; x < width; x += 1) {
  16877.          uint32_t value = 0;
  16878.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  16879.          value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8;
  16880.          value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16;
  16881.          *(uint32_t *)dst = value;
  16882.          src += 4;
  16883.          dst += 4;
  16884.       }
  16885.       dst_row += dst_stride;
  16886.       src_row += src_stride/sizeof(*src_row);
  16887.    }
  16888. }
  16889.  
  16890. union util_format_r8g8b8x8_sint {
  16891.    uint32_t value;
  16892.    struct {
  16893.       int8_t r;
  16894.       int8_t g;
  16895.       int8_t b;
  16896.       uint8_t x;
  16897.    } chan;
  16898. };
  16899.  
  16900. static INLINE void
  16901. util_format_r8g8b8x8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16902. {
  16903.    unsigned x, y;
  16904.    for(y = 0; y < height; y += 1) {
  16905.       int *dst = dst_row;
  16906.       const uint8_t *src = src_row;
  16907.       for(x = 0; x < width; x += 1) {
  16908.          uint32_t value = *(const uint32_t *)src;
  16909.          int32_t r;
  16910.          int32_t g;
  16911.          int32_t b;
  16912.          r = ((int32_t)(value << 24) ) >> 24;
  16913.          g = ((int32_t)(value << 16) ) >> 24;
  16914.          b = ((int32_t)(value << 8) ) >> 24;
  16915.          dst[0] = (int)r; /* r */
  16916.          dst[1] = (int)g; /* g */
  16917.          dst[2] = (int)b; /* b */
  16918.          dst[3] = 1; /* a */
  16919.          src += 4;
  16920.          dst += 4;
  16921.       }
  16922.       src_row += src_stride;
  16923.       dst_row += dst_stride/sizeof(*dst_row);
  16924.    }
  16925. }
  16926.  
  16927. static INLINE void
  16928. util_format_r8g8b8x8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  16929. {
  16930.    unsigned x, y;
  16931.    for(y = 0; y < height; y += 1) {
  16932.       const int *src = src_row;
  16933.       uint8_t *dst = dst_row;
  16934.       for(x = 0; x < width; x += 1) {
  16935.          uint32_t value = 0;
  16936.          value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  16937.          value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ;
  16938.          value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ;
  16939.          *(uint32_t *)dst = value;
  16940.          src += 4;
  16941.          dst += 4;
  16942.       }
  16943.       dst_row += dst_stride;
  16944.       src_row += src_stride/sizeof(*src_row);
  16945.    }
  16946. }
  16947.  
  16948. static INLINE void
  16949. util_format_r8g8b8x8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  16950. {
  16951.          uint32_t value = *(const uint32_t *)src;
  16952.          int32_t r;
  16953.          int32_t g;
  16954.          int32_t b;
  16955.          r = ((int32_t)(value << 24) ) >> 24;
  16956.          g = ((int32_t)(value << 16) ) >> 24;
  16957.          b = ((int32_t)(value << 8) ) >> 24;
  16958.          dst[0] = (int)r; /* r */
  16959.          dst[1] = (int)g; /* g */
  16960.          dst[2] = (int)b; /* b */
  16961.          dst[3] = 1; /* a */
  16962. }
  16963.  
  16964. static INLINE void
  16965. util_format_r8g8b8x8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  16966. {
  16967.    unsigned x, y;
  16968.    for(y = 0; y < height; y += 1) {
  16969.       unsigned *dst = dst_row;
  16970.       const uint8_t *src = src_row;
  16971.       for(x = 0; x < width; x += 1) {
  16972.          uint32_t value = *(const uint32_t *)src;
  16973.          int32_t r;
  16974.          int32_t g;
  16975.          int32_t b;
  16976.          r = ((int32_t)(value << 24) ) >> 24;
  16977.          g = ((int32_t)(value << 16) ) >> 24;
  16978.          b = ((int32_t)(value << 8) ) >> 24;
  16979.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  16980.          dst[1] = (unsigned)MAX2(g, 0); /* g */
  16981.          dst[2] = (unsigned)MAX2(b, 0); /* b */
  16982.          dst[3] = 1; /* a */
  16983.          src += 4;
  16984.          dst += 4;
  16985.       }
  16986.       src_row += src_stride;
  16987.       dst_row += dst_stride/sizeof(*dst_row);
  16988.    }
  16989. }
  16990.  
  16991. static INLINE void
  16992. util_format_r8g8b8x8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  16993. {
  16994.    unsigned x, y;
  16995.    for(y = 0; y < height; y += 1) {
  16996.       const unsigned *src = src_row;
  16997.       uint8_t *dst = dst_row;
  16998.       for(x = 0; x < width; x += 1) {
  16999.          uint32_t value = 0;
  17000.          value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
  17001.          value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ;
  17002.          value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ;
  17003.          *(uint32_t *)dst = value;
  17004.          src += 4;
  17005.          dst += 4;
  17006.       }
  17007.       dst_row += dst_stride;
  17008.       src_row += src_stride/sizeof(*src_row);
  17009.    }
  17010. }
  17011.  
  17012. union util_format_r16g16b16x16_unorm {
  17013.    uint64_t value;
  17014.    struct {
  17015.       uint16_t r;
  17016.       uint16_t g;
  17017.       uint16_t b;
  17018.       uint16_t x;
  17019.    } chan;
  17020. };
  17021.  
  17022. static INLINE void
  17023. util_format_r16g16b16x16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17024. {
  17025.    unsigned x, y;
  17026.    for(y = 0; y < height; y += 1) {
  17027.       float *dst = dst_row;
  17028.       const uint8_t *src = src_row;
  17029.       for(x = 0; x < width; x += 1) {
  17030.          union util_format_r16g16b16x16_unorm pixel;
  17031.          memcpy(&pixel, src, sizeof pixel);
  17032.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  17033.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  17034.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  17035.          dst[3] = 1; /* a */
  17036.          src += 8;
  17037.          dst += 4;
  17038.       }
  17039.       src_row += src_stride;
  17040.       dst_row += dst_stride/sizeof(*dst_row);
  17041.    }
  17042. }
  17043.  
  17044. static INLINE void
  17045. util_format_r16g16b16x16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  17046. {
  17047.    unsigned x, y;
  17048.    for(y = 0; y < height; y += 1) {
  17049.       const float *src = src_row;
  17050.       uint8_t *dst = dst_row;
  17051.       for(x = 0; x < width; x += 1) {
  17052.          union util_format_r16g16b16x16_unorm pixel;
  17053.          pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff);
  17054.          pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff);
  17055.          pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff);
  17056.          memcpy(dst, &pixel, sizeof pixel);
  17057.          src += 4;
  17058.          dst += 8;
  17059.       }
  17060.       dst_row += dst_stride;
  17061.       src_row += src_stride/sizeof(*src_row);
  17062.    }
  17063. }
  17064.  
  17065. static INLINE void
  17066. util_format_r16g16b16x16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  17067. {
  17068.          union util_format_r16g16b16x16_unorm pixel;
  17069.          memcpy(&pixel, src, sizeof pixel);
  17070.          dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */
  17071.          dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */
  17072.          dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */
  17073.          dst[3] = 1; /* a */
  17074. }
  17075.  
  17076. static INLINE void
  17077. util_format_r16g16b16x16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17078. {
  17079.    unsigned x, y;
  17080.    for(y = 0; y < height; y += 1) {
  17081.       uint8_t *dst = dst_row;
  17082.       const uint8_t *src = src_row;
  17083.       for(x = 0; x < width; x += 1) {
  17084.          union util_format_r16g16b16x16_unorm pixel;
  17085.          memcpy(&pixel, src, sizeof pixel);
  17086.          dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */
  17087.          dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */
  17088.          dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */
  17089.          dst[3] = 255; /* a */
  17090.          src += 8;
  17091.          dst += 4;
  17092.       }
  17093.       src_row += src_stride;
  17094.       dst_row += dst_stride/sizeof(*dst_row);
  17095.    }
  17096. }
  17097.  
  17098. static INLINE void
  17099. util_format_r16g16b16x16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17100. {
  17101.    unsigned x, y;
  17102.    for(y = 0; y < height; y += 1) {
  17103.       const uint8_t *src = src_row;
  17104.       uint8_t *dst = dst_row;
  17105.       for(x = 0; x < width; x += 1) {
  17106.          union util_format_r16g16b16x16_unorm pixel;
  17107.          pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff);
  17108.          pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff);
  17109.          pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff);
  17110.          memcpy(dst, &pixel, sizeof pixel);
  17111.          src += 4;
  17112.          dst += 8;
  17113.       }
  17114.       dst_row += dst_stride;
  17115.       src_row += src_stride/sizeof(*src_row);
  17116.    }
  17117. }
  17118.  
  17119. union util_format_r16g16b16x16_snorm {
  17120.    uint64_t value;
  17121.    struct {
  17122.       int16_t r;
  17123.       int16_t g;
  17124.       int16_t b;
  17125.       uint16_t x;
  17126.    } chan;
  17127. };
  17128.  
  17129. static INLINE void
  17130. util_format_r16g16b16x16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17131. {
  17132.    unsigned x, y;
  17133.    for(y = 0; y < height; y += 1) {
  17134.       float *dst = dst_row;
  17135.       const uint8_t *src = src_row;
  17136.       for(x = 0; x < width; x += 1) {
  17137.          union util_format_r16g16b16x16_snorm pixel;
  17138.          memcpy(&pixel, src, sizeof pixel);
  17139.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  17140.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  17141.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  17142.          dst[3] = 1; /* a */
  17143.          src += 8;
  17144.          dst += 4;
  17145.       }
  17146.       src_row += src_stride;
  17147.       dst_row += dst_stride/sizeof(*dst_row);
  17148.    }
  17149. }
  17150.  
  17151. static INLINE void
  17152. util_format_r16g16b16x16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  17153. {
  17154.    unsigned x, y;
  17155.    for(y = 0; y < height; y += 1) {
  17156.       const float *src = src_row;
  17157.       uint8_t *dst = dst_row;
  17158.       for(x = 0; x < width; x += 1) {
  17159.          union util_format_r16g16b16x16_snorm pixel;
  17160.          pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff);
  17161.          pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff);
  17162.          pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff);
  17163.          memcpy(dst, &pixel, sizeof pixel);
  17164.          src += 4;
  17165.          dst += 8;
  17166.       }
  17167.       dst_row += dst_stride;
  17168.       src_row += src_stride/sizeof(*src_row);
  17169.    }
  17170. }
  17171.  
  17172. static INLINE void
  17173. util_format_r16g16b16x16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  17174. {
  17175.          union util_format_r16g16b16x16_snorm pixel;
  17176.          memcpy(&pixel, src, sizeof pixel);
  17177.          dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */
  17178.          dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */
  17179.          dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */
  17180.          dst[3] = 1; /* a */
  17181. }
  17182.  
  17183. static INLINE void
  17184. util_format_r16g16b16x16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17185. {
  17186.    unsigned x, y;
  17187.    for(y = 0; y < height; y += 1) {
  17188.       uint8_t *dst = dst_row;
  17189.       const uint8_t *src = src_row;
  17190.       for(x = 0; x < width; x += 1) {
  17191.          union util_format_r16g16b16x16_snorm pixel;
  17192.          memcpy(&pixel, src, sizeof pixel);
  17193.          dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */
  17194.          dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */
  17195.          dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */
  17196.          dst[3] = 255; /* a */
  17197.          src += 8;
  17198.          dst += 4;
  17199.       }
  17200.       src_row += src_stride;
  17201.       dst_row += dst_stride/sizeof(*dst_row);
  17202.    }
  17203. }
  17204.  
  17205. static INLINE void
  17206. util_format_r16g16b16x16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17207. {
  17208.    unsigned x, y;
  17209.    for(y = 0; y < height; y += 1) {
  17210.       const uint8_t *src = src_row;
  17211.       uint8_t *dst = dst_row;
  17212.       for(x = 0; x < width; x += 1) {
  17213.          union util_format_r16g16b16x16_snorm pixel;
  17214.          pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff);
  17215.          pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff);
  17216.          pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff);
  17217.          memcpy(dst, &pixel, sizeof pixel);
  17218.          src += 4;
  17219.          dst += 8;
  17220.       }
  17221.       dst_row += dst_stride;
  17222.       src_row += src_stride/sizeof(*src_row);
  17223.    }
  17224. }
  17225.  
  17226. union util_format_r16g16b16x16_float {
  17227.    uint64_t value;
  17228.    struct {
  17229.       uint16_t r;
  17230.       uint16_t g;
  17231.       uint16_t b;
  17232.       uint16_t x;
  17233.    } chan;
  17234. };
  17235.  
  17236. static INLINE void
  17237. util_format_r16g16b16x16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17238. {
  17239.    unsigned x, y;
  17240.    for(y = 0; y < height; y += 1) {
  17241.       float *dst = dst_row;
  17242.       const uint8_t *src = src_row;
  17243.       for(x = 0; x < width; x += 1) {
  17244.          union util_format_r16g16b16x16_float pixel;
  17245.          memcpy(&pixel, src, sizeof pixel);
  17246.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  17247.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  17248.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  17249.          dst[3] = 1; /* a */
  17250.          src += 8;
  17251.          dst += 4;
  17252.       }
  17253.       src_row += src_stride;
  17254.       dst_row += dst_stride/sizeof(*dst_row);
  17255.    }
  17256. }
  17257.  
  17258. static INLINE void
  17259. util_format_r16g16b16x16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  17260. {
  17261.    unsigned x, y;
  17262.    for(y = 0; y < height; y += 1) {
  17263.       const float *src = src_row;
  17264.       uint8_t *dst = dst_row;
  17265.       for(x = 0; x < width; x += 1) {
  17266.          union util_format_r16g16b16x16_float pixel;
  17267.          pixel.chan.r = util_float_to_half(src[0]);
  17268.          pixel.chan.g = util_float_to_half(src[1]);
  17269.          pixel.chan.b = util_float_to_half(src[2]);
  17270.          memcpy(dst, &pixel, sizeof pixel);
  17271.          src += 4;
  17272.          dst += 8;
  17273.       }
  17274.       dst_row += dst_stride;
  17275.       src_row += src_stride/sizeof(*src_row);
  17276.    }
  17277. }
  17278.  
  17279. static INLINE void
  17280. util_format_r16g16b16x16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  17281. {
  17282.          union util_format_r16g16b16x16_float pixel;
  17283.          memcpy(&pixel, src, sizeof pixel);
  17284.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  17285.          dst[1] = util_half_to_float(pixel.chan.g); /* g */
  17286.          dst[2] = util_half_to_float(pixel.chan.b); /* b */
  17287.          dst[3] = 1; /* a */
  17288. }
  17289.  
  17290. static INLINE void
  17291. util_format_r16g16b16x16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17292. {
  17293.    unsigned x, y;
  17294.    for(y = 0; y < height; y += 1) {
  17295.       uint8_t *dst = dst_row;
  17296.       const uint8_t *src = src_row;
  17297.       for(x = 0; x < width; x += 1) {
  17298.          union util_format_r16g16b16x16_float pixel;
  17299.          memcpy(&pixel, src, sizeof pixel);
  17300.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  17301.          dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */
  17302.          dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */
  17303.          dst[3] = 255; /* a */
  17304.          src += 8;
  17305.          dst += 4;
  17306.       }
  17307.       src_row += src_stride;
  17308.       dst_row += dst_stride/sizeof(*dst_row);
  17309.    }
  17310. }
  17311.  
  17312. static INLINE void
  17313. util_format_r16g16b16x16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17314. {
  17315.    unsigned x, y;
  17316.    for(y = 0; y < height; y += 1) {
  17317.       const uint8_t *src = src_row;
  17318.       uint8_t *dst = dst_row;
  17319.       for(x = 0; x < width; x += 1) {
  17320.          union util_format_r16g16b16x16_float pixel;
  17321.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  17322.          pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff)));
  17323.          pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff)));
  17324.          memcpy(dst, &pixel, sizeof pixel);
  17325.          src += 4;
  17326.          dst += 8;
  17327.       }
  17328.       dst_row += dst_stride;
  17329.       src_row += src_stride/sizeof(*src_row);
  17330.    }
  17331. }
  17332.  
  17333. union util_format_r16g16b16x16_uint {
  17334.    uint64_t value;
  17335.    struct {
  17336.       uint16_t r;
  17337.       uint16_t g;
  17338.       uint16_t b;
  17339.       uint16_t x;
  17340.    } chan;
  17341. };
  17342.  
  17343. static INLINE void
  17344. util_format_r16g16b16x16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17345. {
  17346.    unsigned x, y;
  17347.    for(y = 0; y < height; y += 1) {
  17348.       unsigned *dst = dst_row;
  17349.       const uint8_t *src = src_row;
  17350.       for(x = 0; x < width; x += 1) {
  17351.          union util_format_r16g16b16x16_uint pixel;
  17352.          memcpy(&pixel, src, sizeof pixel);
  17353.          dst[0] = (unsigned)pixel.chan.r; /* r */
  17354.          dst[1] = (unsigned)pixel.chan.g; /* g */
  17355.          dst[2] = (unsigned)pixel.chan.b; /* b */
  17356.          dst[3] = 1; /* a */
  17357.          src += 8;
  17358.          dst += 4;
  17359.       }
  17360.       src_row += src_stride;
  17361.       dst_row += dst_stride/sizeof(*dst_row);
  17362.    }
  17363. }
  17364.  
  17365. static INLINE void
  17366. util_format_r16g16b16x16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  17367. {
  17368.    unsigned x, y;
  17369.    for(y = 0; y < height; y += 1) {
  17370.       const unsigned *src = src_row;
  17371.       uint8_t *dst = dst_row;
  17372.       for(x = 0; x < width; x += 1) {
  17373.          union util_format_r16g16b16x16_uint pixel;
  17374.          pixel.chan.r = (uint16_t)MIN2(src[0], 65535);
  17375.          pixel.chan.g = (uint16_t)MIN2(src[1], 65535);
  17376.          pixel.chan.b = (uint16_t)MIN2(src[2], 65535);
  17377.          memcpy(dst, &pixel, sizeof pixel);
  17378.          src += 4;
  17379.          dst += 8;
  17380.       }
  17381.       dst_row += dst_stride;
  17382.       src_row += src_stride/sizeof(*src_row);
  17383.    }
  17384. }
  17385.  
  17386. static INLINE void
  17387. util_format_r16g16b16x16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  17388. {
  17389.          union util_format_r16g16b16x16_uint pixel;
  17390.          memcpy(&pixel, src, sizeof pixel);
  17391.          dst[0] = (unsigned)pixel.chan.r; /* r */
  17392.          dst[1] = (unsigned)pixel.chan.g; /* g */
  17393.          dst[2] = (unsigned)pixel.chan.b; /* b */
  17394.          dst[3] = 1; /* a */
  17395. }
  17396.  
  17397. static INLINE void
  17398. util_format_r16g16b16x16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17399. {
  17400.    unsigned x, y;
  17401.    for(y = 0; y < height; y += 1) {
  17402.       int *dst = dst_row;
  17403.       const uint8_t *src = src_row;
  17404.       for(x = 0; x < width; x += 1) {
  17405.          union util_format_r16g16b16x16_uint pixel;
  17406.          memcpy(&pixel, src, sizeof pixel);
  17407.          dst[0] = (int)pixel.chan.r; /* r */
  17408.          dst[1] = (int)pixel.chan.g; /* g */
  17409.          dst[2] = (int)pixel.chan.b; /* b */
  17410.          dst[3] = 1; /* a */
  17411.          src += 8;
  17412.          dst += 4;
  17413.       }
  17414.       src_row += src_stride;
  17415.       dst_row += dst_stride/sizeof(*dst_row);
  17416.    }
  17417. }
  17418.  
  17419. static INLINE void
  17420. util_format_r16g16b16x16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  17421. {
  17422.    unsigned x, y;
  17423.    for(y = 0; y < height; y += 1) {
  17424.       const int *src = src_row;
  17425.       uint8_t *dst = dst_row;
  17426.       for(x = 0; x < width; x += 1) {
  17427.          union util_format_r16g16b16x16_uint pixel;
  17428.          pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535);
  17429.          pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535);
  17430.          pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535);
  17431.          memcpy(dst, &pixel, sizeof pixel);
  17432.          src += 4;
  17433.          dst += 8;
  17434.       }
  17435.       dst_row += dst_stride;
  17436.       src_row += src_stride/sizeof(*src_row);
  17437.    }
  17438. }
  17439.  
  17440. union util_format_r16g16b16x16_sint {
  17441.    uint64_t value;
  17442.    struct {
  17443.       int16_t r;
  17444.       int16_t g;
  17445.       int16_t b;
  17446.       uint16_t x;
  17447.    } chan;
  17448. };
  17449.  
  17450. static INLINE void
  17451. util_format_r16g16b16x16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17452. {
  17453.    unsigned x, y;
  17454.    for(y = 0; y < height; y += 1) {
  17455.       int *dst = dst_row;
  17456.       const uint8_t *src = src_row;
  17457.       for(x = 0; x < width; x += 1) {
  17458.          union util_format_r16g16b16x16_sint pixel;
  17459.          memcpy(&pixel, src, sizeof pixel);
  17460.          dst[0] = (int)pixel.chan.r; /* r */
  17461.          dst[1] = (int)pixel.chan.g; /* g */
  17462.          dst[2] = (int)pixel.chan.b; /* b */
  17463.          dst[3] = 1; /* a */
  17464.          src += 8;
  17465.          dst += 4;
  17466.       }
  17467.       src_row += src_stride;
  17468.       dst_row += dst_stride/sizeof(*dst_row);
  17469.    }
  17470. }
  17471.  
  17472. static INLINE void
  17473. util_format_r16g16b16x16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  17474. {
  17475.    unsigned x, y;
  17476.    for(y = 0; y < height; y += 1) {
  17477.       const int *src = src_row;
  17478.       uint8_t *dst = dst_row;
  17479.       for(x = 0; x < width; x += 1) {
  17480.          union util_format_r16g16b16x16_sint pixel;
  17481.          pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767);
  17482.          pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767);
  17483.          pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767);
  17484.          memcpy(dst, &pixel, sizeof pixel);
  17485.          src += 4;
  17486.          dst += 8;
  17487.       }
  17488.       dst_row += dst_stride;
  17489.       src_row += src_stride/sizeof(*src_row);
  17490.    }
  17491. }
  17492.  
  17493. static INLINE void
  17494. util_format_r16g16b16x16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  17495. {
  17496.          union util_format_r16g16b16x16_sint pixel;
  17497.          memcpy(&pixel, src, sizeof pixel);
  17498.          dst[0] = (int)pixel.chan.r; /* r */
  17499.          dst[1] = (int)pixel.chan.g; /* g */
  17500.          dst[2] = (int)pixel.chan.b; /* b */
  17501.          dst[3] = 1; /* a */
  17502. }
  17503.  
  17504. static INLINE void
  17505. util_format_r16g16b16x16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17506. {
  17507.    unsigned x, y;
  17508.    for(y = 0; y < height; y += 1) {
  17509.       unsigned *dst = dst_row;
  17510.       const uint8_t *src = src_row;
  17511.       for(x = 0; x < width; x += 1) {
  17512.          union util_format_r16g16b16x16_sint pixel;
  17513.          memcpy(&pixel, src, sizeof pixel);
  17514.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  17515.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  17516.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  17517.          dst[3] = 1; /* a */
  17518.          src += 8;
  17519.          dst += 4;
  17520.       }
  17521.       src_row += src_stride;
  17522.       dst_row += dst_stride/sizeof(*dst_row);
  17523.    }
  17524. }
  17525.  
  17526. static INLINE void
  17527. util_format_r16g16b16x16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  17528. {
  17529.    unsigned x, y;
  17530.    for(y = 0; y < height; y += 1) {
  17531.       const unsigned *src = src_row;
  17532.       uint8_t *dst = dst_row;
  17533.       for(x = 0; x < width; x += 1) {
  17534.          union util_format_r16g16b16x16_sint pixel;
  17535.          pixel.chan.r = (int16_t)MIN2(src[0], 32767);
  17536.          pixel.chan.g = (int16_t)MIN2(src[1], 32767);
  17537.          pixel.chan.b = (int16_t)MIN2(src[2], 32767);
  17538.          memcpy(dst, &pixel, sizeof pixel);
  17539.          src += 4;
  17540.          dst += 8;
  17541.       }
  17542.       dst_row += dst_stride;
  17543.       src_row += src_stride/sizeof(*src_row);
  17544.    }
  17545. }
  17546.  
  17547. union util_format_r32g32b32x32_float {
  17548.    struct {
  17549.       float r;
  17550.       float g;
  17551.       float b;
  17552.       uint32_t x;
  17553.    } chan;
  17554. };
  17555.  
  17556. static INLINE void
  17557. util_format_r32g32b32x32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17558. {
  17559.    unsigned x, y;
  17560.    for(y = 0; y < height; y += 1) {
  17561.       float *dst = dst_row;
  17562.       const uint8_t *src = src_row;
  17563.       for(x = 0; x < width; x += 1) {
  17564.          union util_format_r32g32b32x32_float pixel;
  17565.          memcpy(&pixel, src, sizeof pixel);
  17566.          dst[0] = pixel.chan.r; /* r */
  17567.          dst[1] = pixel.chan.g; /* g */
  17568.          dst[2] = pixel.chan.b; /* b */
  17569.          dst[3] = 1; /* a */
  17570.          src += 16;
  17571.          dst += 4;
  17572.       }
  17573.       src_row += src_stride;
  17574.       dst_row += dst_stride/sizeof(*dst_row);
  17575.    }
  17576. }
  17577.  
  17578. static INLINE void
  17579. util_format_r32g32b32x32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  17580. {
  17581.    unsigned x, y;
  17582.    for(y = 0; y < height; y += 1) {
  17583.       const float *src = src_row;
  17584.       uint8_t *dst = dst_row;
  17585.       for(x = 0; x < width; x += 1) {
  17586.          union util_format_r32g32b32x32_float pixel;
  17587.          pixel.chan.r = src[0];
  17588.          pixel.chan.g = src[1];
  17589.          pixel.chan.b = src[2];
  17590.          memcpy(dst, &pixel, sizeof pixel);
  17591.          src += 4;
  17592.          dst += 16;
  17593.       }
  17594.       dst_row += dst_stride;
  17595.       src_row += src_stride/sizeof(*src_row);
  17596.    }
  17597. }
  17598.  
  17599. static INLINE void
  17600. util_format_r32g32b32x32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  17601. {
  17602.          union util_format_r32g32b32x32_float pixel;
  17603.          memcpy(&pixel, src, sizeof pixel);
  17604.          dst[0] = pixel.chan.r; /* r */
  17605.          dst[1] = pixel.chan.g; /* g */
  17606.          dst[2] = pixel.chan.b; /* b */
  17607.          dst[3] = 1; /* a */
  17608. }
  17609.  
  17610. static INLINE void
  17611. util_format_r32g32b32x32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17612. {
  17613.    unsigned x, y;
  17614.    for(y = 0; y < height; y += 1) {
  17615.       uint8_t *dst = dst_row;
  17616.       const uint8_t *src = src_row;
  17617.       for(x = 0; x < width; x += 1) {
  17618.          union util_format_r32g32b32x32_float pixel;
  17619.          memcpy(&pixel, src, sizeof pixel);
  17620.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  17621.          dst[1] = float_to_ubyte(pixel.chan.g); /* g */
  17622.          dst[2] = float_to_ubyte(pixel.chan.b); /* b */
  17623.          dst[3] = 255; /* a */
  17624.          src += 16;
  17625.          dst += 4;
  17626.       }
  17627.       src_row += src_stride;
  17628.       dst_row += dst_stride/sizeof(*dst_row);
  17629.    }
  17630. }
  17631.  
  17632. static INLINE void
  17633. util_format_r32g32b32x32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17634. {
  17635.    unsigned x, y;
  17636.    for(y = 0; y < height; y += 1) {
  17637.       const uint8_t *src = src_row;
  17638.       uint8_t *dst = dst_row;
  17639.       for(x = 0; x < width; x += 1) {
  17640.          union util_format_r32g32b32x32_float pixel;
  17641.          pixel.chan.r = ubyte_to_float(src[0]);
  17642.          pixel.chan.g = ubyte_to_float(src[1]);
  17643.          pixel.chan.b = ubyte_to_float(src[2]);
  17644.          memcpy(dst, &pixel, sizeof pixel);
  17645.          src += 4;
  17646.          dst += 16;
  17647.       }
  17648.       dst_row += dst_stride;
  17649.       src_row += src_stride/sizeof(*src_row);
  17650.    }
  17651. }
  17652.  
  17653. union util_format_r32g32b32x32_uint {
  17654.    struct {
  17655.       uint32_t r;
  17656.       uint32_t g;
  17657.       uint32_t b;
  17658.       uint32_t x;
  17659.    } chan;
  17660. };
  17661.  
  17662. static INLINE void
  17663. util_format_r32g32b32x32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17664. {
  17665.    unsigned x, y;
  17666.    for(y = 0; y < height; y += 1) {
  17667.       unsigned *dst = dst_row;
  17668.       const uint8_t *src = src_row;
  17669.       for(x = 0; x < width; x += 1) {
  17670.          union util_format_r32g32b32x32_uint pixel;
  17671.          memcpy(&pixel, src, sizeof pixel);
  17672.          dst[0] = pixel.chan.r; /* r */
  17673.          dst[1] = pixel.chan.g; /* g */
  17674.          dst[2] = pixel.chan.b; /* b */
  17675.          dst[3] = 1; /* a */
  17676.          src += 16;
  17677.          dst += 4;
  17678.       }
  17679.       src_row += src_stride;
  17680.       dst_row += dst_stride/sizeof(*dst_row);
  17681.    }
  17682. }
  17683.  
  17684. static INLINE void
  17685. util_format_r32g32b32x32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  17686. {
  17687.    unsigned x, y;
  17688.    for(y = 0; y < height; y += 1) {
  17689.       const unsigned *src = src_row;
  17690.       uint8_t *dst = dst_row;
  17691.       for(x = 0; x < width; x += 1) {
  17692.          union util_format_r32g32b32x32_uint pixel;
  17693.          pixel.chan.r = src[0];
  17694.          pixel.chan.g = src[1];
  17695.          pixel.chan.b = src[2];
  17696.          memcpy(dst, &pixel, sizeof pixel);
  17697.          src += 4;
  17698.          dst += 16;
  17699.       }
  17700.       dst_row += dst_stride;
  17701.       src_row += src_stride/sizeof(*src_row);
  17702.    }
  17703. }
  17704.  
  17705. static INLINE void
  17706. util_format_r32g32b32x32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  17707. {
  17708.          union util_format_r32g32b32x32_uint pixel;
  17709.          memcpy(&pixel, src, sizeof pixel);
  17710.          dst[0] = pixel.chan.r; /* r */
  17711.          dst[1] = pixel.chan.g; /* g */
  17712.          dst[2] = pixel.chan.b; /* b */
  17713.          dst[3] = 1; /* a */
  17714. }
  17715.  
  17716. static INLINE void
  17717. util_format_r32g32b32x32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17718. {
  17719.    unsigned x, y;
  17720.    for(y = 0; y < height; y += 1) {
  17721.       int *dst = dst_row;
  17722.       const uint8_t *src = src_row;
  17723.       for(x = 0; x < width; x += 1) {
  17724.          union util_format_r32g32b32x32_uint pixel;
  17725.          memcpy(&pixel, src, sizeof pixel);
  17726.          dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
  17727.          dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */
  17728.          dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */
  17729.          dst[3] = 1; /* a */
  17730.          src += 16;
  17731.          dst += 4;
  17732.       }
  17733.       src_row += src_stride;
  17734.       dst_row += dst_stride/sizeof(*dst_row);
  17735.    }
  17736. }
  17737.  
  17738. static INLINE void
  17739. util_format_r32g32b32x32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  17740. {
  17741.    unsigned x, y;
  17742.    for(y = 0; y < height; y += 1) {
  17743.       const int *src = src_row;
  17744.       uint8_t *dst = dst_row;
  17745.       for(x = 0; x < width; x += 1) {
  17746.          union util_format_r32g32b32x32_uint pixel;
  17747.          pixel.chan.r = (uint32_t)MAX2(src[0], 0);
  17748.          pixel.chan.g = (uint32_t)MAX2(src[1], 0);
  17749.          pixel.chan.b = (uint32_t)MAX2(src[2], 0);
  17750.          memcpy(dst, &pixel, sizeof pixel);
  17751.          src += 4;
  17752.          dst += 16;
  17753.       }
  17754.       dst_row += dst_stride;
  17755.       src_row += src_stride/sizeof(*src_row);
  17756.    }
  17757. }
  17758.  
  17759. union util_format_r32g32b32x32_sint {
  17760.    struct {
  17761.       int32_t r;
  17762.       int32_t g;
  17763.       int32_t b;
  17764.       uint32_t x;
  17765.    } chan;
  17766. };
  17767.  
  17768. static INLINE void
  17769. util_format_r32g32b32x32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17770. {
  17771.    unsigned x, y;
  17772.    for(y = 0; y < height; y += 1) {
  17773.       int *dst = dst_row;
  17774.       const uint8_t *src = src_row;
  17775.       for(x = 0; x < width; x += 1) {
  17776.          union util_format_r32g32b32x32_sint pixel;
  17777.          memcpy(&pixel, src, sizeof pixel);
  17778.          dst[0] = pixel.chan.r; /* r */
  17779.          dst[1] = pixel.chan.g; /* g */
  17780.          dst[2] = pixel.chan.b; /* b */
  17781.          dst[3] = 1; /* a */
  17782.          src += 16;
  17783.          dst += 4;
  17784.       }
  17785.       src_row += src_stride;
  17786.       dst_row += dst_stride/sizeof(*dst_row);
  17787.    }
  17788. }
  17789.  
  17790. static INLINE void
  17791. util_format_r32g32b32x32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  17792. {
  17793.    unsigned x, y;
  17794.    for(y = 0; y < height; y += 1) {
  17795.       const int *src = src_row;
  17796.       uint8_t *dst = dst_row;
  17797.       for(x = 0; x < width; x += 1) {
  17798.          union util_format_r32g32b32x32_sint pixel;
  17799.          pixel.chan.r = src[0];
  17800.          pixel.chan.g = src[1];
  17801.          pixel.chan.b = src[2];
  17802.          memcpy(dst, &pixel, sizeof pixel);
  17803.          src += 4;
  17804.          dst += 16;
  17805.       }
  17806.       dst_row += dst_stride;
  17807.       src_row += src_stride/sizeof(*src_row);
  17808.    }
  17809. }
  17810.  
  17811. static INLINE void
  17812. util_format_r32g32b32x32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  17813. {
  17814.          union util_format_r32g32b32x32_sint pixel;
  17815.          memcpy(&pixel, src, sizeof pixel);
  17816.          dst[0] = pixel.chan.r; /* r */
  17817.          dst[1] = pixel.chan.g; /* g */
  17818.          dst[2] = pixel.chan.b; /* b */
  17819.          dst[3] = 1; /* a */
  17820. }
  17821.  
  17822. static INLINE void
  17823. util_format_r32g32b32x32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17824. {
  17825.    unsigned x, y;
  17826.    for(y = 0; y < height; y += 1) {
  17827.       unsigned *dst = dst_row;
  17828.       const uint8_t *src = src_row;
  17829.       for(x = 0; x < width; x += 1) {
  17830.          union util_format_r32g32b32x32_sint pixel;
  17831.          memcpy(&pixel, src, sizeof pixel);
  17832.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  17833.          dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */
  17834.          dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */
  17835.          dst[3] = 1; /* a */
  17836.          src += 16;
  17837.          dst += 4;
  17838.       }
  17839.       src_row += src_stride;
  17840.       dst_row += dst_stride/sizeof(*dst_row);
  17841.    }
  17842. }
  17843.  
  17844. static INLINE void
  17845. util_format_r32g32b32x32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  17846. {
  17847.    unsigned x, y;
  17848.    for(y = 0; y < height; y += 1) {
  17849.       const unsigned *src = src_row;
  17850.       uint8_t *dst = dst_row;
  17851.       for(x = 0; x < width; x += 1) {
  17852.          union util_format_r32g32b32x32_sint pixel;
  17853.          pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
  17854.          pixel.chan.g = (int32_t)MIN2(src[1], 2147483647);
  17855.          pixel.chan.b = (int32_t)MIN2(src[2], 2147483647);
  17856.          memcpy(dst, &pixel, sizeof pixel);
  17857.          src += 4;
  17858.          dst += 16;
  17859.       }
  17860.       dst_row += dst_stride;
  17861.       src_row += src_stride/sizeof(*src_row);
  17862.    }
  17863. }
  17864.  
  17865. union util_format_r8a8_snorm {
  17866.    uint16_t value;
  17867.    struct {
  17868.       int8_t r;
  17869.       int8_t a;
  17870.    } chan;
  17871. };
  17872.  
  17873. static INLINE void
  17874. util_format_r8a8_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17875. {
  17876.    unsigned x, y;
  17877.    for(y = 0; y < height; y += 1) {
  17878.       float *dst = dst_row;
  17879.       const uint8_t *src = src_row;
  17880.       for(x = 0; x < width; x += 1) {
  17881.          uint16_t value = *(const uint16_t *)src;
  17882.          int16_t r;
  17883.          int16_t a;
  17884.          r = ((int16_t)(value << 8) ) >> 8;
  17885.          a = ((int16_t)(value) ) >> 8;
  17886.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  17887.          dst[1] = 0; /* g */
  17888.          dst[2] = 0; /* b */
  17889.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  17890.          src += 2;
  17891.          dst += 4;
  17892.       }
  17893.       src_row += src_stride;
  17894.       dst_row += dst_stride/sizeof(*dst_row);
  17895.    }
  17896. }
  17897.  
  17898. static INLINE void
  17899. util_format_r8a8_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  17900. {
  17901.    unsigned x, y;
  17902.    for(y = 0; y < height; y += 1) {
  17903.       const float *src = src_row;
  17904.       uint8_t *dst = dst_row;
  17905.       for(x = 0; x < width; x += 1) {
  17906.          uint16_t value = 0;
  17907.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ;
  17908.          value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ;
  17909.          *(uint16_t *)dst = value;
  17910.          src += 4;
  17911.          dst += 2;
  17912.       }
  17913.       dst_row += dst_stride;
  17914.       src_row += src_stride/sizeof(*src_row);
  17915.    }
  17916. }
  17917.  
  17918. static INLINE void
  17919. util_format_r8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  17920. {
  17921.          uint16_t value = *(const uint16_t *)src;
  17922.          int16_t r;
  17923.          int16_t a;
  17924.          r = ((int16_t)(value << 8) ) >> 8;
  17925.          a = ((int16_t)(value) ) >> 8;
  17926.          dst[0] = (float)(r * (1.0f/0x7f)); /* r */
  17927.          dst[1] = 0; /* g */
  17928.          dst[2] = 0; /* b */
  17929.          dst[3] = (float)(a * (1.0f/0x7f)); /* a */
  17930. }
  17931.  
  17932. static INLINE void
  17933. util_format_r8a8_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17934. {
  17935.    unsigned x, y;
  17936.    for(y = 0; y < height; y += 1) {
  17937.       uint8_t *dst = dst_row;
  17938.       const uint8_t *src = src_row;
  17939.       for(x = 0; x < width; x += 1) {
  17940.          uint16_t value = *(const uint16_t *)src;
  17941.          int16_t r;
  17942.          int16_t a;
  17943.          r = ((int16_t)(value << 8) ) >> 8;
  17944.          a = ((int16_t)(value) ) >> 8;
  17945.          dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */
  17946.          dst[1] = 0; /* g */
  17947.          dst[2] = 0; /* b */
  17948.          dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */
  17949.          src += 2;
  17950.          dst += 4;
  17951.       }
  17952.       src_row += src_stride;
  17953.       dst_row += dst_stride/sizeof(*dst_row);
  17954.    }
  17955. }
  17956.  
  17957. static INLINE void
  17958. util_format_r8a8_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17959. {
  17960.    unsigned x, y;
  17961.    for(y = 0; y < height; y += 1) {
  17962.       const uint8_t *src = src_row;
  17963.       uint8_t *dst = dst_row;
  17964.       for(x = 0; x < width; x += 1) {
  17965.          uint16_t value = 0;
  17966.          value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ;
  17967.          value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ;
  17968.          *(uint16_t *)dst = value;
  17969.          src += 4;
  17970.          dst += 2;
  17971.       }
  17972.       dst_row += dst_stride;
  17973.       src_row += src_stride/sizeof(*src_row);
  17974.    }
  17975. }
  17976.  
  17977. union util_format_r16a16_unorm {
  17978.    uint32_t value;
  17979.    struct {
  17980.       uint16_t r;
  17981.       uint16_t a;
  17982.    } chan;
  17983. };
  17984.  
  17985. static INLINE void
  17986. util_format_r16a16_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  17987. {
  17988.    unsigned x, y;
  17989.    for(y = 0; y < height; y += 1) {
  17990.       float *dst = dst_row;
  17991.       const uint8_t *src = src_row;
  17992.       for(x = 0; x < width; x += 1) {
  17993.          uint32_t value = *(const uint32_t *)src;
  17994.          uint32_t r;
  17995.          uint32_t a;
  17996.          r = (value) & 0xffff;
  17997.          a = value >> 16;
  17998.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  17999.          dst[1] = 0; /* g */
  18000.          dst[2] = 0; /* b */
  18001.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  18002.          src += 4;
  18003.          dst += 4;
  18004.       }
  18005.       src_row += src_stride;
  18006.       dst_row += dst_stride/sizeof(*dst_row);
  18007.    }
  18008. }
  18009.  
  18010. static INLINE void
  18011. util_format_r16a16_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  18012. {
  18013.    unsigned x, y;
  18014.    for(y = 0; y < height; y += 1) {
  18015.       const float *src = src_row;
  18016.       uint8_t *dst = dst_row;
  18017.       for(x = 0; x < width; x += 1) {
  18018.          uint32_t value = 0;
  18019.          value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff;
  18020.          value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16;
  18021.          *(uint32_t *)dst = value;
  18022.          src += 4;
  18023.          dst += 4;
  18024.       }
  18025.       dst_row += dst_stride;
  18026.       src_row += src_stride/sizeof(*src_row);
  18027.    }
  18028. }
  18029.  
  18030. static INLINE void
  18031. util_format_r16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  18032. {
  18033.          uint32_t value = *(const uint32_t *)src;
  18034.          uint32_t r;
  18035.          uint32_t a;
  18036.          r = (value) & 0xffff;
  18037.          a = value >> 16;
  18038.          dst[0] = (float)(r * (1.0f/0xffff)); /* r */
  18039.          dst[1] = 0; /* g */
  18040.          dst[2] = 0; /* b */
  18041.          dst[3] = (float)(a * (1.0f/0xffff)); /* a */
  18042. }
  18043.  
  18044. static INLINE void
  18045. util_format_r16a16_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18046. {
  18047.    unsigned x, y;
  18048.    for(y = 0; y < height; y += 1) {
  18049.       uint8_t *dst = dst_row;
  18050.       const uint8_t *src = src_row;
  18051.       for(x = 0; x < width; x += 1) {
  18052.          uint32_t value = *(const uint32_t *)src;
  18053.          uint32_t r;
  18054.          uint32_t a;
  18055.          r = (value) & 0xffff;
  18056.          a = value >> 16;
  18057.          dst[0] = (uint8_t)(r >> 8); /* r */
  18058.          dst[1] = 0; /* g */
  18059.          dst[2] = 0; /* b */
  18060.          dst[3] = (uint8_t)(a >> 8); /* a */
  18061.          src += 4;
  18062.          dst += 4;
  18063.       }
  18064.       src_row += src_stride;
  18065.       dst_row += dst_stride/sizeof(*dst_row);
  18066.    }
  18067. }
  18068.  
  18069. static INLINE void
  18070. util_format_r16a16_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18071. {
  18072.    unsigned x, y;
  18073.    for(y = 0; y < height; y += 1) {
  18074.       const uint8_t *src = src_row;
  18075.       uint8_t *dst = dst_row;
  18076.       for(x = 0; x < width; x += 1) {
  18077.          uint32_t value = 0;
  18078.          value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff;
  18079.          value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16;
  18080.          *(uint32_t *)dst = value;
  18081.          src += 4;
  18082.          dst += 4;
  18083.       }
  18084.       dst_row += dst_stride;
  18085.       src_row += src_stride/sizeof(*src_row);
  18086.    }
  18087. }
  18088.  
  18089. union util_format_r16a16_snorm {
  18090.    uint32_t value;
  18091.    struct {
  18092.       int16_t r;
  18093.       int16_t a;
  18094.    } chan;
  18095. };
  18096.  
  18097. static INLINE void
  18098. util_format_r16a16_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18099. {
  18100.    unsigned x, y;
  18101.    for(y = 0; y < height; y += 1) {
  18102.       float *dst = dst_row;
  18103.       const uint8_t *src = src_row;
  18104.       for(x = 0; x < width; x += 1) {
  18105.          uint32_t value = *(const uint32_t *)src;
  18106.          int32_t r;
  18107.          int32_t a;
  18108.          r = ((int32_t)(value << 16) ) >> 16;
  18109.          a = ((int32_t)(value) ) >> 16;
  18110.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  18111.          dst[1] = 0; /* g */
  18112.          dst[2] = 0; /* b */
  18113.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  18114.          src += 4;
  18115.          dst += 4;
  18116.       }
  18117.       src_row += src_stride;
  18118.       dst_row += dst_stride/sizeof(*dst_row);
  18119.    }
  18120. }
  18121.  
  18122. static INLINE void
  18123. util_format_r16a16_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  18124. {
  18125.    unsigned x, y;
  18126.    for(y = 0; y < height; y += 1) {
  18127.       const float *src = src_row;
  18128.       uint8_t *dst = dst_row;
  18129.       for(x = 0; x < width; x += 1) {
  18130.          uint32_t value = 0;
  18131.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ;
  18132.          value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ;
  18133.          *(uint32_t *)dst = value;
  18134.          src += 4;
  18135.          dst += 4;
  18136.       }
  18137.       dst_row += dst_stride;
  18138.       src_row += src_stride/sizeof(*src_row);
  18139.    }
  18140. }
  18141.  
  18142. static INLINE void
  18143. util_format_r16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  18144. {
  18145.          uint32_t value = *(const uint32_t *)src;
  18146.          int32_t r;
  18147.          int32_t a;
  18148.          r = ((int32_t)(value << 16) ) >> 16;
  18149.          a = ((int32_t)(value) ) >> 16;
  18150.          dst[0] = (float)(r * (1.0f/0x7fff)); /* r */
  18151.          dst[1] = 0; /* g */
  18152.          dst[2] = 0; /* b */
  18153.          dst[3] = (float)(a * (1.0f/0x7fff)); /* a */
  18154. }
  18155.  
  18156. static INLINE void
  18157. util_format_r16a16_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18158. {
  18159.    unsigned x, y;
  18160.    for(y = 0; y < height; y += 1) {
  18161.       uint8_t *dst = dst_row;
  18162.       const uint8_t *src = src_row;
  18163.       for(x = 0; x < width; x += 1) {
  18164.          uint32_t value = *(const uint32_t *)src;
  18165.          int32_t r;
  18166.          int32_t a;
  18167.          r = ((int32_t)(value << 16) ) >> 16;
  18168.          a = ((int32_t)(value) ) >> 16;
  18169.          dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */
  18170.          dst[1] = 0; /* g */
  18171.          dst[2] = 0; /* b */
  18172.          dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */
  18173.          src += 4;
  18174.          dst += 4;
  18175.       }
  18176.       src_row += src_stride;
  18177.       dst_row += dst_stride/sizeof(*dst_row);
  18178.    }
  18179. }
  18180.  
  18181. static INLINE void
  18182. util_format_r16a16_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18183. {
  18184.    unsigned x, y;
  18185.    for(y = 0; y < height; y += 1) {
  18186.       const uint8_t *src = src_row;
  18187.       uint8_t *dst = dst_row;
  18188.       for(x = 0; x < width; x += 1) {
  18189.          uint32_t value = 0;
  18190.          value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ;
  18191.          value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ;
  18192.          *(uint32_t *)dst = value;
  18193.          src += 4;
  18194.          dst += 4;
  18195.       }
  18196.       dst_row += dst_stride;
  18197.       src_row += src_stride/sizeof(*src_row);
  18198.    }
  18199. }
  18200.  
  18201. union util_format_r16a16_float {
  18202.    uint32_t value;
  18203.    struct {
  18204.       uint16_t r;
  18205.       uint16_t a;
  18206.    } chan;
  18207. };
  18208.  
  18209. static INLINE void
  18210. util_format_r16a16_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18211. {
  18212.    unsigned x, y;
  18213.    for(y = 0; y < height; y += 1) {
  18214.       float *dst = dst_row;
  18215.       const uint8_t *src = src_row;
  18216.       for(x = 0; x < width; x += 1) {
  18217.          union util_format_r16a16_float pixel;
  18218.          memcpy(&pixel, src, sizeof pixel);
  18219.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  18220.          dst[1] = 0; /* g */
  18221.          dst[2] = 0; /* b */
  18222.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  18223.          src += 4;
  18224.          dst += 4;
  18225.       }
  18226.       src_row += src_stride;
  18227.       dst_row += dst_stride/sizeof(*dst_row);
  18228.    }
  18229. }
  18230.  
  18231. static INLINE void
  18232. util_format_r16a16_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  18233. {
  18234.    unsigned x, y;
  18235.    for(y = 0; y < height; y += 1) {
  18236.       const float *src = src_row;
  18237.       uint8_t *dst = dst_row;
  18238.       for(x = 0; x < width; x += 1) {
  18239.          union util_format_r16a16_float pixel;
  18240.          pixel.chan.r = util_float_to_half(src[0]);
  18241.          pixel.chan.a = util_float_to_half(src[3]);
  18242.          memcpy(dst, &pixel, sizeof pixel);
  18243.          src += 4;
  18244.          dst += 4;
  18245.       }
  18246.       dst_row += dst_stride;
  18247.       src_row += src_stride/sizeof(*src_row);
  18248.    }
  18249. }
  18250.  
  18251. static INLINE void
  18252. util_format_r16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  18253. {
  18254.          union util_format_r16a16_float pixel;
  18255.          memcpy(&pixel, src, sizeof pixel);
  18256.          dst[0] = util_half_to_float(pixel.chan.r); /* r */
  18257.          dst[1] = 0; /* g */
  18258.          dst[2] = 0; /* b */
  18259.          dst[3] = util_half_to_float(pixel.chan.a); /* a */
  18260. }
  18261.  
  18262. static INLINE void
  18263. util_format_r16a16_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18264. {
  18265.    unsigned x, y;
  18266.    for(y = 0; y < height; y += 1) {
  18267.       uint8_t *dst = dst_row;
  18268.       const uint8_t *src = src_row;
  18269.       for(x = 0; x < width; x += 1) {
  18270.          union util_format_r16a16_float pixel;
  18271.          memcpy(&pixel, src, sizeof pixel);
  18272.          dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */
  18273.          dst[1] = 0; /* g */
  18274.          dst[2] = 0; /* b */
  18275.          dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */
  18276.          src += 4;
  18277.          dst += 4;
  18278.       }
  18279.       src_row += src_stride;
  18280.       dst_row += dst_stride/sizeof(*dst_row);
  18281.    }
  18282. }
  18283.  
  18284. static INLINE void
  18285. util_format_r16a16_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18286. {
  18287.    unsigned x, y;
  18288.    for(y = 0; y < height; y += 1) {
  18289.       const uint8_t *src = src_row;
  18290.       uint8_t *dst = dst_row;
  18291.       for(x = 0; x < width; x += 1) {
  18292.          union util_format_r16a16_float pixel;
  18293.          pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff)));
  18294.          pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff)));
  18295.          memcpy(dst, &pixel, sizeof pixel);
  18296.          src += 4;
  18297.          dst += 4;
  18298.       }
  18299.       dst_row += dst_stride;
  18300.       src_row += src_stride/sizeof(*src_row);
  18301.    }
  18302. }
  18303.  
  18304. union util_format_r32a32_float {
  18305.    uint64_t value;
  18306.    struct {
  18307.       float r;
  18308.       float a;
  18309.    } chan;
  18310. };
  18311.  
  18312. static INLINE void
  18313. util_format_r32a32_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18314. {
  18315.    unsigned x, y;
  18316.    for(y = 0; y < height; y += 1) {
  18317.       float *dst = dst_row;
  18318.       const uint8_t *src = src_row;
  18319.       for(x = 0; x < width; x += 1) {
  18320.          union util_format_r32a32_float pixel;
  18321.          memcpy(&pixel, src, sizeof pixel);
  18322.          dst[0] = pixel.chan.r; /* r */
  18323.          dst[1] = 0; /* g */
  18324.          dst[2] = 0; /* b */
  18325.          dst[3] = pixel.chan.a; /* a */
  18326.          src += 8;
  18327.          dst += 4;
  18328.       }
  18329.       src_row += src_stride;
  18330.       dst_row += dst_stride/sizeof(*dst_row);
  18331.    }
  18332. }
  18333.  
  18334. static INLINE void
  18335. util_format_r32a32_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
  18336. {
  18337.    unsigned x, y;
  18338.    for(y = 0; y < height; y += 1) {
  18339.       const float *src = src_row;
  18340.       uint8_t *dst = dst_row;
  18341.       for(x = 0; x < width; x += 1) {
  18342.          union util_format_r32a32_float pixel;
  18343.          pixel.chan.r = src[0];
  18344.          pixel.chan.a = src[3];
  18345.          memcpy(dst, &pixel, sizeof pixel);
  18346.          src += 4;
  18347.          dst += 8;
  18348.       }
  18349.       dst_row += dst_stride;
  18350.       src_row += src_stride/sizeof(*src_row);
  18351.    }
  18352. }
  18353.  
  18354. static INLINE void
  18355. util_format_r32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
  18356. {
  18357.          union util_format_r32a32_float pixel;
  18358.          memcpy(&pixel, src, sizeof pixel);
  18359.          dst[0] = pixel.chan.r; /* r */
  18360.          dst[1] = 0; /* g */
  18361.          dst[2] = 0; /* b */
  18362.          dst[3] = pixel.chan.a; /* a */
  18363. }
  18364.  
  18365. static INLINE void
  18366. util_format_r32a32_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18367. {
  18368.    unsigned x, y;
  18369.    for(y = 0; y < height; y += 1) {
  18370.       uint8_t *dst = dst_row;
  18371.       const uint8_t *src = src_row;
  18372.       for(x = 0; x < width; x += 1) {
  18373.          union util_format_r32a32_float pixel;
  18374.          memcpy(&pixel, src, sizeof pixel);
  18375.          dst[0] = float_to_ubyte(pixel.chan.r); /* r */
  18376.          dst[1] = 0; /* g */
  18377.          dst[2] = 0; /* b */
  18378.          dst[3] = float_to_ubyte(pixel.chan.a); /* a */
  18379.          src += 8;
  18380.          dst += 4;
  18381.       }
  18382.       src_row += src_stride;
  18383.       dst_row += dst_stride/sizeof(*dst_row);
  18384.    }
  18385. }
  18386.  
  18387. static INLINE void
  18388. util_format_r32a32_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18389. {
  18390.    unsigned x, y;
  18391.    for(y = 0; y < height; y += 1) {
  18392.       const uint8_t *src = src_row;
  18393.       uint8_t *dst = dst_row;
  18394.       for(x = 0; x < width; x += 1) {
  18395.          union util_format_r32a32_float pixel;
  18396.          pixel.chan.r = ubyte_to_float(src[0]);
  18397.          pixel.chan.a = ubyte_to_float(src[3]);
  18398.          memcpy(dst, &pixel, sizeof pixel);
  18399.          src += 4;
  18400.          dst += 8;
  18401.       }
  18402.       dst_row += dst_stride;
  18403.       src_row += src_stride/sizeof(*src_row);
  18404.    }
  18405. }
  18406.  
  18407. union util_format_r8a8_uint {
  18408.    uint16_t value;
  18409.    struct {
  18410.       uint8_t r;
  18411.       uint8_t a;
  18412.    } chan;
  18413. };
  18414.  
  18415. static INLINE void
  18416. util_format_r8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18417. {
  18418.    unsigned x, y;
  18419.    for(y = 0; y < height; y += 1) {
  18420.       unsigned *dst = dst_row;
  18421.       const uint8_t *src = src_row;
  18422.       for(x = 0; x < width; x += 1) {
  18423.          uint16_t value = *(const uint16_t *)src;
  18424.          uint16_t r;
  18425.          uint16_t a;
  18426.          r = (value) & 0xff;
  18427.          a = value >> 8;
  18428.          dst[0] = (unsigned)r; /* r */
  18429.          dst[1] = 0; /* g */
  18430.          dst[2] = 0; /* b */
  18431.          dst[3] = (unsigned)a; /* a */
  18432.          src += 2;
  18433.          dst += 4;
  18434.       }
  18435.       src_row += src_stride;
  18436.       dst_row += dst_stride/sizeof(*dst_row);
  18437.    }
  18438. }
  18439.  
  18440. static INLINE void
  18441. util_format_r8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  18442. {
  18443.    unsigned x, y;
  18444.    for(y = 0; y < height; y += 1) {
  18445.       const unsigned *src = src_row;
  18446.       uint8_t *dst = dst_row;
  18447.       for(x = 0; x < width; x += 1) {
  18448.          uint16_t value = 0;
  18449.          value |= ((uint8_t)MIN2(src[0], 255)) & 0xff;
  18450.          value |= ((uint8_t)MIN2(src[3], 255)) << 8;
  18451.          *(uint16_t *)dst = value;
  18452.          src += 4;
  18453.          dst += 2;
  18454.       }
  18455.       dst_row += dst_stride;
  18456.       src_row += src_stride/sizeof(*src_row);
  18457.    }
  18458. }
  18459.  
  18460. static INLINE void
  18461. util_format_r8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  18462. {
  18463.          uint16_t value = *(const uint16_t *)src;
  18464.          uint16_t r;
  18465.          uint16_t a;
  18466.          r = (value) & 0xff;
  18467.          a = value >> 8;
  18468.          dst[0] = (unsigned)r; /* r */
  18469.          dst[1] = 0; /* g */
  18470.          dst[2] = 0; /* b */
  18471.          dst[3] = (unsigned)a; /* a */
  18472. }
  18473.  
  18474. static INLINE void
  18475. util_format_r8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18476. {
  18477.    unsigned x, y;
  18478.    for(y = 0; y < height; y += 1) {
  18479.       int *dst = dst_row;
  18480.       const uint8_t *src = src_row;
  18481.       for(x = 0; x < width; x += 1) {
  18482.          uint16_t value = *(const uint16_t *)src;
  18483.          uint16_t r;
  18484.          uint16_t a;
  18485.          r = (value) & 0xff;
  18486.          a = value >> 8;
  18487.          dst[0] = (int)r; /* r */
  18488.          dst[1] = 0; /* g */
  18489.          dst[2] = 0; /* b */
  18490.          dst[3] = (int)a; /* a */
  18491.          src += 2;
  18492.          dst += 4;
  18493.       }
  18494.       src_row += src_stride;
  18495.       dst_row += dst_stride/sizeof(*dst_row);
  18496.    }
  18497. }
  18498.  
  18499. static INLINE void
  18500. util_format_r8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18501. {
  18502.    unsigned x, y;
  18503.    for(y = 0; y < height; y += 1) {
  18504.       const int *src = src_row;
  18505.       uint8_t *dst = dst_row;
  18506.       for(x = 0; x < width; x += 1) {
  18507.          uint16_t value = 0;
  18508.          value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff;
  18509.          value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8;
  18510.          *(uint16_t *)dst = value;
  18511.          src += 4;
  18512.          dst += 2;
  18513.       }
  18514.       dst_row += dst_stride;
  18515.       src_row += src_stride/sizeof(*src_row);
  18516.    }
  18517. }
  18518.  
  18519. union util_format_r8a8_sint {
  18520.    uint16_t value;
  18521.    struct {
  18522.       int8_t r;
  18523.       int8_t a;
  18524.    } chan;
  18525. };
  18526.  
  18527. static INLINE void
  18528. util_format_r8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18529. {
  18530.    unsigned x, y;
  18531.    for(y = 0; y < height; y += 1) {
  18532.       int *dst = dst_row;
  18533.       const uint8_t *src = src_row;
  18534.       for(x = 0; x < width; x += 1) {
  18535.          uint16_t value = *(const uint16_t *)src;
  18536.          int16_t r;
  18537.          int16_t a;
  18538.          r = ((int16_t)(value << 8) ) >> 8;
  18539.          a = ((int16_t)(value) ) >> 8;
  18540.          dst[0] = (int)r; /* r */
  18541.          dst[1] = 0; /* g */
  18542.          dst[2] = 0; /* b */
  18543.          dst[3] = (int)a; /* a */
  18544.          src += 2;
  18545.          dst += 4;
  18546.       }
  18547.       src_row += src_stride;
  18548.       dst_row += dst_stride/sizeof(*dst_row);
  18549.    }
  18550. }
  18551.  
  18552. static INLINE void
  18553. util_format_r8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18554. {
  18555.    unsigned x, y;
  18556.    for(y = 0; y < height; y += 1) {
  18557.       const int *src = src_row;
  18558.       uint8_t *dst = dst_row;
  18559.       for(x = 0; x < width; x += 1) {
  18560.          uint16_t value = 0;
  18561.          value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ;
  18562.          value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ;
  18563.          *(uint16_t *)dst = value;
  18564.          src += 4;
  18565.          dst += 2;
  18566.       }
  18567.       dst_row += dst_stride;
  18568.       src_row += src_stride/sizeof(*src_row);
  18569.    }
  18570. }
  18571.  
  18572. static INLINE void
  18573. util_format_r8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  18574. {
  18575.          uint16_t value = *(const uint16_t *)src;
  18576.          int16_t r;
  18577.          int16_t a;
  18578.          r = ((int16_t)(value << 8) ) >> 8;
  18579.          a = ((int16_t)(value) ) >> 8;
  18580.          dst[0] = (int)r; /* r */
  18581.          dst[1] = 0; /* g */
  18582.          dst[2] = 0; /* b */
  18583.          dst[3] = (int)a; /* a */
  18584. }
  18585.  
  18586. static INLINE void
  18587. util_format_r8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18588. {
  18589.    unsigned x, y;
  18590.    for(y = 0; y < height; y += 1) {
  18591.       unsigned *dst = dst_row;
  18592.       const uint8_t *src = src_row;
  18593.       for(x = 0; x < width; x += 1) {
  18594.          uint16_t value = *(const uint16_t *)src;
  18595.          int16_t r;
  18596.          int16_t a;
  18597.          r = ((int16_t)(value << 8) ) >> 8;
  18598.          a = ((int16_t)(value) ) >> 8;
  18599.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  18600.          dst[1] = 0; /* g */
  18601.          dst[2] = 0; /* b */
  18602.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  18603.          src += 2;
  18604.          dst += 4;
  18605.       }
  18606.       src_row += src_stride;
  18607.       dst_row += dst_stride/sizeof(*dst_row);
  18608.    }
  18609. }
  18610.  
  18611. static INLINE void
  18612. util_format_r8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  18613. {
  18614.    unsigned x, y;
  18615.    for(y = 0; y < height; y += 1) {
  18616.       const unsigned *src = src_row;
  18617.       uint8_t *dst = dst_row;
  18618.       for(x = 0; x < width; x += 1) {
  18619.          uint16_t value = 0;
  18620.          value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ;
  18621.          value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ;
  18622.          *(uint16_t *)dst = value;
  18623.          src += 4;
  18624.          dst += 2;
  18625.       }
  18626.       dst_row += dst_stride;
  18627.       src_row += src_stride/sizeof(*src_row);
  18628.    }
  18629. }
  18630.  
  18631. union util_format_r16a16_uint {
  18632.    uint32_t value;
  18633.    struct {
  18634.       uint16_t r;
  18635.       uint16_t a;
  18636.    } chan;
  18637. };
  18638.  
  18639. static INLINE void
  18640. util_format_r16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18641. {
  18642.    unsigned x, y;
  18643.    for(y = 0; y < height; y += 1) {
  18644.       unsigned *dst = dst_row;
  18645.       const uint8_t *src = src_row;
  18646.       for(x = 0; x < width; x += 1) {
  18647.          uint32_t value = *(const uint32_t *)src;
  18648.          uint32_t r;
  18649.          uint32_t a;
  18650.          r = (value) & 0xffff;
  18651.          a = value >> 16;
  18652.          dst[0] = (unsigned)r; /* r */
  18653.          dst[1] = 0; /* g */
  18654.          dst[2] = 0; /* b */
  18655.          dst[3] = (unsigned)a; /* a */
  18656.          src += 4;
  18657.          dst += 4;
  18658.       }
  18659.       src_row += src_stride;
  18660.       dst_row += dst_stride/sizeof(*dst_row);
  18661.    }
  18662. }
  18663.  
  18664. static INLINE void
  18665. util_format_r16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  18666. {
  18667.    unsigned x, y;
  18668.    for(y = 0; y < height; y += 1) {
  18669.       const unsigned *src = src_row;
  18670.       uint8_t *dst = dst_row;
  18671.       for(x = 0; x < width; x += 1) {
  18672.          uint32_t value = 0;
  18673.          value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff;
  18674.          value |= ((uint16_t)MIN2(src[3], 65535)) << 16;
  18675.          *(uint32_t *)dst = value;
  18676.          src += 4;
  18677.          dst += 4;
  18678.       }
  18679.       dst_row += dst_stride;
  18680.       src_row += src_stride/sizeof(*src_row);
  18681.    }
  18682. }
  18683.  
  18684. static INLINE void
  18685. util_format_r16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  18686. {
  18687.          uint32_t value = *(const uint32_t *)src;
  18688.          uint32_t r;
  18689.          uint32_t a;
  18690.          r = (value) & 0xffff;
  18691.          a = value >> 16;
  18692.          dst[0] = (unsigned)r; /* r */
  18693.          dst[1] = 0; /* g */
  18694.          dst[2] = 0; /* b */
  18695.          dst[3] = (unsigned)a; /* a */
  18696. }
  18697.  
  18698. static INLINE void
  18699. util_format_r16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18700. {
  18701.    unsigned x, y;
  18702.    for(y = 0; y < height; y += 1) {
  18703.       int *dst = dst_row;
  18704.       const uint8_t *src = src_row;
  18705.       for(x = 0; x < width; x += 1) {
  18706.          uint32_t value = *(const uint32_t *)src;
  18707.          uint32_t r;
  18708.          uint32_t a;
  18709.          r = (value) & 0xffff;
  18710.          a = value >> 16;
  18711.          dst[0] = (int)r; /* r */
  18712.          dst[1] = 0; /* g */
  18713.          dst[2] = 0; /* b */
  18714.          dst[3] = (int)a; /* a */
  18715.          src += 4;
  18716.          dst += 4;
  18717.       }
  18718.       src_row += src_stride;
  18719.       dst_row += dst_stride/sizeof(*dst_row);
  18720.    }
  18721. }
  18722.  
  18723. static INLINE void
  18724. util_format_r16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18725. {
  18726.    unsigned x, y;
  18727.    for(y = 0; y < height; y += 1) {
  18728.       const int *src = src_row;
  18729.       uint8_t *dst = dst_row;
  18730.       for(x = 0; x < width; x += 1) {
  18731.          uint32_t value = 0;
  18732.          value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff;
  18733.          value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16;
  18734.          *(uint32_t *)dst = value;
  18735.          src += 4;
  18736.          dst += 4;
  18737.       }
  18738.       dst_row += dst_stride;
  18739.       src_row += src_stride/sizeof(*src_row);
  18740.    }
  18741. }
  18742.  
  18743. union util_format_r16a16_sint {
  18744.    uint32_t value;
  18745.    struct {
  18746.       int16_t r;
  18747.       int16_t a;
  18748.    } chan;
  18749. };
  18750.  
  18751. static INLINE void
  18752. util_format_r16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18753. {
  18754.    unsigned x, y;
  18755.    for(y = 0; y < height; y += 1) {
  18756.       int *dst = dst_row;
  18757.       const uint8_t *src = src_row;
  18758.       for(x = 0; x < width; x += 1) {
  18759.          uint32_t value = *(const uint32_t *)src;
  18760.          int32_t r;
  18761.          int32_t a;
  18762.          r = ((int32_t)(value << 16) ) >> 16;
  18763.          a = ((int32_t)(value) ) >> 16;
  18764.          dst[0] = (int)r; /* r */
  18765.          dst[1] = 0; /* g */
  18766.          dst[2] = 0; /* b */
  18767.          dst[3] = (int)a; /* a */
  18768.          src += 4;
  18769.          dst += 4;
  18770.       }
  18771.       src_row += src_stride;
  18772.       dst_row += dst_stride/sizeof(*dst_row);
  18773.    }
  18774. }
  18775.  
  18776. static INLINE void
  18777. util_format_r16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18778. {
  18779.    unsigned x, y;
  18780.    for(y = 0; y < height; y += 1) {
  18781.       const int *src = src_row;
  18782.       uint8_t *dst = dst_row;
  18783.       for(x = 0; x < width; x += 1) {
  18784.          uint32_t value = 0;
  18785.          value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ;
  18786.          value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ;
  18787.          *(uint32_t *)dst = value;
  18788.          src += 4;
  18789.          dst += 4;
  18790.       }
  18791.       dst_row += dst_stride;
  18792.       src_row += src_stride/sizeof(*src_row);
  18793.    }
  18794. }
  18795.  
  18796. static INLINE void
  18797. util_format_r16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  18798. {
  18799.          uint32_t value = *(const uint32_t *)src;
  18800.          int32_t r;
  18801.          int32_t a;
  18802.          r = ((int32_t)(value << 16) ) >> 16;
  18803.          a = ((int32_t)(value) ) >> 16;
  18804.          dst[0] = (int)r; /* r */
  18805.          dst[1] = 0; /* g */
  18806.          dst[2] = 0; /* b */
  18807.          dst[3] = (int)a; /* a */
  18808. }
  18809.  
  18810. static INLINE void
  18811. util_format_r16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18812. {
  18813.    unsigned x, y;
  18814.    for(y = 0; y < height; y += 1) {
  18815.       unsigned *dst = dst_row;
  18816.       const uint8_t *src = src_row;
  18817.       for(x = 0; x < width; x += 1) {
  18818.          uint32_t value = *(const uint32_t *)src;
  18819.          int32_t r;
  18820.          int32_t a;
  18821.          r = ((int32_t)(value << 16) ) >> 16;
  18822.          a = ((int32_t)(value) ) >> 16;
  18823.          dst[0] = (unsigned)MAX2(r, 0); /* r */
  18824.          dst[1] = 0; /* g */
  18825.          dst[2] = 0; /* b */
  18826.          dst[3] = (unsigned)MAX2(a, 0); /* a */
  18827.          src += 4;
  18828.          dst += 4;
  18829.       }
  18830.       src_row += src_stride;
  18831.       dst_row += dst_stride/sizeof(*dst_row);
  18832.    }
  18833. }
  18834.  
  18835. static INLINE void
  18836. util_format_r16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  18837. {
  18838.    unsigned x, y;
  18839.    for(y = 0; y < height; y += 1) {
  18840.       const unsigned *src = src_row;
  18841.       uint8_t *dst = dst_row;
  18842.       for(x = 0; x < width; x += 1) {
  18843.          uint32_t value = 0;
  18844.          value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ;
  18845.          value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ;
  18846.          *(uint32_t *)dst = value;
  18847.          src += 4;
  18848.          dst += 4;
  18849.       }
  18850.       dst_row += dst_stride;
  18851.       src_row += src_stride/sizeof(*src_row);
  18852.    }
  18853. }
  18854.  
  18855. union util_format_r32a32_uint {
  18856.    uint64_t value;
  18857.    struct {
  18858.       uint32_t r;
  18859.       uint32_t a;
  18860.    } chan;
  18861. };
  18862.  
  18863. static INLINE void
  18864. util_format_r32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18865. {
  18866.    unsigned x, y;
  18867.    for(y = 0; y < height; y += 1) {
  18868.       unsigned *dst = dst_row;
  18869.       const uint8_t *src = src_row;
  18870.       for(x = 0; x < width; x += 1) {
  18871.          union util_format_r32a32_uint pixel;
  18872.          memcpy(&pixel, src, sizeof pixel);
  18873.          dst[0] = pixel.chan.r; /* r */
  18874.          dst[1] = 0; /* g */
  18875.          dst[2] = 0; /* b */
  18876.          dst[3] = pixel.chan.a; /* a */
  18877.          src += 8;
  18878.          dst += 4;
  18879.       }
  18880.       src_row += src_stride;
  18881.       dst_row += dst_stride/sizeof(*dst_row);
  18882.    }
  18883. }
  18884.  
  18885. static INLINE void
  18886. util_format_r32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  18887. {
  18888.    unsigned x, y;
  18889.    for(y = 0; y < height; y += 1) {
  18890.       const unsigned *src = src_row;
  18891.       uint8_t *dst = dst_row;
  18892.       for(x = 0; x < width; x += 1) {
  18893.          union util_format_r32a32_uint pixel;
  18894.          pixel.chan.r = src[0];
  18895.          pixel.chan.a = src[3];
  18896.          memcpy(dst, &pixel, sizeof pixel);
  18897.          src += 4;
  18898.          dst += 8;
  18899.       }
  18900.       dst_row += dst_stride;
  18901.       src_row += src_stride/sizeof(*src_row);
  18902.    }
  18903. }
  18904.  
  18905. static INLINE void
  18906. util_format_r32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j)
  18907. {
  18908.          union util_format_r32a32_uint pixel;
  18909.          memcpy(&pixel, src, sizeof pixel);
  18910.          dst[0] = pixel.chan.r; /* r */
  18911.          dst[1] = 0; /* g */
  18912.          dst[2] = 0; /* b */
  18913.          dst[3] = pixel.chan.a; /* a */
  18914. }
  18915.  
  18916. static INLINE void
  18917. util_format_r32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18918. {
  18919.    unsigned x, y;
  18920.    for(y = 0; y < height; y += 1) {
  18921.       int *dst = dst_row;
  18922.       const uint8_t *src = src_row;
  18923.       for(x = 0; x < width; x += 1) {
  18924.          union util_format_r32a32_uint pixel;
  18925.          memcpy(&pixel, src, sizeof pixel);
  18926.          dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */
  18927.          dst[1] = 0; /* g */
  18928.          dst[2] = 0; /* b */
  18929.          dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */
  18930.          src += 8;
  18931.          dst += 4;
  18932.       }
  18933.       src_row += src_stride;
  18934.       dst_row += dst_stride/sizeof(*dst_row);
  18935.    }
  18936. }
  18937.  
  18938. static INLINE void
  18939. util_format_r32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18940. {
  18941.    unsigned x, y;
  18942.    for(y = 0; y < height; y += 1) {
  18943.       const int *src = src_row;
  18944.       uint8_t *dst = dst_row;
  18945.       for(x = 0; x < width; x += 1) {
  18946.          union util_format_r32a32_uint pixel;
  18947.          pixel.chan.r = (uint32_t)MAX2(src[0], 0);
  18948.          pixel.chan.a = (uint32_t)MAX2(src[3], 0);
  18949.          memcpy(dst, &pixel, sizeof pixel);
  18950.          src += 4;
  18951.          dst += 8;
  18952.       }
  18953.       dst_row += dst_stride;
  18954.       src_row += src_stride/sizeof(*src_row);
  18955.    }
  18956. }
  18957.  
  18958. union util_format_r32a32_sint {
  18959.    uint64_t value;
  18960.    struct {
  18961.       int32_t r;
  18962.       int32_t a;
  18963.    } chan;
  18964. };
  18965.  
  18966. static INLINE void
  18967. util_format_r32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  18968. {
  18969.    unsigned x, y;
  18970.    for(y = 0; y < height; y += 1) {
  18971.       int *dst = dst_row;
  18972.       const uint8_t *src = src_row;
  18973.       for(x = 0; x < width; x += 1) {
  18974.          union util_format_r32a32_sint pixel;
  18975.          memcpy(&pixel, src, sizeof pixel);
  18976.          dst[0] = pixel.chan.r; /* r */
  18977.          dst[1] = 0; /* g */
  18978.          dst[2] = 0; /* b */
  18979.          dst[3] = pixel.chan.a; /* a */
  18980.          src += 8;
  18981.          dst += 4;
  18982.       }
  18983.       src_row += src_stride;
  18984.       dst_row += dst_stride/sizeof(*dst_row);
  18985.    }
  18986. }
  18987.  
  18988. static INLINE void
  18989. util_format_r32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height)
  18990. {
  18991.    unsigned x, y;
  18992.    for(y = 0; y < height; y += 1) {
  18993.       const int *src = src_row;
  18994.       uint8_t *dst = dst_row;
  18995.       for(x = 0; x < width; x += 1) {
  18996.          union util_format_r32a32_sint pixel;
  18997.          pixel.chan.r = src[0];
  18998.          pixel.chan.a = src[3];
  18999.          memcpy(dst, &pixel, sizeof pixel);
  19000.          src += 4;
  19001.          dst += 8;
  19002.       }
  19003.       dst_row += dst_stride;
  19004.       src_row += src_stride/sizeof(*src_row);
  19005.    }
  19006. }
  19007.  
  19008. static INLINE void
  19009. util_format_r32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j)
  19010. {
  19011.          union util_format_r32a32_sint pixel;
  19012.          memcpy(&pixel, src, sizeof pixel);
  19013.          dst[0] = pixel.chan.r; /* r */
  19014.          dst[1] = 0; /* g */
  19015.          dst[2] = 0; /* b */
  19016.          dst[3] = pixel.chan.a; /* a */
  19017. }
  19018.  
  19019. static INLINE void
  19020. util_format_r32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
  19021. {
  19022.    unsigned x, y;
  19023.    for(y = 0; y < height; y += 1) {
  19024.       unsigned *dst = dst_row;
  19025.       const uint8_t *src = src_row;
  19026.       for(x = 0; x < width; x += 1) {
  19027.          union util_format_r32a32_sint pixel;
  19028.          memcpy(&pixel, src, sizeof pixel);
  19029.          dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */
  19030.          dst[1] = 0; /* g */
  19031.          dst[2] = 0; /* b */
  19032.          dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */
  19033.          src += 8;
  19034.          dst += 4;
  19035.       }
  19036.       src_row += src_stride;
  19037.       dst_row += dst_stride/sizeof(*dst_row);
  19038.    }
  19039. }
  19040.  
  19041. static INLINE void
  19042. util_format_r32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height)
  19043. {
  19044.    unsigned x, y;
  19045.    for(y = 0; y < height; y += 1) {
  19046.       const unsigned *src = src_row;
  19047.       uint8_t *dst = dst_row;
  19048.       for(x = 0; x < width; x += 1) {
  19049.          union util_format_r32a32_sint pixel;
  19050.          pixel.chan.r = (int32_t)MIN2(src[0], 2147483647);
  19051.          pixel.chan.a = (int32_t)MIN2(src[3], 2147483647);
  19052.          memcpy(dst, &pixel, sizeof pixel);
  19053.          src += 4;
  19054.          dst += 8;
  19055.       }
  19056.       dst_row += dst_stride;
  19057.       src_row += src_stride/sizeof(*src_row);
  19058.    }
  19059. }
  19060.  
  19061. const struct util_format_description
  19062. util_format_none_description = {
  19063.    PIPE_FORMAT_NONE,
  19064.    "PIPE_FORMAT_NONE",
  19065.    "none",
  19066.    {1, 1, 8},   /* block */
  19067.    UTIL_FORMAT_LAYOUT_PLAIN,
  19068.    1,   /* nr_channels */
  19069.    TRUE,        /* is_array */
  19070.    TRUE,        /* is_bitmask */
  19071.    FALSE,       /* is_mixed */
  19072.    {
  19073.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0},  /* x = r */
  19074.       {0, 0, 0, 0, 0},
  19075.       {0, 0, 0, 0, 0},
  19076.       {0, 0, 0, 0, 0}
  19077.    },
  19078.    {
  19079.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19080.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  19081.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  19082.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19083.    },
  19084.    UTIL_FORMAT_COLORSPACE_RGB,
  19085.    &util_format_none_unpack_rgba_8unorm,
  19086.    &util_format_none_pack_rgba_8unorm,
  19087.    NULL, /* fetch_rgba_8unorm */
  19088.    &util_format_none_unpack_rgba_float,
  19089.    &util_format_none_pack_rgba_float,
  19090.    &util_format_none_fetch_rgba_float,
  19091.    NULL, /* unpack_z_32unorm */
  19092.    NULL, /* pack_z_32unorm */
  19093.    NULL, /* unpack_z_float */
  19094.    NULL, /* pack_z_float */
  19095.    NULL, /* unpack_s_8uint */
  19096.    NULL, /* pack_s_8uint */
  19097.    NULL, /* unpack_rgba_uint */
  19098.    NULL, /* pack_rgba_uint */
  19099.    NULL, /* unpack_rgba_sint */
  19100.    NULL, /* pack_rgba_sint */
  19101.    NULL, /* fetch_rgba_uint */
  19102.    NULL  /* fetch_rgba_sint */
  19103. };
  19104.  
  19105. const struct util_format_description
  19106. util_format_b8g8r8a8_unorm_description = {
  19107.    PIPE_FORMAT_B8G8R8A8_UNORM,
  19108.    "PIPE_FORMAT_B8G8R8A8_UNORM",
  19109.    "b8g8r8a8_unorm",
  19110.    {1, 1, 32},  /* block */
  19111.    UTIL_FORMAT_LAYOUT_PLAIN,
  19112.    4,   /* nr_channels */
  19113.    TRUE,        /* is_array */
  19114.    TRUE,        /* is_bitmask */
  19115.    FALSE,       /* is_mixed */
  19116.    {
  19117.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = b */
  19118.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  19119.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = r */
  19120.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = a */
  19121.    },
  19122.    {
  19123.       UTIL_FORMAT_SWIZZLE_Z,    /* r */
  19124.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  19125.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19126.       UTIL_FORMAT_SWIZZLE_W     /* a */
  19127.    },
  19128.    UTIL_FORMAT_COLORSPACE_RGB,
  19129.    &util_format_b8g8r8a8_unorm_unpack_rgba_8unorm,
  19130.    &util_format_b8g8r8a8_unorm_pack_rgba_8unorm,
  19131.    NULL, /* fetch_rgba_8unorm */
  19132.    &util_format_b8g8r8a8_unorm_unpack_rgba_float,
  19133.    &util_format_b8g8r8a8_unorm_pack_rgba_float,
  19134.    &util_format_b8g8r8a8_unorm_fetch_rgba_float,
  19135.    NULL, /* unpack_z_32unorm */
  19136.    NULL, /* pack_z_32unorm */
  19137.    NULL, /* unpack_z_float */
  19138.    NULL, /* pack_z_float */
  19139.    NULL, /* unpack_s_8uint */
  19140.    NULL, /* pack_s_8uint */
  19141.    NULL, /* unpack_rgba_uint */
  19142.    NULL, /* pack_rgba_uint */
  19143.    NULL, /* unpack_rgba_sint */
  19144.    NULL, /* pack_rgba_sint */
  19145.    NULL, /* fetch_rgba_uint */
  19146.    NULL  /* fetch_rgba_sint */
  19147. };
  19148.  
  19149. const struct util_format_description
  19150. util_format_b8g8r8x8_unorm_description = {
  19151.    PIPE_FORMAT_B8G8R8X8_UNORM,
  19152.    "PIPE_FORMAT_B8G8R8X8_UNORM",
  19153.    "b8g8r8x8_unorm",
  19154.    {1, 1, 32},  /* block */
  19155.    UTIL_FORMAT_LAYOUT_PLAIN,
  19156.    4,   /* nr_channels */
  19157.    TRUE,        /* is_array */
  19158.    TRUE,        /* is_bitmask */
  19159.    FALSE,       /* is_mixed */
  19160.    {
  19161.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = b */
  19162.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  19163.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = r */
  19164.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  19165.    },
  19166.    {
  19167.       UTIL_FORMAT_SWIZZLE_Z,    /* r */
  19168.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  19169.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19170.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19171.    },
  19172.    UTIL_FORMAT_COLORSPACE_RGB,
  19173.    &util_format_b8g8r8x8_unorm_unpack_rgba_8unorm,
  19174.    &util_format_b8g8r8x8_unorm_pack_rgba_8unorm,
  19175.    NULL, /* fetch_rgba_8unorm */
  19176.    &util_format_b8g8r8x8_unorm_unpack_rgba_float,
  19177.    &util_format_b8g8r8x8_unorm_pack_rgba_float,
  19178.    &util_format_b8g8r8x8_unorm_fetch_rgba_float,
  19179.    NULL, /* unpack_z_32unorm */
  19180.    NULL, /* pack_z_32unorm */
  19181.    NULL, /* unpack_z_float */
  19182.    NULL, /* pack_z_float */
  19183.    NULL, /* unpack_s_8uint */
  19184.    NULL, /* pack_s_8uint */
  19185.    NULL, /* unpack_rgba_uint */
  19186.    NULL, /* pack_rgba_uint */
  19187.    NULL, /* unpack_rgba_sint */
  19188.    NULL, /* pack_rgba_sint */
  19189.    NULL, /* fetch_rgba_uint */
  19190.    NULL  /* fetch_rgba_sint */
  19191. };
  19192.  
  19193. const struct util_format_description
  19194. util_format_a8r8g8b8_unorm_description = {
  19195.    PIPE_FORMAT_A8R8G8B8_UNORM,
  19196.    "PIPE_FORMAT_A8R8G8B8_UNORM",
  19197.    "a8r8g8b8_unorm",
  19198.    {1, 1, 32},  /* block */
  19199.    UTIL_FORMAT_LAYOUT_PLAIN,
  19200.    4,   /* nr_channels */
  19201.    TRUE,        /* is_array */
  19202.    TRUE,        /* is_bitmask */
  19203.    FALSE,       /* is_mixed */
  19204.    {
  19205.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = a */
  19206.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = r */
  19207.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = g */
  19208.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = b */
  19209.    },
  19210.    {
  19211.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  19212.       UTIL_FORMAT_SWIZZLE_Z,    /* g */
  19213.       UTIL_FORMAT_SWIZZLE_W,    /* b */
  19214.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19215.    },
  19216.    UTIL_FORMAT_COLORSPACE_RGB,
  19217.    &util_format_a8r8g8b8_unorm_unpack_rgba_8unorm,
  19218.    &util_format_a8r8g8b8_unorm_pack_rgba_8unorm,
  19219.    NULL, /* fetch_rgba_8unorm */
  19220.    &util_format_a8r8g8b8_unorm_unpack_rgba_float,
  19221.    &util_format_a8r8g8b8_unorm_pack_rgba_float,
  19222.    &util_format_a8r8g8b8_unorm_fetch_rgba_float,
  19223.    NULL, /* unpack_z_32unorm */
  19224.    NULL, /* pack_z_32unorm */
  19225.    NULL, /* unpack_z_float */
  19226.    NULL, /* pack_z_float */
  19227.    NULL, /* unpack_s_8uint */
  19228.    NULL, /* pack_s_8uint */
  19229.    NULL, /* unpack_rgba_uint */
  19230.    NULL, /* pack_rgba_uint */
  19231.    NULL, /* unpack_rgba_sint */
  19232.    NULL, /* pack_rgba_sint */
  19233.    NULL, /* fetch_rgba_uint */
  19234.    NULL  /* fetch_rgba_sint */
  19235. };
  19236.  
  19237. const struct util_format_description
  19238. util_format_x8r8g8b8_unorm_description = {
  19239.    PIPE_FORMAT_X8R8G8B8_UNORM,
  19240.    "PIPE_FORMAT_X8R8G8B8_UNORM",
  19241.    "x8r8g8b8_unorm",
  19242.    {1, 1, 32},  /* block */
  19243.    UTIL_FORMAT_LAYOUT_PLAIN,
  19244.    4,   /* nr_channels */
  19245.    TRUE,        /* is_array */
  19246.    TRUE,        /* is_bitmask */
  19247.    FALSE,       /* is_mixed */
  19248.    {
  19249.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  19250.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = r */
  19251.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = g */
  19252.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = b */
  19253.    },
  19254.    {
  19255.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  19256.       UTIL_FORMAT_SWIZZLE_Z,    /* g */
  19257.       UTIL_FORMAT_SWIZZLE_W,    /* b */
  19258.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19259.    },
  19260.    UTIL_FORMAT_COLORSPACE_RGB,
  19261.    &util_format_x8r8g8b8_unorm_unpack_rgba_8unorm,
  19262.    &util_format_x8r8g8b8_unorm_pack_rgba_8unorm,
  19263.    NULL, /* fetch_rgba_8unorm */
  19264.    &util_format_x8r8g8b8_unorm_unpack_rgba_float,
  19265.    &util_format_x8r8g8b8_unorm_pack_rgba_float,
  19266.    &util_format_x8r8g8b8_unorm_fetch_rgba_float,
  19267.    NULL, /* unpack_z_32unorm */
  19268.    NULL, /* pack_z_32unorm */
  19269.    NULL, /* unpack_z_float */
  19270.    NULL, /* pack_z_float */
  19271.    NULL, /* unpack_s_8uint */
  19272.    NULL, /* pack_s_8uint */
  19273.    NULL, /* unpack_rgba_uint */
  19274.    NULL, /* pack_rgba_uint */
  19275.    NULL, /* unpack_rgba_sint */
  19276.    NULL, /* pack_rgba_sint */
  19277.    NULL, /* fetch_rgba_uint */
  19278.    NULL  /* fetch_rgba_sint */
  19279. };
  19280.  
  19281. const struct util_format_description
  19282. util_format_a8b8g8r8_unorm_description = {
  19283.    PIPE_FORMAT_A8B8G8R8_UNORM,
  19284.    "PIPE_FORMAT_A8B8G8R8_UNORM",
  19285.    "a8b8g8r8_unorm",
  19286.    {1, 1, 32},  /* block */
  19287.    UTIL_FORMAT_LAYOUT_PLAIN,
  19288.    4,   /* nr_channels */
  19289.    TRUE,        /* is_array */
  19290.    TRUE,        /* is_bitmask */
  19291.    FALSE,       /* is_mixed */
  19292.    {
  19293.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = a */
  19294.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = b */
  19295.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = g */
  19296.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = r */
  19297.    },
  19298.    {
  19299.       UTIL_FORMAT_SWIZZLE_W,    /* r */
  19300.       UTIL_FORMAT_SWIZZLE_Z,    /* g */
  19301.       UTIL_FORMAT_SWIZZLE_Y,    /* b */
  19302.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19303.    },
  19304.    UTIL_FORMAT_COLORSPACE_RGB,
  19305.    &util_format_a8b8g8r8_unorm_unpack_rgba_8unorm,
  19306.    &util_format_a8b8g8r8_unorm_pack_rgba_8unorm,
  19307.    NULL, /* fetch_rgba_8unorm */
  19308.    &util_format_a8b8g8r8_unorm_unpack_rgba_float,
  19309.    &util_format_a8b8g8r8_unorm_pack_rgba_float,
  19310.    &util_format_a8b8g8r8_unorm_fetch_rgba_float,
  19311.    NULL, /* unpack_z_32unorm */
  19312.    NULL, /* pack_z_32unorm */
  19313.    NULL, /* unpack_z_float */
  19314.    NULL, /* pack_z_float */
  19315.    NULL, /* unpack_s_8uint */
  19316.    NULL, /* pack_s_8uint */
  19317.    NULL, /* unpack_rgba_uint */
  19318.    NULL, /* pack_rgba_uint */
  19319.    NULL, /* unpack_rgba_sint */
  19320.    NULL, /* pack_rgba_sint */
  19321.    NULL, /* fetch_rgba_uint */
  19322.    NULL  /* fetch_rgba_sint */
  19323. };
  19324.  
  19325. const struct util_format_description
  19326. util_format_x8b8g8r8_unorm_description = {
  19327.    PIPE_FORMAT_X8B8G8R8_UNORM,
  19328.    "PIPE_FORMAT_X8B8G8R8_UNORM",
  19329.    "x8b8g8r8_unorm",
  19330.    {1, 1, 32},  /* block */
  19331.    UTIL_FORMAT_LAYOUT_PLAIN,
  19332.    4,   /* nr_channels */
  19333.    TRUE,        /* is_array */
  19334.    TRUE,        /* is_bitmask */
  19335.    FALSE,       /* is_mixed */
  19336.    {
  19337.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  19338.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = b */
  19339.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = g */
  19340.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = r */
  19341.    },
  19342.    {
  19343.       UTIL_FORMAT_SWIZZLE_W,    /* r */
  19344.       UTIL_FORMAT_SWIZZLE_Z,    /* g */
  19345.       UTIL_FORMAT_SWIZZLE_Y,    /* b */
  19346.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19347.    },
  19348.    UTIL_FORMAT_COLORSPACE_RGB,
  19349.    &util_format_x8b8g8r8_unorm_unpack_rgba_8unorm,
  19350.    &util_format_x8b8g8r8_unorm_pack_rgba_8unorm,
  19351.    NULL, /* fetch_rgba_8unorm */
  19352.    &util_format_x8b8g8r8_unorm_unpack_rgba_float,
  19353.    &util_format_x8b8g8r8_unorm_pack_rgba_float,
  19354.    &util_format_x8b8g8r8_unorm_fetch_rgba_float,
  19355.    NULL, /* unpack_z_32unorm */
  19356.    NULL, /* pack_z_32unorm */
  19357.    NULL, /* unpack_z_float */
  19358.    NULL, /* pack_z_float */
  19359.    NULL, /* unpack_s_8uint */
  19360.    NULL, /* pack_s_8uint */
  19361.    NULL, /* unpack_rgba_uint */
  19362.    NULL, /* pack_rgba_uint */
  19363.    NULL, /* unpack_rgba_sint */
  19364.    NULL, /* pack_rgba_sint */
  19365.    NULL, /* fetch_rgba_uint */
  19366.    NULL  /* fetch_rgba_sint */
  19367. };
  19368.  
  19369. const struct util_format_description
  19370. util_format_r8g8b8x8_unorm_description = {
  19371.    PIPE_FORMAT_R8G8B8X8_UNORM,
  19372.    "PIPE_FORMAT_R8G8B8X8_UNORM",
  19373.    "r8g8b8x8_unorm",
  19374.    {1, 1, 32},  /* block */
  19375.    UTIL_FORMAT_LAYOUT_PLAIN,
  19376.    4,   /* nr_channels */
  19377.    TRUE,        /* is_array */
  19378.    TRUE,        /* is_bitmask */
  19379.    FALSE,       /* is_mixed */
  19380.    {
  19381.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  19382.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  19383.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = b */
  19384.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  19385.    },
  19386.    {
  19387.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19388.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  19389.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  19390.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19391.    },
  19392.    UTIL_FORMAT_COLORSPACE_RGB,
  19393.    &util_format_r8g8b8x8_unorm_unpack_rgba_8unorm,
  19394.    &util_format_r8g8b8x8_unorm_pack_rgba_8unorm,
  19395.    NULL, /* fetch_rgba_8unorm */
  19396.    &util_format_r8g8b8x8_unorm_unpack_rgba_float,
  19397.    &util_format_r8g8b8x8_unorm_pack_rgba_float,
  19398.    &util_format_r8g8b8x8_unorm_fetch_rgba_float,
  19399.    NULL, /* unpack_z_32unorm */
  19400.    NULL, /* pack_z_32unorm */
  19401.    NULL, /* unpack_z_float */
  19402.    NULL, /* pack_z_float */
  19403.    NULL, /* unpack_s_8uint */
  19404.    NULL, /* pack_s_8uint */
  19405.    NULL, /* unpack_rgba_uint */
  19406.    NULL, /* pack_rgba_uint */
  19407.    NULL, /* unpack_rgba_sint */
  19408.    NULL, /* pack_rgba_sint */
  19409.    NULL, /* fetch_rgba_uint */
  19410.    NULL  /* fetch_rgba_sint */
  19411. };
  19412.  
  19413. const struct util_format_description
  19414. util_format_l8_unorm_description = {
  19415.    PIPE_FORMAT_L8_UNORM,
  19416.    "PIPE_FORMAT_L8_UNORM",
  19417.    "l8_unorm",
  19418.    {1, 1, 8},   /* block */
  19419.    UTIL_FORMAT_LAYOUT_PLAIN,
  19420.    1,   /* nr_channels */
  19421.    TRUE,        /* is_array */
  19422.    TRUE,        /* is_bitmask */
  19423.    FALSE,       /* is_mixed */
  19424.    {
  19425.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = rgb */
  19426.       {0, 0, 0, 0, 0},
  19427.       {0, 0, 0, 0, 0},
  19428.       {0, 0, 0, 0, 0}
  19429.    },
  19430.    {
  19431.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19432.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19433.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19434.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19435.    },
  19436.    UTIL_FORMAT_COLORSPACE_RGB,
  19437.    &util_format_l8_unorm_unpack_rgba_8unorm,
  19438.    &util_format_l8_unorm_pack_rgba_8unorm,
  19439.    NULL, /* fetch_rgba_8unorm */
  19440.    &util_format_l8_unorm_unpack_rgba_float,
  19441.    &util_format_l8_unorm_pack_rgba_float,
  19442.    &util_format_l8_unorm_fetch_rgba_float,
  19443.    NULL, /* unpack_z_32unorm */
  19444.    NULL, /* pack_z_32unorm */
  19445.    NULL, /* unpack_z_float */
  19446.    NULL, /* pack_z_float */
  19447.    NULL, /* unpack_s_8uint */
  19448.    NULL, /* pack_s_8uint */
  19449.    NULL, /* unpack_rgba_uint */
  19450.    NULL, /* pack_rgba_uint */
  19451.    NULL, /* unpack_rgba_sint */
  19452.    NULL, /* pack_rgba_sint */
  19453.    NULL, /* fetch_rgba_uint */
  19454.    NULL  /* fetch_rgba_sint */
  19455. };
  19456.  
  19457. const struct util_format_description
  19458. util_format_a8_unorm_description = {
  19459.    PIPE_FORMAT_A8_UNORM,
  19460.    "PIPE_FORMAT_A8_UNORM",
  19461.    "a8_unorm",
  19462.    {1, 1, 8},   /* block */
  19463.    UTIL_FORMAT_LAYOUT_PLAIN,
  19464.    1,   /* nr_channels */
  19465.    TRUE,        /* is_array */
  19466.    TRUE,        /* is_bitmask */
  19467.    FALSE,       /* is_mixed */
  19468.    {
  19469.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = a */
  19470.       {0, 0, 0, 0, 0},
  19471.       {0, 0, 0, 0, 0},
  19472.       {0, 0, 0, 0, 0}
  19473.    },
  19474.    {
  19475.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  19476.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  19477.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  19478.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19479.    },
  19480.    UTIL_FORMAT_COLORSPACE_RGB,
  19481.    &util_format_a8_unorm_unpack_rgba_8unorm,
  19482.    &util_format_a8_unorm_pack_rgba_8unorm,
  19483.    NULL, /* fetch_rgba_8unorm */
  19484.    &util_format_a8_unorm_unpack_rgba_float,
  19485.    &util_format_a8_unorm_pack_rgba_float,
  19486.    &util_format_a8_unorm_fetch_rgba_float,
  19487.    NULL, /* unpack_z_32unorm */
  19488.    NULL, /* pack_z_32unorm */
  19489.    NULL, /* unpack_z_float */
  19490.    NULL, /* pack_z_float */
  19491.    NULL, /* unpack_s_8uint */
  19492.    NULL, /* pack_s_8uint */
  19493.    NULL, /* unpack_rgba_uint */
  19494.    NULL, /* pack_rgba_uint */
  19495.    NULL, /* unpack_rgba_sint */
  19496.    NULL, /* pack_rgba_sint */
  19497.    NULL, /* fetch_rgba_uint */
  19498.    NULL  /* fetch_rgba_sint */
  19499. };
  19500.  
  19501. const struct util_format_description
  19502. util_format_i8_unorm_description = {
  19503.    PIPE_FORMAT_I8_UNORM,
  19504.    "PIPE_FORMAT_I8_UNORM",
  19505.    "i8_unorm",
  19506.    {1, 1, 8},   /* block */
  19507.    UTIL_FORMAT_LAYOUT_PLAIN,
  19508.    1,   /* nr_channels */
  19509.    TRUE,        /* is_array */
  19510.    TRUE,        /* is_bitmask */
  19511.    FALSE,       /* is_mixed */
  19512.    {
  19513.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = rgba */
  19514.       {0, 0, 0, 0, 0},
  19515.       {0, 0, 0, 0, 0},
  19516.       {0, 0, 0, 0, 0}
  19517.    },
  19518.    {
  19519.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19520.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19521.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19522.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19523.    },
  19524.    UTIL_FORMAT_COLORSPACE_RGB,
  19525.    &util_format_i8_unorm_unpack_rgba_8unorm,
  19526.    &util_format_i8_unorm_pack_rgba_8unorm,
  19527.    NULL, /* fetch_rgba_8unorm */
  19528.    &util_format_i8_unorm_unpack_rgba_float,
  19529.    &util_format_i8_unorm_pack_rgba_float,
  19530.    &util_format_i8_unorm_fetch_rgba_float,
  19531.    NULL, /* unpack_z_32unorm */
  19532.    NULL, /* pack_z_32unorm */
  19533.    NULL, /* unpack_z_float */
  19534.    NULL, /* pack_z_float */
  19535.    NULL, /* unpack_s_8uint */
  19536.    NULL, /* pack_s_8uint */
  19537.    NULL, /* unpack_rgba_uint */
  19538.    NULL, /* pack_rgba_uint */
  19539.    NULL, /* unpack_rgba_sint */
  19540.    NULL, /* pack_rgba_sint */
  19541.    NULL, /* fetch_rgba_uint */
  19542.    NULL  /* fetch_rgba_sint */
  19543. };
  19544.  
  19545. const struct util_format_description
  19546. util_format_l4a4_unorm_description = {
  19547.    PIPE_FORMAT_L4A4_UNORM,
  19548.    "PIPE_FORMAT_L4A4_UNORM",
  19549.    "l4a4_unorm",
  19550.    {1, 1, 8},   /* block */
  19551.    UTIL_FORMAT_LAYOUT_PLAIN,
  19552.    2,   /* nr_channels */
  19553.    FALSE,       /* is_array */
  19554.    TRUE,        /* is_bitmask */
  19555.    FALSE,       /* is_mixed */
  19556.    {
  19557.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0},   /* x = rgb */
  19558.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4},   /* y = a */
  19559.       {0, 0, 0, 0, 0},
  19560.       {0, 0, 0, 0, 0}
  19561.    },
  19562.    {
  19563.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19564.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19565.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19566.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  19567.    },
  19568.    UTIL_FORMAT_COLORSPACE_RGB,
  19569.    &util_format_l4a4_unorm_unpack_rgba_8unorm,
  19570.    &util_format_l4a4_unorm_pack_rgba_8unorm,
  19571.    NULL, /* fetch_rgba_8unorm */
  19572.    &util_format_l4a4_unorm_unpack_rgba_float,
  19573.    &util_format_l4a4_unorm_pack_rgba_float,
  19574.    &util_format_l4a4_unorm_fetch_rgba_float,
  19575.    NULL, /* unpack_z_32unorm */
  19576.    NULL, /* pack_z_32unorm */
  19577.    NULL, /* unpack_z_float */
  19578.    NULL, /* pack_z_float */
  19579.    NULL, /* unpack_s_8uint */
  19580.    NULL, /* pack_s_8uint */
  19581.    NULL, /* unpack_rgba_uint */
  19582.    NULL, /* pack_rgba_uint */
  19583.    NULL, /* unpack_rgba_sint */
  19584.    NULL, /* pack_rgba_sint */
  19585.    NULL, /* fetch_rgba_uint */
  19586.    NULL  /* fetch_rgba_sint */
  19587. };
  19588.  
  19589. const struct util_format_description
  19590. util_format_l8a8_unorm_description = {
  19591.    PIPE_FORMAT_L8A8_UNORM,
  19592.    "PIPE_FORMAT_L8A8_UNORM",
  19593.    "l8a8_unorm",
  19594.    {1, 1, 16},  /* block */
  19595.    UTIL_FORMAT_LAYOUT_PLAIN,
  19596.    2,   /* nr_channels */
  19597.    TRUE,        /* is_array */
  19598.    TRUE,        /* is_bitmask */
  19599.    FALSE,       /* is_mixed */
  19600.    {
  19601.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = rgb */
  19602.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = a */
  19603.       {0, 0, 0, 0, 0},
  19604.       {0, 0, 0, 0, 0}
  19605.    },
  19606.    {
  19607.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19608.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19609.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19610.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  19611.    },
  19612.    UTIL_FORMAT_COLORSPACE_RGB,
  19613.    &util_format_l8a8_unorm_unpack_rgba_8unorm,
  19614.    &util_format_l8a8_unorm_pack_rgba_8unorm,
  19615.    NULL, /* fetch_rgba_8unorm */
  19616.    &util_format_l8a8_unorm_unpack_rgba_float,
  19617.    &util_format_l8a8_unorm_pack_rgba_float,
  19618.    &util_format_l8a8_unorm_fetch_rgba_float,
  19619.    NULL, /* unpack_z_32unorm */
  19620.    NULL, /* pack_z_32unorm */
  19621.    NULL, /* unpack_z_float */
  19622.    NULL, /* pack_z_float */
  19623.    NULL, /* unpack_s_8uint */
  19624.    NULL, /* pack_s_8uint */
  19625.    NULL, /* unpack_rgba_uint */
  19626.    NULL, /* pack_rgba_uint */
  19627.    NULL, /* unpack_rgba_sint */
  19628.    NULL, /* pack_rgba_sint */
  19629.    NULL, /* fetch_rgba_uint */
  19630.    NULL  /* fetch_rgba_sint */
  19631. };
  19632.  
  19633. const struct util_format_description
  19634. util_format_l16_unorm_description = {
  19635.    PIPE_FORMAT_L16_UNORM,
  19636.    "PIPE_FORMAT_L16_UNORM",
  19637.    "l16_unorm",
  19638.    {1, 1, 16},  /* block */
  19639.    UTIL_FORMAT_LAYOUT_PLAIN,
  19640.    1,   /* nr_channels */
  19641.    TRUE,        /* is_array */
  19642.    TRUE,        /* is_bitmask */
  19643.    FALSE,       /* is_mixed */
  19644.    {
  19645.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = rgb */
  19646.       {0, 0, 0, 0, 0},
  19647.       {0, 0, 0, 0, 0},
  19648.       {0, 0, 0, 0, 0}
  19649.    },
  19650.    {
  19651.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19652.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19653.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19654.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19655.    },
  19656.    UTIL_FORMAT_COLORSPACE_RGB,
  19657.    &util_format_l16_unorm_unpack_rgba_8unorm,
  19658.    &util_format_l16_unorm_pack_rgba_8unorm,
  19659.    NULL, /* fetch_rgba_8unorm */
  19660.    &util_format_l16_unorm_unpack_rgba_float,
  19661.    &util_format_l16_unorm_pack_rgba_float,
  19662.    &util_format_l16_unorm_fetch_rgba_float,
  19663.    NULL, /* unpack_z_32unorm */
  19664.    NULL, /* pack_z_32unorm */
  19665.    NULL, /* unpack_z_float */
  19666.    NULL, /* pack_z_float */
  19667.    NULL, /* unpack_s_8uint */
  19668.    NULL, /* pack_s_8uint */
  19669.    NULL, /* unpack_rgba_uint */
  19670.    NULL, /* pack_rgba_uint */
  19671.    NULL, /* unpack_rgba_sint */
  19672.    NULL, /* pack_rgba_sint */
  19673.    NULL, /* fetch_rgba_uint */
  19674.    NULL  /* fetch_rgba_sint */
  19675. };
  19676.  
  19677. const struct util_format_description
  19678. util_format_a16_unorm_description = {
  19679.    PIPE_FORMAT_A16_UNORM,
  19680.    "PIPE_FORMAT_A16_UNORM",
  19681.    "a16_unorm",
  19682.    {1, 1, 16},  /* block */
  19683.    UTIL_FORMAT_LAYOUT_PLAIN,
  19684.    1,   /* nr_channels */
  19685.    TRUE,        /* is_array */
  19686.    TRUE,        /* is_bitmask */
  19687.    FALSE,       /* is_mixed */
  19688.    {
  19689.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = a */
  19690.       {0, 0, 0, 0, 0},
  19691.       {0, 0, 0, 0, 0},
  19692.       {0, 0, 0, 0, 0}
  19693.    },
  19694.    {
  19695.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  19696.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  19697.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  19698.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19699.    },
  19700.    UTIL_FORMAT_COLORSPACE_RGB,
  19701.    &util_format_a16_unorm_unpack_rgba_8unorm,
  19702.    &util_format_a16_unorm_pack_rgba_8unorm,
  19703.    NULL, /* fetch_rgba_8unorm */
  19704.    &util_format_a16_unorm_unpack_rgba_float,
  19705.    &util_format_a16_unorm_pack_rgba_float,
  19706.    &util_format_a16_unorm_fetch_rgba_float,
  19707.    NULL, /* unpack_z_32unorm */
  19708.    NULL, /* pack_z_32unorm */
  19709.    NULL, /* unpack_z_float */
  19710.    NULL, /* pack_z_float */
  19711.    NULL, /* unpack_s_8uint */
  19712.    NULL, /* pack_s_8uint */
  19713.    NULL, /* unpack_rgba_uint */
  19714.    NULL, /* pack_rgba_uint */
  19715.    NULL, /* unpack_rgba_sint */
  19716.    NULL, /* pack_rgba_sint */
  19717.    NULL, /* fetch_rgba_uint */
  19718.    NULL  /* fetch_rgba_sint */
  19719. };
  19720.  
  19721. const struct util_format_description
  19722. util_format_i16_unorm_description = {
  19723.    PIPE_FORMAT_I16_UNORM,
  19724.    "PIPE_FORMAT_I16_UNORM",
  19725.    "i16_unorm",
  19726.    {1, 1, 16},  /* block */
  19727.    UTIL_FORMAT_LAYOUT_PLAIN,
  19728.    1,   /* nr_channels */
  19729.    TRUE,        /* is_array */
  19730.    TRUE,        /* is_bitmask */
  19731.    FALSE,       /* is_mixed */
  19732.    {
  19733.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = rgba */
  19734.       {0, 0, 0, 0, 0},
  19735.       {0, 0, 0, 0, 0},
  19736.       {0, 0, 0, 0, 0}
  19737.    },
  19738.    {
  19739.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19740.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19741.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19742.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19743.    },
  19744.    UTIL_FORMAT_COLORSPACE_RGB,
  19745.    &util_format_i16_unorm_unpack_rgba_8unorm,
  19746.    &util_format_i16_unorm_pack_rgba_8unorm,
  19747.    NULL, /* fetch_rgba_8unorm */
  19748.    &util_format_i16_unorm_unpack_rgba_float,
  19749.    &util_format_i16_unorm_pack_rgba_float,
  19750.    &util_format_i16_unorm_fetch_rgba_float,
  19751.    NULL, /* unpack_z_32unorm */
  19752.    NULL, /* pack_z_32unorm */
  19753.    NULL, /* unpack_z_float */
  19754.    NULL, /* pack_z_float */
  19755.    NULL, /* unpack_s_8uint */
  19756.    NULL, /* pack_s_8uint */
  19757.    NULL, /* unpack_rgba_uint */
  19758.    NULL, /* pack_rgba_uint */
  19759.    NULL, /* unpack_rgba_sint */
  19760.    NULL, /* pack_rgba_sint */
  19761.    NULL, /* fetch_rgba_uint */
  19762.    NULL  /* fetch_rgba_sint */
  19763. };
  19764.  
  19765. const struct util_format_description
  19766. util_format_l16a16_unorm_description = {
  19767.    PIPE_FORMAT_L16A16_UNORM,
  19768.    "PIPE_FORMAT_L16A16_UNORM",
  19769.    "l16a16_unorm",
  19770.    {1, 1, 32},  /* block */
  19771.    UTIL_FORMAT_LAYOUT_PLAIN,
  19772.    2,   /* nr_channels */
  19773.    TRUE,        /* is_array */
  19774.    TRUE,        /* is_bitmask */
  19775.    FALSE,       /* is_mixed */
  19776.    {
  19777.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = rgb */
  19778.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */
  19779.       {0, 0, 0, 0, 0},
  19780.       {0, 0, 0, 0, 0}
  19781.    },
  19782.    {
  19783.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19784.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19785.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19786.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  19787.    },
  19788.    UTIL_FORMAT_COLORSPACE_RGB,
  19789.    &util_format_l16a16_unorm_unpack_rgba_8unorm,
  19790.    &util_format_l16a16_unorm_pack_rgba_8unorm,
  19791.    NULL, /* fetch_rgba_8unorm */
  19792.    &util_format_l16a16_unorm_unpack_rgba_float,
  19793.    &util_format_l16a16_unorm_pack_rgba_float,
  19794.    &util_format_l16a16_unorm_fetch_rgba_float,
  19795.    NULL, /* unpack_z_32unorm */
  19796.    NULL, /* pack_z_32unorm */
  19797.    NULL, /* unpack_z_float */
  19798.    NULL, /* pack_z_float */
  19799.    NULL, /* unpack_s_8uint */
  19800.    NULL, /* pack_s_8uint */
  19801.    NULL, /* unpack_rgba_uint */
  19802.    NULL, /* pack_rgba_uint */
  19803.    NULL, /* unpack_rgba_sint */
  19804.    NULL, /* pack_rgba_sint */
  19805.    NULL, /* fetch_rgba_uint */
  19806.    NULL  /* fetch_rgba_sint */
  19807. };
  19808.  
  19809. const struct util_format_description
  19810. util_format_a8_snorm_description = {
  19811.    PIPE_FORMAT_A8_SNORM,
  19812.    "PIPE_FORMAT_A8_SNORM",
  19813.    "a8_snorm",
  19814.    {1, 1, 8},   /* block */
  19815.    UTIL_FORMAT_LAYOUT_PLAIN,
  19816.    1,   /* nr_channels */
  19817.    TRUE,        /* is_array */
  19818.    TRUE,        /* is_bitmask */
  19819.    FALSE,       /* is_mixed */
  19820.    {
  19821.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = a */
  19822.       {0, 0, 0, 0, 0},
  19823.       {0, 0, 0, 0, 0},
  19824.       {0, 0, 0, 0, 0}
  19825.    },
  19826.    {
  19827.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  19828.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  19829.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  19830.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19831.    },
  19832.    UTIL_FORMAT_COLORSPACE_RGB,
  19833.    &util_format_a8_snorm_unpack_rgba_8unorm,
  19834.    &util_format_a8_snorm_pack_rgba_8unorm,
  19835.    NULL, /* fetch_rgba_8unorm */
  19836.    &util_format_a8_snorm_unpack_rgba_float,
  19837.    &util_format_a8_snorm_pack_rgba_float,
  19838.    &util_format_a8_snorm_fetch_rgba_float,
  19839.    NULL, /* unpack_z_32unorm */
  19840.    NULL, /* pack_z_32unorm */
  19841.    NULL, /* unpack_z_float */
  19842.    NULL, /* pack_z_float */
  19843.    NULL, /* unpack_s_8uint */
  19844.    NULL, /* pack_s_8uint */
  19845.    NULL, /* unpack_rgba_uint */
  19846.    NULL, /* pack_rgba_uint */
  19847.    NULL, /* unpack_rgba_sint */
  19848.    NULL, /* pack_rgba_sint */
  19849.    NULL, /* fetch_rgba_uint */
  19850.    NULL  /* fetch_rgba_sint */
  19851. };
  19852.  
  19853. const struct util_format_description
  19854. util_format_l8_snorm_description = {
  19855.    PIPE_FORMAT_L8_SNORM,
  19856.    "PIPE_FORMAT_L8_SNORM",
  19857.    "l8_snorm",
  19858.    {1, 1, 8},   /* block */
  19859.    UTIL_FORMAT_LAYOUT_PLAIN,
  19860.    1,   /* nr_channels */
  19861.    TRUE,        /* is_array */
  19862.    TRUE,        /* is_bitmask */
  19863.    FALSE,       /* is_mixed */
  19864.    {
  19865.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = rgb */
  19866.       {0, 0, 0, 0, 0},
  19867.       {0, 0, 0, 0, 0},
  19868.       {0, 0, 0, 0, 0}
  19869.    },
  19870.    {
  19871.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19872.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19873.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19874.       UTIL_FORMAT_SWIZZLE_1     /* a */
  19875.    },
  19876.    UTIL_FORMAT_COLORSPACE_RGB,
  19877.    &util_format_l8_snorm_unpack_rgba_8unorm,
  19878.    &util_format_l8_snorm_pack_rgba_8unorm,
  19879.    NULL, /* fetch_rgba_8unorm */
  19880.    &util_format_l8_snorm_unpack_rgba_float,
  19881.    &util_format_l8_snorm_pack_rgba_float,
  19882.    &util_format_l8_snorm_fetch_rgba_float,
  19883.    NULL, /* unpack_z_32unorm */
  19884.    NULL, /* pack_z_32unorm */
  19885.    NULL, /* unpack_z_float */
  19886.    NULL, /* pack_z_float */
  19887.    NULL, /* unpack_s_8uint */
  19888.    NULL, /* pack_s_8uint */
  19889.    NULL, /* unpack_rgba_uint */
  19890.    NULL, /* pack_rgba_uint */
  19891.    NULL, /* unpack_rgba_sint */
  19892.    NULL, /* pack_rgba_sint */
  19893.    NULL, /* fetch_rgba_uint */
  19894.    NULL  /* fetch_rgba_sint */
  19895. };
  19896.  
  19897. const struct util_format_description
  19898. util_format_l8a8_snorm_description = {
  19899.    PIPE_FORMAT_L8A8_SNORM,
  19900.    "PIPE_FORMAT_L8A8_SNORM",
  19901.    "l8a8_snorm",
  19902.    {1, 1, 16},  /* block */
  19903.    UTIL_FORMAT_LAYOUT_PLAIN,
  19904.    2,   /* nr_channels */
  19905.    TRUE,        /* is_array */
  19906.    TRUE,        /* is_bitmask */
  19907.    FALSE,       /* is_mixed */
  19908.    {
  19909.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = rgb */
  19910.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = a */
  19911.       {0, 0, 0, 0, 0},
  19912.       {0, 0, 0, 0, 0}
  19913.    },
  19914.    {
  19915.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19916.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19917.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19918.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  19919.    },
  19920.    UTIL_FORMAT_COLORSPACE_RGB,
  19921.    &util_format_l8a8_snorm_unpack_rgba_8unorm,
  19922.    &util_format_l8a8_snorm_pack_rgba_8unorm,
  19923.    NULL, /* fetch_rgba_8unorm */
  19924.    &util_format_l8a8_snorm_unpack_rgba_float,
  19925.    &util_format_l8a8_snorm_pack_rgba_float,
  19926.    &util_format_l8a8_snorm_fetch_rgba_float,
  19927.    NULL, /* unpack_z_32unorm */
  19928.    NULL, /* pack_z_32unorm */
  19929.    NULL, /* unpack_z_float */
  19930.    NULL, /* pack_z_float */
  19931.    NULL, /* unpack_s_8uint */
  19932.    NULL, /* pack_s_8uint */
  19933.    NULL, /* unpack_rgba_uint */
  19934.    NULL, /* pack_rgba_uint */
  19935.    NULL, /* unpack_rgba_sint */
  19936.    NULL, /* pack_rgba_sint */
  19937.    NULL, /* fetch_rgba_uint */
  19938.    NULL  /* fetch_rgba_sint */
  19939. };
  19940.  
  19941. const struct util_format_description
  19942. util_format_i8_snorm_description = {
  19943.    PIPE_FORMAT_I8_SNORM,
  19944.    "PIPE_FORMAT_I8_SNORM",
  19945.    "i8_snorm",
  19946.    {1, 1, 8},   /* block */
  19947.    UTIL_FORMAT_LAYOUT_PLAIN,
  19948.    1,   /* nr_channels */
  19949.    TRUE,        /* is_array */
  19950.    TRUE,        /* is_bitmask */
  19951.    FALSE,       /* is_mixed */
  19952.    {
  19953.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = rgba */
  19954.       {0, 0, 0, 0, 0},
  19955.       {0, 0, 0, 0, 0},
  19956.       {0, 0, 0, 0, 0}
  19957.    },
  19958.    {
  19959.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  19960.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  19961.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  19962.       UTIL_FORMAT_SWIZZLE_X     /* a */
  19963.    },
  19964.    UTIL_FORMAT_COLORSPACE_RGB,
  19965.    &util_format_i8_snorm_unpack_rgba_8unorm,
  19966.    &util_format_i8_snorm_pack_rgba_8unorm,
  19967.    NULL, /* fetch_rgba_8unorm */
  19968.    &util_format_i8_snorm_unpack_rgba_float,
  19969.    &util_format_i8_snorm_pack_rgba_float,
  19970.    &util_format_i8_snorm_fetch_rgba_float,
  19971.    NULL, /* unpack_z_32unorm */
  19972.    NULL, /* pack_z_32unorm */
  19973.    NULL, /* unpack_z_float */
  19974.    NULL, /* pack_z_float */
  19975.    NULL, /* unpack_s_8uint */
  19976.    NULL, /* pack_s_8uint */
  19977.    NULL, /* unpack_rgba_uint */
  19978.    NULL, /* pack_rgba_uint */
  19979.    NULL, /* unpack_rgba_sint */
  19980.    NULL, /* pack_rgba_sint */
  19981.    NULL, /* fetch_rgba_uint */
  19982.    NULL  /* fetch_rgba_sint */
  19983. };
  19984.  
  19985. const struct util_format_description
  19986. util_format_a16_snorm_description = {
  19987.    PIPE_FORMAT_A16_SNORM,
  19988.    "PIPE_FORMAT_A16_SNORM",
  19989.    "a16_snorm",
  19990.    {1, 1, 16},  /* block */
  19991.    UTIL_FORMAT_LAYOUT_PLAIN,
  19992.    1,   /* nr_channels */
  19993.    TRUE,        /* is_array */
  19994.    TRUE,        /* is_bitmask */
  19995.    FALSE,       /* is_mixed */
  19996.    {
  19997.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = a */
  19998.       {0, 0, 0, 0, 0},
  19999.       {0, 0, 0, 0, 0},
  20000.       {0, 0, 0, 0, 0}
  20001.    },
  20002.    {
  20003.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  20004.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  20005.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  20006.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20007.    },
  20008.    UTIL_FORMAT_COLORSPACE_RGB,
  20009.    &util_format_a16_snorm_unpack_rgba_8unorm,
  20010.    &util_format_a16_snorm_pack_rgba_8unorm,
  20011.    NULL, /* fetch_rgba_8unorm */
  20012.    &util_format_a16_snorm_unpack_rgba_float,
  20013.    &util_format_a16_snorm_pack_rgba_float,
  20014.    &util_format_a16_snorm_fetch_rgba_float,
  20015.    NULL, /* unpack_z_32unorm */
  20016.    NULL, /* pack_z_32unorm */
  20017.    NULL, /* unpack_z_float */
  20018.    NULL, /* pack_z_float */
  20019.    NULL, /* unpack_s_8uint */
  20020.    NULL, /* pack_s_8uint */
  20021.    NULL, /* unpack_rgba_uint */
  20022.    NULL, /* pack_rgba_uint */
  20023.    NULL, /* unpack_rgba_sint */
  20024.    NULL, /* pack_rgba_sint */
  20025.    NULL, /* fetch_rgba_uint */
  20026.    NULL  /* fetch_rgba_sint */
  20027. };
  20028.  
  20029. const struct util_format_description
  20030. util_format_l16_snorm_description = {
  20031.    PIPE_FORMAT_L16_SNORM,
  20032.    "PIPE_FORMAT_L16_SNORM",
  20033.    "l16_snorm",
  20034.    {1, 1, 16},  /* block */
  20035.    UTIL_FORMAT_LAYOUT_PLAIN,
  20036.    1,   /* nr_channels */
  20037.    TRUE,        /* is_array */
  20038.    TRUE,        /* is_bitmask */
  20039.    FALSE,       /* is_mixed */
  20040.    {
  20041.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = rgb */
  20042.       {0, 0, 0, 0, 0},
  20043.       {0, 0, 0, 0, 0},
  20044.       {0, 0, 0, 0, 0}
  20045.    },
  20046.    {
  20047.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20048.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20049.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20050.       UTIL_FORMAT_SWIZZLE_1     /* a */
  20051.    },
  20052.    UTIL_FORMAT_COLORSPACE_RGB,
  20053.    &util_format_l16_snorm_unpack_rgba_8unorm,
  20054.    &util_format_l16_snorm_pack_rgba_8unorm,
  20055.    NULL, /* fetch_rgba_8unorm */
  20056.    &util_format_l16_snorm_unpack_rgba_float,
  20057.    &util_format_l16_snorm_pack_rgba_float,
  20058.    &util_format_l16_snorm_fetch_rgba_float,
  20059.    NULL, /* unpack_z_32unorm */
  20060.    NULL, /* pack_z_32unorm */
  20061.    NULL, /* unpack_z_float */
  20062.    NULL, /* pack_z_float */
  20063.    NULL, /* unpack_s_8uint */
  20064.    NULL, /* pack_s_8uint */
  20065.    NULL, /* unpack_rgba_uint */
  20066.    NULL, /* pack_rgba_uint */
  20067.    NULL, /* unpack_rgba_sint */
  20068.    NULL, /* pack_rgba_sint */
  20069.    NULL, /* fetch_rgba_uint */
  20070.    NULL  /* fetch_rgba_sint */
  20071. };
  20072.  
  20073. const struct util_format_description
  20074. util_format_l16a16_snorm_description = {
  20075.    PIPE_FORMAT_L16A16_SNORM,
  20076.    "PIPE_FORMAT_L16A16_SNORM",
  20077.    "l16a16_snorm",
  20078.    {1, 1, 32},  /* block */
  20079.    UTIL_FORMAT_LAYOUT_PLAIN,
  20080.    2,   /* nr_channels */
  20081.    TRUE,        /* is_array */
  20082.    TRUE,        /* is_bitmask */
  20083.    FALSE,       /* is_mixed */
  20084.    {
  20085.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = rgb */
  20086.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = a */
  20087.       {0, 0, 0, 0, 0},
  20088.       {0, 0, 0, 0, 0}
  20089.    },
  20090.    {
  20091.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20092.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20093.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20094.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  20095.    },
  20096.    UTIL_FORMAT_COLORSPACE_RGB,
  20097.    &util_format_l16a16_snorm_unpack_rgba_8unorm,
  20098.    &util_format_l16a16_snorm_pack_rgba_8unorm,
  20099.    NULL, /* fetch_rgba_8unorm */
  20100.    &util_format_l16a16_snorm_unpack_rgba_float,
  20101.    &util_format_l16a16_snorm_pack_rgba_float,
  20102.    &util_format_l16a16_snorm_fetch_rgba_float,
  20103.    NULL, /* unpack_z_32unorm */
  20104.    NULL, /* pack_z_32unorm */
  20105.    NULL, /* unpack_z_float */
  20106.    NULL, /* pack_z_float */
  20107.    NULL, /* unpack_s_8uint */
  20108.    NULL, /* pack_s_8uint */
  20109.    NULL, /* unpack_rgba_uint */
  20110.    NULL, /* pack_rgba_uint */
  20111.    NULL, /* unpack_rgba_sint */
  20112.    NULL, /* pack_rgba_sint */
  20113.    NULL, /* fetch_rgba_uint */
  20114.    NULL  /* fetch_rgba_sint */
  20115. };
  20116.  
  20117. const struct util_format_description
  20118. util_format_i16_snorm_description = {
  20119.    PIPE_FORMAT_I16_SNORM,
  20120.    "PIPE_FORMAT_I16_SNORM",
  20121.    "i16_snorm",
  20122.    {1, 1, 16},  /* block */
  20123.    UTIL_FORMAT_LAYOUT_PLAIN,
  20124.    1,   /* nr_channels */
  20125.    TRUE,        /* is_array */
  20126.    TRUE,        /* is_bitmask */
  20127.    FALSE,       /* is_mixed */
  20128.    {
  20129.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = rgba */
  20130.       {0, 0, 0, 0, 0},
  20131.       {0, 0, 0, 0, 0},
  20132.       {0, 0, 0, 0, 0}
  20133.    },
  20134.    {
  20135.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20136.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20137.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20138.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20139.    },
  20140.    UTIL_FORMAT_COLORSPACE_RGB,
  20141.    &util_format_i16_snorm_unpack_rgba_8unorm,
  20142.    &util_format_i16_snorm_pack_rgba_8unorm,
  20143.    NULL, /* fetch_rgba_8unorm */
  20144.    &util_format_i16_snorm_unpack_rgba_float,
  20145.    &util_format_i16_snorm_pack_rgba_float,
  20146.    &util_format_i16_snorm_fetch_rgba_float,
  20147.    NULL, /* unpack_z_32unorm */
  20148.    NULL, /* pack_z_32unorm */
  20149.    NULL, /* unpack_z_float */
  20150.    NULL, /* pack_z_float */
  20151.    NULL, /* unpack_s_8uint */
  20152.    NULL, /* pack_s_8uint */
  20153.    NULL, /* unpack_rgba_uint */
  20154.    NULL, /* pack_rgba_uint */
  20155.    NULL, /* unpack_rgba_sint */
  20156.    NULL, /* pack_rgba_sint */
  20157.    NULL, /* fetch_rgba_uint */
  20158.    NULL  /* fetch_rgba_sint */
  20159. };
  20160.  
  20161. const struct util_format_description
  20162. util_format_a16_float_description = {
  20163.    PIPE_FORMAT_A16_FLOAT,
  20164.    "PIPE_FORMAT_A16_FLOAT",
  20165.    "a16_float",
  20166.    {1, 1, 16},  /* block */
  20167.    UTIL_FORMAT_LAYOUT_PLAIN,
  20168.    1,   /* nr_channels */
  20169.    TRUE,        /* is_array */
  20170.    FALSE,       /* is_bitmask */
  20171.    FALSE,       /* is_mixed */
  20172.    {
  20173.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = a */
  20174.       {0, 0, 0, 0, 0},
  20175.       {0, 0, 0, 0, 0},
  20176.       {0, 0, 0, 0, 0}
  20177.    },
  20178.    {
  20179.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  20180.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  20181.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  20182.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20183.    },
  20184.    UTIL_FORMAT_COLORSPACE_RGB,
  20185.    &util_format_a16_float_unpack_rgba_8unorm,
  20186.    &util_format_a16_float_pack_rgba_8unorm,
  20187.    NULL, /* fetch_rgba_8unorm */
  20188.    &util_format_a16_float_unpack_rgba_float,
  20189.    &util_format_a16_float_pack_rgba_float,
  20190.    &util_format_a16_float_fetch_rgba_float,
  20191.    NULL, /* unpack_z_32unorm */
  20192.    NULL, /* pack_z_32unorm */
  20193.    NULL, /* unpack_z_float */
  20194.    NULL, /* pack_z_float */
  20195.    NULL, /* unpack_s_8uint */
  20196.    NULL, /* pack_s_8uint */
  20197.    NULL, /* unpack_rgba_uint */
  20198.    NULL, /* pack_rgba_uint */
  20199.    NULL, /* unpack_rgba_sint */
  20200.    NULL, /* pack_rgba_sint */
  20201.    NULL, /* fetch_rgba_uint */
  20202.    NULL  /* fetch_rgba_sint */
  20203. };
  20204.  
  20205. const struct util_format_description
  20206. util_format_l16_float_description = {
  20207.    PIPE_FORMAT_L16_FLOAT,
  20208.    "PIPE_FORMAT_L16_FLOAT",
  20209.    "l16_float",
  20210.    {1, 1, 16},  /* block */
  20211.    UTIL_FORMAT_LAYOUT_PLAIN,
  20212.    1,   /* nr_channels */
  20213.    TRUE,        /* is_array */
  20214.    FALSE,       /* is_bitmask */
  20215.    FALSE,       /* is_mixed */
  20216.    {
  20217.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = rgb */
  20218.       {0, 0, 0, 0, 0},
  20219.       {0, 0, 0, 0, 0},
  20220.       {0, 0, 0, 0, 0}
  20221.    },
  20222.    {
  20223.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20224.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20225.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20226.       UTIL_FORMAT_SWIZZLE_1     /* a */
  20227.    },
  20228.    UTIL_FORMAT_COLORSPACE_RGB,
  20229.    &util_format_l16_float_unpack_rgba_8unorm,
  20230.    &util_format_l16_float_pack_rgba_8unorm,
  20231.    NULL, /* fetch_rgba_8unorm */
  20232.    &util_format_l16_float_unpack_rgba_float,
  20233.    &util_format_l16_float_pack_rgba_float,
  20234.    &util_format_l16_float_fetch_rgba_float,
  20235.    NULL, /* unpack_z_32unorm */
  20236.    NULL, /* pack_z_32unorm */
  20237.    NULL, /* unpack_z_float */
  20238.    NULL, /* pack_z_float */
  20239.    NULL, /* unpack_s_8uint */
  20240.    NULL, /* pack_s_8uint */
  20241.    NULL, /* unpack_rgba_uint */
  20242.    NULL, /* pack_rgba_uint */
  20243.    NULL, /* unpack_rgba_sint */
  20244.    NULL, /* pack_rgba_sint */
  20245.    NULL, /* fetch_rgba_uint */
  20246.    NULL  /* fetch_rgba_sint */
  20247. };
  20248.  
  20249. const struct util_format_description
  20250. util_format_l16a16_float_description = {
  20251.    PIPE_FORMAT_L16A16_FLOAT,
  20252.    "PIPE_FORMAT_L16A16_FLOAT",
  20253.    "l16a16_float",
  20254.    {1, 1, 32},  /* block */
  20255.    UTIL_FORMAT_LAYOUT_PLAIN,
  20256.    2,   /* nr_channels */
  20257.    TRUE,        /* is_array */
  20258.    FALSE,       /* is_bitmask */
  20259.    FALSE,       /* is_mixed */
  20260.    {
  20261.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = rgb */
  20262.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = a */
  20263.       {0, 0, 0, 0, 0},
  20264.       {0, 0, 0, 0, 0}
  20265.    },
  20266.    {
  20267.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20268.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20269.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20270.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  20271.    },
  20272.    UTIL_FORMAT_COLORSPACE_RGB,
  20273.    &util_format_l16a16_float_unpack_rgba_8unorm,
  20274.    &util_format_l16a16_float_pack_rgba_8unorm,
  20275.    NULL, /* fetch_rgba_8unorm */
  20276.    &util_format_l16a16_float_unpack_rgba_float,
  20277.    &util_format_l16a16_float_pack_rgba_float,
  20278.    &util_format_l16a16_float_fetch_rgba_float,
  20279.    NULL, /* unpack_z_32unorm */
  20280.    NULL, /* pack_z_32unorm */
  20281.    NULL, /* unpack_z_float */
  20282.    NULL, /* pack_z_float */
  20283.    NULL, /* unpack_s_8uint */
  20284.    NULL, /* pack_s_8uint */
  20285.    NULL, /* unpack_rgba_uint */
  20286.    NULL, /* pack_rgba_uint */
  20287.    NULL, /* unpack_rgba_sint */
  20288.    NULL, /* pack_rgba_sint */
  20289.    NULL, /* fetch_rgba_uint */
  20290.    NULL  /* fetch_rgba_sint */
  20291. };
  20292.  
  20293. const struct util_format_description
  20294. util_format_i16_float_description = {
  20295.    PIPE_FORMAT_I16_FLOAT,
  20296.    "PIPE_FORMAT_I16_FLOAT",
  20297.    "i16_float",
  20298.    {1, 1, 16},  /* block */
  20299.    UTIL_FORMAT_LAYOUT_PLAIN,
  20300.    1,   /* nr_channels */
  20301.    TRUE,        /* is_array */
  20302.    FALSE,       /* is_bitmask */
  20303.    FALSE,       /* is_mixed */
  20304.    {
  20305.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = rgba */
  20306.       {0, 0, 0, 0, 0},
  20307.       {0, 0, 0, 0, 0},
  20308.       {0, 0, 0, 0, 0}
  20309.    },
  20310.    {
  20311.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20312.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20313.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20314.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20315.    },
  20316.    UTIL_FORMAT_COLORSPACE_RGB,
  20317.    &util_format_i16_float_unpack_rgba_8unorm,
  20318.    &util_format_i16_float_pack_rgba_8unorm,
  20319.    NULL, /* fetch_rgba_8unorm */
  20320.    &util_format_i16_float_unpack_rgba_float,
  20321.    &util_format_i16_float_pack_rgba_float,
  20322.    &util_format_i16_float_fetch_rgba_float,
  20323.    NULL, /* unpack_z_32unorm */
  20324.    NULL, /* pack_z_32unorm */
  20325.    NULL, /* unpack_z_float */
  20326.    NULL, /* pack_z_float */
  20327.    NULL, /* unpack_s_8uint */
  20328.    NULL, /* pack_s_8uint */
  20329.    NULL, /* unpack_rgba_uint */
  20330.    NULL, /* pack_rgba_uint */
  20331.    NULL, /* unpack_rgba_sint */
  20332.    NULL, /* pack_rgba_sint */
  20333.    NULL, /* fetch_rgba_uint */
  20334.    NULL  /* fetch_rgba_sint */
  20335. };
  20336.  
  20337. const struct util_format_description
  20338. util_format_a32_float_description = {
  20339.    PIPE_FORMAT_A32_FLOAT,
  20340.    "PIPE_FORMAT_A32_FLOAT",
  20341.    "a32_float",
  20342.    {1, 1, 32},  /* block */
  20343.    UTIL_FORMAT_LAYOUT_PLAIN,
  20344.    1,   /* nr_channels */
  20345.    TRUE,        /* is_array */
  20346.    FALSE,       /* is_bitmask */
  20347.    FALSE,       /* is_mixed */
  20348.    {
  20349.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = a */
  20350.       {0, 0, 0, 0, 0},
  20351.       {0, 0, 0, 0, 0},
  20352.       {0, 0, 0, 0, 0}
  20353.    },
  20354.    {
  20355.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  20356.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  20357.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  20358.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20359.    },
  20360.    UTIL_FORMAT_COLORSPACE_RGB,
  20361.    &util_format_a32_float_unpack_rgba_8unorm,
  20362.    &util_format_a32_float_pack_rgba_8unorm,
  20363.    NULL, /* fetch_rgba_8unorm */
  20364.    &util_format_a32_float_unpack_rgba_float,
  20365.    &util_format_a32_float_pack_rgba_float,
  20366.    &util_format_a32_float_fetch_rgba_float,
  20367.    NULL, /* unpack_z_32unorm */
  20368.    NULL, /* pack_z_32unorm */
  20369.    NULL, /* unpack_z_float */
  20370.    NULL, /* pack_z_float */
  20371.    NULL, /* unpack_s_8uint */
  20372.    NULL, /* pack_s_8uint */
  20373.    NULL, /* unpack_rgba_uint */
  20374.    NULL, /* pack_rgba_uint */
  20375.    NULL, /* unpack_rgba_sint */
  20376.    NULL, /* pack_rgba_sint */
  20377.    NULL, /* fetch_rgba_uint */
  20378.    NULL  /* fetch_rgba_sint */
  20379. };
  20380.  
  20381. const struct util_format_description
  20382. util_format_l32_float_description = {
  20383.    PIPE_FORMAT_L32_FLOAT,
  20384.    "PIPE_FORMAT_L32_FLOAT",
  20385.    "l32_float",
  20386.    {1, 1, 32},  /* block */
  20387.    UTIL_FORMAT_LAYOUT_PLAIN,
  20388.    1,   /* nr_channels */
  20389.    TRUE,        /* is_array */
  20390.    FALSE,       /* is_bitmask */
  20391.    FALSE,       /* is_mixed */
  20392.    {
  20393.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = rgb */
  20394.       {0, 0, 0, 0, 0},
  20395.       {0, 0, 0, 0, 0},
  20396.       {0, 0, 0, 0, 0}
  20397.    },
  20398.    {
  20399.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20400.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20401.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20402.       UTIL_FORMAT_SWIZZLE_1     /* a */
  20403.    },
  20404.    UTIL_FORMAT_COLORSPACE_RGB,
  20405.    &util_format_l32_float_unpack_rgba_8unorm,
  20406.    &util_format_l32_float_pack_rgba_8unorm,
  20407.    NULL, /* fetch_rgba_8unorm */
  20408.    &util_format_l32_float_unpack_rgba_float,
  20409.    &util_format_l32_float_pack_rgba_float,
  20410.    &util_format_l32_float_fetch_rgba_float,
  20411.    NULL, /* unpack_z_32unorm */
  20412.    NULL, /* pack_z_32unorm */
  20413.    NULL, /* unpack_z_float */
  20414.    NULL, /* pack_z_float */
  20415.    NULL, /* unpack_s_8uint */
  20416.    NULL, /* pack_s_8uint */
  20417.    NULL, /* unpack_rgba_uint */
  20418.    NULL, /* pack_rgba_uint */
  20419.    NULL, /* unpack_rgba_sint */
  20420.    NULL, /* pack_rgba_sint */
  20421.    NULL, /* fetch_rgba_uint */
  20422.    NULL  /* fetch_rgba_sint */
  20423. };
  20424.  
  20425. const struct util_format_description
  20426. util_format_l32a32_float_description = {
  20427.    PIPE_FORMAT_L32A32_FLOAT,
  20428.    "PIPE_FORMAT_L32A32_FLOAT",
  20429.    "l32a32_float",
  20430.    {1, 1, 64},  /* block */
  20431.    UTIL_FORMAT_LAYOUT_PLAIN,
  20432.    2,   /* nr_channels */
  20433.    TRUE,        /* is_array */
  20434.    FALSE,       /* is_bitmask */
  20435.    FALSE,       /* is_mixed */
  20436.    {
  20437.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = rgb */
  20438.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = a */
  20439.       {0, 0, 0, 0, 0},
  20440.       {0, 0, 0, 0, 0}
  20441.    },
  20442.    {
  20443.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20444.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20445.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20446.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  20447.    },
  20448.    UTIL_FORMAT_COLORSPACE_RGB,
  20449.    &util_format_l32a32_float_unpack_rgba_8unorm,
  20450.    &util_format_l32a32_float_pack_rgba_8unorm,
  20451.    NULL, /* fetch_rgba_8unorm */
  20452.    &util_format_l32a32_float_unpack_rgba_float,
  20453.    &util_format_l32a32_float_pack_rgba_float,
  20454.    &util_format_l32a32_float_fetch_rgba_float,
  20455.    NULL, /* unpack_z_32unorm */
  20456.    NULL, /* pack_z_32unorm */
  20457.    NULL, /* unpack_z_float */
  20458.    NULL, /* pack_z_float */
  20459.    NULL, /* unpack_s_8uint */
  20460.    NULL, /* pack_s_8uint */
  20461.    NULL, /* unpack_rgba_uint */
  20462.    NULL, /* pack_rgba_uint */
  20463.    NULL, /* unpack_rgba_sint */
  20464.    NULL, /* pack_rgba_sint */
  20465.    NULL, /* fetch_rgba_uint */
  20466.    NULL  /* fetch_rgba_sint */
  20467. };
  20468.  
  20469. const struct util_format_description
  20470. util_format_i32_float_description = {
  20471.    PIPE_FORMAT_I32_FLOAT,
  20472.    "PIPE_FORMAT_I32_FLOAT",
  20473.    "i32_float",
  20474.    {1, 1, 32},  /* block */
  20475.    UTIL_FORMAT_LAYOUT_PLAIN,
  20476.    1,   /* nr_channels */
  20477.    TRUE,        /* is_array */
  20478.    FALSE,       /* is_bitmask */
  20479.    FALSE,       /* is_mixed */
  20480.    {
  20481.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = rgba */
  20482.       {0, 0, 0, 0, 0},
  20483.       {0, 0, 0, 0, 0},
  20484.       {0, 0, 0, 0, 0}
  20485.    },
  20486.    {
  20487.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20488.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  20489.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  20490.       UTIL_FORMAT_SWIZZLE_X     /* a */
  20491.    },
  20492.    UTIL_FORMAT_COLORSPACE_RGB,
  20493.    &util_format_i32_float_unpack_rgba_8unorm,
  20494.    &util_format_i32_float_pack_rgba_8unorm,
  20495.    NULL, /* fetch_rgba_8unorm */
  20496.    &util_format_i32_float_unpack_rgba_float,
  20497.    &util_format_i32_float_pack_rgba_float,
  20498.    &util_format_i32_float_fetch_rgba_float,
  20499.    NULL, /* unpack_z_32unorm */
  20500.    NULL, /* pack_z_32unorm */
  20501.    NULL, /* unpack_z_float */
  20502.    NULL, /* pack_z_float */
  20503.    NULL, /* unpack_s_8uint */
  20504.    NULL, /* pack_s_8uint */
  20505.    NULL, /* unpack_rgba_uint */
  20506.    NULL, /* pack_rgba_uint */
  20507.    NULL, /* unpack_rgba_sint */
  20508.    NULL, /* pack_rgba_sint */
  20509.    NULL, /* fetch_rgba_uint */
  20510.    NULL  /* fetch_rgba_sint */
  20511. };
  20512.  
  20513. const struct util_format_description
  20514. util_format_r8sg8sb8ux8u_norm_description = {
  20515.    PIPE_FORMAT_R8SG8SB8UX8U_NORM,
  20516.    "PIPE_FORMAT_R8SG8SB8UX8U_NORM",
  20517.    "r8sg8sb8ux8u_norm",
  20518.    {1, 1, 32},  /* block */
  20519.    UTIL_FORMAT_LAYOUT_PLAIN,
  20520.    4,   /* nr_channels */
  20521.    FALSE,       /* is_array */
  20522.    TRUE,        /* is_bitmask */
  20523.    TRUE,        /* is_mixed */
  20524.    {
  20525.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  20526.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = g */
  20527.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = b */
  20528.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  20529.    },
  20530.    {
  20531.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20532.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  20533.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  20534.       UTIL_FORMAT_SWIZZLE_1     /* a */
  20535.    },
  20536.    UTIL_FORMAT_COLORSPACE_RGB,
  20537.    &util_format_r8sg8sb8ux8u_norm_unpack_rgba_8unorm,
  20538.    &util_format_r8sg8sb8ux8u_norm_pack_rgba_8unorm,
  20539.    NULL, /* fetch_rgba_8unorm */
  20540.    &util_format_r8sg8sb8ux8u_norm_unpack_rgba_float,
  20541.    &util_format_r8sg8sb8ux8u_norm_pack_rgba_float,
  20542.    &util_format_r8sg8sb8ux8u_norm_fetch_rgba_float,
  20543.    NULL, /* unpack_z_32unorm */
  20544.    NULL, /* pack_z_32unorm */
  20545.    NULL, /* unpack_z_float */
  20546.    NULL, /* pack_z_float */
  20547.    NULL, /* unpack_s_8uint */
  20548.    NULL, /* pack_s_8uint */
  20549.    NULL, /* unpack_rgba_uint */
  20550.    NULL, /* pack_rgba_uint */
  20551.    NULL, /* unpack_rgba_sint */
  20552.    NULL, /* pack_rgba_sint */
  20553.    NULL, /* fetch_rgba_uint */
  20554.    NULL  /* fetch_rgba_sint */
  20555. };
  20556.  
  20557. const struct util_format_description
  20558. util_format_r5sg5sb6u_norm_description = {
  20559.    PIPE_FORMAT_R5SG5SB6U_NORM,
  20560.    "PIPE_FORMAT_R5SG5SB6U_NORM",
  20561.    "r5sg5sb6u_norm",
  20562.    {1, 1, 16},  /* block */
  20563.    UTIL_FORMAT_LAYOUT_PLAIN,
  20564.    3,   /* nr_channels */
  20565.    FALSE,       /* is_array */
  20566.    TRUE,        /* is_bitmask */
  20567.    TRUE,        /* is_mixed */
  20568.    {
  20569.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 0},     /* x = r */
  20570.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 5},     /* y = g */
  20571.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 6, 10},  /* z = b */
  20572.       {0, 0, 0, 0, 0}
  20573.    },
  20574.    {
  20575.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  20576.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  20577.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  20578.       UTIL_FORMAT_SWIZZLE_1     /* a */
  20579.    },
  20580.    UTIL_FORMAT_COLORSPACE_RGB,
  20581.    &util_format_r5sg5sb6u_norm_unpack_rgba_8unorm,
  20582.    &util_format_r5sg5sb6u_norm_pack_rgba_8unorm,
  20583.    NULL, /* fetch_rgba_8unorm */
  20584.    &util_format_r5sg5sb6u_norm_unpack_rgba_float,
  20585.    &util_format_r5sg5sb6u_norm_pack_rgba_float,
  20586.    &util_format_r5sg5sb6u_norm_fetch_rgba_float,
  20587.    NULL, /* unpack_z_32unorm */
  20588.    NULL, /* pack_z_32unorm */
  20589.    NULL, /* unpack_z_float */
  20590.    NULL, /* pack_z_float */
  20591.    NULL, /* unpack_s_8uint */
  20592.    NULL, /* pack_s_8uint */
  20593.    NULL, /* unpack_rgba_uint */
  20594.    NULL, /* pack_rgba_uint */
  20595.    NULL, /* unpack_rgba_sint */
  20596.    NULL, /* pack_rgba_sint */
  20597.    NULL, /* fetch_rgba_uint */
  20598.    NULL  /* fetch_rgba_sint */
  20599. };
  20600.  
  20601. const struct util_format_description
  20602. util_format_s8_uint_description = {
  20603.    PIPE_FORMAT_S8_UINT,
  20604.    "PIPE_FORMAT_S8_UINT",
  20605.    "s8_uint",
  20606.    {1, 1, 8},   /* block */
  20607.    UTIL_FORMAT_LAYOUT_PLAIN,
  20608.    1,   /* nr_channels */
  20609.    TRUE,        /* is_array */
  20610.    TRUE,        /* is_bitmask */
  20611.    FALSE,       /* is_mixed */
  20612.    {
  20613.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = s */
  20614.       {0, 0, 0, 0, 0},
  20615.       {0, 0, 0, 0, 0},
  20616.       {0, 0, 0, 0, 0}
  20617.    },
  20618.    {
  20619.       UTIL_FORMAT_SWIZZLE_NONE, /* z */
  20620.       UTIL_FORMAT_SWIZZLE_X,    /* s */
  20621.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20622.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20623.    },
  20624.    UTIL_FORMAT_COLORSPACE_ZS,
  20625.    NULL, /* unpack_rgba_8unorm */
  20626.    NULL, /* pack_rgba_8unorm */
  20627.    NULL, /* fetch_rgba_8unorm */
  20628.    NULL, /* unpack_rgba_float */
  20629.    NULL, /* pack_rgba_float */
  20630.    NULL, /* fetch_rgba_float */
  20631.    NULL, /* unpack_z_32unorm */
  20632.    NULL, /* pack_z_32unorm */
  20633.    NULL, /* unpack_z_float */
  20634.    NULL, /* pack_z_float */
  20635.    &util_format_s8_uint_unpack_s_8uint,
  20636.    &util_format_s8_uint_pack_s_8uint,
  20637.    NULL, /* unpack_rgba_uint */
  20638.    NULL, /* pack_rgba_uint */
  20639.    NULL, /* unpack_rgba_sint */
  20640.    NULL, /* pack_rgba_sint */
  20641.    NULL, /* fetch_rgba_uint */
  20642.    NULL  /* fetch_rgba_sint */
  20643. };
  20644.  
  20645. const struct util_format_description
  20646. util_format_z16_unorm_description = {
  20647.    PIPE_FORMAT_Z16_UNORM,
  20648.    "PIPE_FORMAT_Z16_UNORM",
  20649.    "z16_unorm",
  20650.    {1, 1, 16},  /* block */
  20651.    UTIL_FORMAT_LAYOUT_PLAIN,
  20652.    1,   /* nr_channels */
  20653.    TRUE,        /* is_array */
  20654.    TRUE,        /* is_bitmask */
  20655.    FALSE,       /* is_mixed */
  20656.    {
  20657.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = z */
  20658.       {0, 0, 0, 0, 0},
  20659.       {0, 0, 0, 0, 0},
  20660.       {0, 0, 0, 0, 0}
  20661.    },
  20662.    {
  20663.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  20664.       UTIL_FORMAT_SWIZZLE_NONE, /* s */
  20665.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20666.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20667.    },
  20668.    UTIL_FORMAT_COLORSPACE_ZS,
  20669.    NULL, /* unpack_rgba_8unorm */
  20670.    NULL, /* pack_rgba_8unorm */
  20671.    NULL, /* fetch_rgba_8unorm */
  20672.    NULL, /* unpack_rgba_float */
  20673.    NULL, /* pack_rgba_float */
  20674.    NULL, /* fetch_rgba_float */
  20675.    &util_format_z16_unorm_unpack_z_32unorm,
  20676.    &util_format_z16_unorm_pack_z_32unorm,
  20677.    &util_format_z16_unorm_unpack_z_float,
  20678.    &util_format_z16_unorm_pack_z_float,
  20679.    NULL, /* unpack_s_8uint */
  20680.    NULL, /* pack_s_8uint */
  20681.    NULL, /* unpack_rgba_uint */
  20682.    NULL, /* pack_rgba_uint */
  20683.    NULL, /* unpack_rgba_sint */
  20684.    NULL, /* pack_rgba_sint */
  20685.    NULL, /* fetch_rgba_uint */
  20686.    NULL  /* fetch_rgba_sint */
  20687. };
  20688.  
  20689. const struct util_format_description
  20690. util_format_z32_unorm_description = {
  20691.    PIPE_FORMAT_Z32_UNORM,
  20692.    "PIPE_FORMAT_Z32_UNORM",
  20693.    "z32_unorm",
  20694.    {1, 1, 32},  /* block */
  20695.    UTIL_FORMAT_LAYOUT_PLAIN,
  20696.    1,   /* nr_channels */
  20697.    TRUE,        /* is_array */
  20698.    TRUE,        /* is_bitmask */
  20699.    FALSE,       /* is_mixed */
  20700.    {
  20701.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0},  /* x = z */
  20702.       {0, 0, 0, 0, 0},
  20703.       {0, 0, 0, 0, 0},
  20704.       {0, 0, 0, 0, 0}
  20705.    },
  20706.    {
  20707.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  20708.       UTIL_FORMAT_SWIZZLE_NONE, /* s */
  20709.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20710.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20711.    },
  20712.    UTIL_FORMAT_COLORSPACE_ZS,
  20713.    NULL, /* unpack_rgba_8unorm */
  20714.    NULL, /* pack_rgba_8unorm */
  20715.    NULL, /* fetch_rgba_8unorm */
  20716.    NULL, /* unpack_rgba_float */
  20717.    NULL, /* pack_rgba_float */
  20718.    NULL, /* fetch_rgba_float */
  20719.    &util_format_z32_unorm_unpack_z_32unorm,
  20720.    &util_format_z32_unorm_pack_z_32unorm,
  20721.    &util_format_z32_unorm_unpack_z_float,
  20722.    &util_format_z32_unorm_pack_z_float,
  20723.    NULL, /* unpack_s_8uint */
  20724.    NULL, /* pack_s_8uint */
  20725.    NULL, /* unpack_rgba_uint */
  20726.    NULL, /* pack_rgba_uint */
  20727.    NULL, /* unpack_rgba_sint */
  20728.    NULL, /* pack_rgba_sint */
  20729.    NULL, /* fetch_rgba_uint */
  20730.    NULL  /* fetch_rgba_sint */
  20731. };
  20732.  
  20733. const struct util_format_description
  20734. util_format_z32_float_description = {
  20735.    PIPE_FORMAT_Z32_FLOAT,
  20736.    "PIPE_FORMAT_Z32_FLOAT",
  20737.    "z32_float",
  20738.    {1, 1, 32},  /* block */
  20739.    UTIL_FORMAT_LAYOUT_PLAIN,
  20740.    1,   /* nr_channels */
  20741.    TRUE,        /* is_array */
  20742.    FALSE,       /* is_bitmask */
  20743.    FALSE,       /* is_mixed */
  20744.    {
  20745.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = z */
  20746.       {0, 0, 0, 0, 0},
  20747.       {0, 0, 0, 0, 0},
  20748.       {0, 0, 0, 0, 0}
  20749.    },
  20750.    {
  20751.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  20752.       UTIL_FORMAT_SWIZZLE_NONE, /* s */
  20753.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20754.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20755.    },
  20756.    UTIL_FORMAT_COLORSPACE_ZS,
  20757.    NULL, /* unpack_rgba_8unorm */
  20758.    NULL, /* pack_rgba_8unorm */
  20759.    NULL, /* fetch_rgba_8unorm */
  20760.    NULL, /* unpack_rgba_float */
  20761.    NULL, /* pack_rgba_float */
  20762.    NULL, /* fetch_rgba_float */
  20763.    &util_format_z32_float_unpack_z_32unorm,
  20764.    &util_format_z32_float_pack_z_32unorm,
  20765.    &util_format_z32_float_unpack_z_float,
  20766.    &util_format_z32_float_pack_z_float,
  20767.    NULL, /* unpack_s_8uint */
  20768.    NULL, /* pack_s_8uint */
  20769.    NULL, /* unpack_rgba_uint */
  20770.    NULL, /* pack_rgba_uint */
  20771.    NULL, /* unpack_rgba_sint */
  20772.    NULL, /* pack_rgba_sint */
  20773.    NULL, /* fetch_rgba_uint */
  20774.    NULL  /* fetch_rgba_sint */
  20775. };
  20776.  
  20777. const struct util_format_description
  20778. util_format_z24_unorm_s8_uint_description = {
  20779.    PIPE_FORMAT_Z24_UNORM_S8_UINT,
  20780.    "PIPE_FORMAT_Z24_UNORM_S8_UINT",
  20781.    "z24_unorm_s8_uint",
  20782.    {1, 1, 32},  /* block */
  20783.    UTIL_FORMAT_LAYOUT_PLAIN,
  20784.    2,   /* nr_channels */
  20785.    FALSE,       /* is_array */
  20786.    TRUE,        /* is_bitmask */
  20787.    TRUE,        /* is_mixed */
  20788.    {
  20789.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0},  /* x = z */
  20790.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24},  /* y = s */
  20791.       {0, 0, 0, 0, 0},
  20792.       {0, 0, 0, 0, 0}
  20793.    },
  20794.    {
  20795.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  20796.       UTIL_FORMAT_SWIZZLE_Y,    /* s */
  20797.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20798.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20799.    },
  20800.    UTIL_FORMAT_COLORSPACE_ZS,
  20801.    NULL, /* unpack_rgba_8unorm */
  20802.    NULL, /* pack_rgba_8unorm */
  20803.    NULL, /* fetch_rgba_8unorm */
  20804.    NULL, /* unpack_rgba_float */
  20805.    NULL, /* pack_rgba_float */
  20806.    NULL, /* fetch_rgba_float */
  20807.    &util_format_z24_unorm_s8_uint_unpack_z_32unorm,
  20808.    &util_format_z24_unorm_s8_uint_pack_z_32unorm,
  20809.    &util_format_z24_unorm_s8_uint_unpack_z_float,
  20810.    &util_format_z24_unorm_s8_uint_pack_z_float,
  20811.    &util_format_z24_unorm_s8_uint_unpack_s_8uint,
  20812.    &util_format_z24_unorm_s8_uint_pack_s_8uint,
  20813.    NULL, /* unpack_rgba_uint */
  20814.    NULL, /* pack_rgba_uint */
  20815.    NULL, /* unpack_rgba_sint */
  20816.    NULL, /* pack_rgba_sint */
  20817.    NULL, /* fetch_rgba_uint */
  20818.    NULL  /* fetch_rgba_sint */
  20819. };
  20820.  
  20821. const struct util_format_description
  20822. util_format_s8_uint_z24_unorm_description = {
  20823.    PIPE_FORMAT_S8_UINT_Z24_UNORM,
  20824.    "PIPE_FORMAT_S8_UINT_Z24_UNORM",
  20825.    "s8_uint_z24_unorm",
  20826.    {1, 1, 32},  /* block */
  20827.    UTIL_FORMAT_LAYOUT_PLAIN,
  20828.    2,   /* nr_channels */
  20829.    FALSE,       /* is_array */
  20830.    TRUE,        /* is_bitmask */
  20831.    TRUE,        /* is_mixed */
  20832.    {
  20833.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = s */
  20834.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8},  /* y = z */
  20835.       {0, 0, 0, 0, 0},
  20836.       {0, 0, 0, 0, 0}
  20837.    },
  20838.    {
  20839.       UTIL_FORMAT_SWIZZLE_Y,    /* z */
  20840.       UTIL_FORMAT_SWIZZLE_X,    /* s */
  20841.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20842.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20843.    },
  20844.    UTIL_FORMAT_COLORSPACE_ZS,
  20845.    NULL, /* unpack_rgba_8unorm */
  20846.    NULL, /* pack_rgba_8unorm */
  20847.    NULL, /* fetch_rgba_8unorm */
  20848.    NULL, /* unpack_rgba_float */
  20849.    NULL, /* pack_rgba_float */
  20850.    NULL, /* fetch_rgba_float */
  20851.    &util_format_s8_uint_z24_unorm_unpack_z_32unorm,
  20852.    &util_format_s8_uint_z24_unorm_pack_z_32unorm,
  20853.    &util_format_s8_uint_z24_unorm_unpack_z_float,
  20854.    &util_format_s8_uint_z24_unorm_pack_z_float,
  20855.    &util_format_s8_uint_z24_unorm_unpack_s_8uint,
  20856.    &util_format_s8_uint_z24_unorm_pack_s_8uint,
  20857.    NULL, /* unpack_rgba_uint */
  20858.    NULL, /* pack_rgba_uint */
  20859.    NULL, /* unpack_rgba_sint */
  20860.    NULL, /* pack_rgba_sint */
  20861.    NULL, /* fetch_rgba_uint */
  20862.    NULL  /* fetch_rgba_sint */
  20863. };
  20864.  
  20865. const struct util_format_description
  20866. util_format_x24s8_uint_description = {
  20867.    PIPE_FORMAT_X24S8_UINT,
  20868.    "PIPE_FORMAT_X24S8_UINT",
  20869.    "x24s8_uint",
  20870.    {1, 1, 32},  /* block */
  20871.    UTIL_FORMAT_LAYOUT_PLAIN,
  20872.    2,   /* nr_channels */
  20873.    FALSE,       /* is_array */
  20874.    TRUE,        /* is_bitmask */
  20875.    FALSE,       /* is_mixed */
  20876.    {
  20877.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 0},     /* x = x */
  20878.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24},  /* y = s */
  20879.       {0, 0, 0, 0, 0},
  20880.       {0, 0, 0, 0, 0}
  20881.    },
  20882.    {
  20883.       UTIL_FORMAT_SWIZZLE_NONE, /* z */
  20884.       UTIL_FORMAT_SWIZZLE_Y,    /* s */
  20885.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20886.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20887.    },
  20888.    UTIL_FORMAT_COLORSPACE_ZS,
  20889.    NULL, /* unpack_rgba_8unorm */
  20890.    NULL, /* pack_rgba_8unorm */
  20891.    NULL, /* fetch_rgba_8unorm */
  20892.    NULL, /* unpack_rgba_float */
  20893.    NULL, /* pack_rgba_float */
  20894.    NULL, /* fetch_rgba_float */
  20895.    NULL, /* unpack_z_32unorm */
  20896.    NULL, /* pack_z_32unorm */
  20897.    NULL, /* unpack_z_float */
  20898.    NULL, /* pack_z_float */
  20899.    &util_format_x24s8_uint_unpack_s_8uint,
  20900.    &util_format_x24s8_uint_pack_s_8uint,
  20901.    NULL, /* unpack_rgba_uint */
  20902.    NULL, /* pack_rgba_uint */
  20903.    NULL, /* unpack_rgba_sint */
  20904.    NULL, /* pack_rgba_sint */
  20905.    NULL, /* fetch_rgba_uint */
  20906.    NULL  /* fetch_rgba_sint */
  20907. };
  20908.  
  20909. const struct util_format_description
  20910. util_format_s8x24_uint_description = {
  20911.    PIPE_FORMAT_S8X24_UINT,
  20912.    "PIPE_FORMAT_S8X24_UINT",
  20913.    "s8x24_uint",
  20914.    {1, 1, 32},  /* block */
  20915.    UTIL_FORMAT_LAYOUT_PLAIN,
  20916.    2,   /* nr_channels */
  20917.    FALSE,       /* is_array */
  20918.    TRUE,        /* is_bitmask */
  20919.    FALSE,       /* is_mixed */
  20920.    {
  20921.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = s */
  20922.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 8},     /* y = x */
  20923.       {0, 0, 0, 0, 0},
  20924.       {0, 0, 0, 0, 0}
  20925.    },
  20926.    {
  20927.       UTIL_FORMAT_SWIZZLE_NONE, /* z */
  20928.       UTIL_FORMAT_SWIZZLE_X,    /* s */
  20929.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20930.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20931.    },
  20932.    UTIL_FORMAT_COLORSPACE_ZS,
  20933.    NULL, /* unpack_rgba_8unorm */
  20934.    NULL, /* pack_rgba_8unorm */
  20935.    NULL, /* fetch_rgba_8unorm */
  20936.    NULL, /* unpack_rgba_float */
  20937.    NULL, /* pack_rgba_float */
  20938.    NULL, /* fetch_rgba_float */
  20939.    NULL, /* unpack_z_32unorm */
  20940.    NULL, /* pack_z_32unorm */
  20941.    NULL, /* unpack_z_float */
  20942.    NULL, /* pack_z_float */
  20943.    &util_format_s8x24_uint_unpack_s_8uint,
  20944.    &util_format_s8x24_uint_pack_s_8uint,
  20945.    NULL, /* unpack_rgba_uint */
  20946.    NULL, /* pack_rgba_uint */
  20947.    NULL, /* unpack_rgba_sint */
  20948.    NULL, /* pack_rgba_sint */
  20949.    NULL, /* fetch_rgba_uint */
  20950.    NULL  /* fetch_rgba_sint */
  20951. };
  20952.  
  20953. const struct util_format_description
  20954. util_format_z24x8_unorm_description = {
  20955.    PIPE_FORMAT_Z24X8_UNORM,
  20956.    "PIPE_FORMAT_Z24X8_UNORM",
  20957.    "z24x8_unorm",
  20958.    {1, 1, 32},  /* block */
  20959.    UTIL_FORMAT_LAYOUT_PLAIN,
  20960.    2,   /* nr_channels */
  20961.    FALSE,       /* is_array */
  20962.    TRUE,        /* is_bitmask */
  20963.    FALSE,       /* is_mixed */
  20964.    {
  20965.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0},  /* x = z */
  20966.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24},     /* y = x */
  20967.       {0, 0, 0, 0, 0},
  20968.       {0, 0, 0, 0, 0}
  20969.    },
  20970.    {
  20971.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  20972.       UTIL_FORMAT_SWIZZLE_NONE, /* s */
  20973.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  20974.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  20975.    },
  20976.    UTIL_FORMAT_COLORSPACE_ZS,
  20977.    NULL, /* unpack_rgba_8unorm */
  20978.    NULL, /* pack_rgba_8unorm */
  20979.    NULL, /* fetch_rgba_8unorm */
  20980.    NULL, /* unpack_rgba_float */
  20981.    NULL, /* pack_rgba_float */
  20982.    NULL, /* fetch_rgba_float */
  20983.    &util_format_z24x8_unorm_unpack_z_32unorm,
  20984.    &util_format_z24x8_unorm_pack_z_32unorm,
  20985.    &util_format_z24x8_unorm_unpack_z_float,
  20986.    &util_format_z24x8_unorm_pack_z_float,
  20987.    NULL, /* unpack_s_8uint */
  20988.    NULL, /* pack_s_8uint */
  20989.    NULL, /* unpack_rgba_uint */
  20990.    NULL, /* pack_rgba_uint */
  20991.    NULL, /* unpack_rgba_sint */
  20992.    NULL, /* pack_rgba_sint */
  20993.    NULL, /* fetch_rgba_uint */
  20994.    NULL  /* fetch_rgba_sint */
  20995. };
  20996.  
  20997. const struct util_format_description
  20998. util_format_x8z24_unorm_description = {
  20999.    PIPE_FORMAT_X8Z24_UNORM,
  21000.    "PIPE_FORMAT_X8Z24_UNORM",
  21001.    "x8z24_unorm",
  21002.    {1, 1, 32},  /* block */
  21003.    UTIL_FORMAT_LAYOUT_PLAIN,
  21004.    2,   /* nr_channels */
  21005.    FALSE,       /* is_array */
  21006.    TRUE,        /* is_bitmask */
  21007.    FALSE,       /* is_mixed */
  21008.    {
  21009.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  21010.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8},  /* y = z */
  21011.       {0, 0, 0, 0, 0},
  21012.       {0, 0, 0, 0, 0}
  21013.    },
  21014.    {
  21015.       UTIL_FORMAT_SWIZZLE_Y,    /* z */
  21016.       UTIL_FORMAT_SWIZZLE_NONE, /* s */
  21017.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  21018.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  21019.    },
  21020.    UTIL_FORMAT_COLORSPACE_ZS,
  21021.    NULL, /* unpack_rgba_8unorm */
  21022.    NULL, /* pack_rgba_8unorm */
  21023.    NULL, /* fetch_rgba_8unorm */
  21024.    NULL, /* unpack_rgba_float */
  21025.    NULL, /* pack_rgba_float */
  21026.    NULL, /* fetch_rgba_float */
  21027.    &util_format_x8z24_unorm_unpack_z_32unorm,
  21028.    &util_format_x8z24_unorm_pack_z_32unorm,
  21029.    &util_format_x8z24_unorm_unpack_z_float,
  21030.    &util_format_x8z24_unorm_pack_z_float,
  21031.    NULL, /* unpack_s_8uint */
  21032.    NULL, /* pack_s_8uint */
  21033.    NULL, /* unpack_rgba_uint */
  21034.    NULL, /* pack_rgba_uint */
  21035.    NULL, /* unpack_rgba_sint */
  21036.    NULL, /* pack_rgba_sint */
  21037.    NULL, /* fetch_rgba_uint */
  21038.    NULL  /* fetch_rgba_sint */
  21039. };
  21040.  
  21041. const struct util_format_description
  21042. util_format_z32_float_s8x24_uint_description = {
  21043.    PIPE_FORMAT_Z32_FLOAT_S8X24_UINT,
  21044.    "PIPE_FORMAT_Z32_FLOAT_S8X24_UINT",
  21045.    "z32_float_s8x24_uint",
  21046.    {1, 1, 64},  /* block */
  21047.    UTIL_FORMAT_LAYOUT_PLAIN,
  21048.    3,   /* nr_channels */
  21049.    FALSE,       /* is_array */
  21050.    FALSE,       /* is_bitmask */
  21051.    TRUE,        /* is_mixed */
  21052.    {
  21053.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = z */
  21054.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32},  /* y = s */
  21055.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40},    /* z = x */
  21056.       {0, 0, 0, 0, 0}
  21057.    },
  21058.    {
  21059.       UTIL_FORMAT_SWIZZLE_X,    /* z */
  21060.       UTIL_FORMAT_SWIZZLE_Y,    /* s */
  21061.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  21062.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  21063.    },
  21064.    UTIL_FORMAT_COLORSPACE_ZS,
  21065.    NULL, /* unpack_rgba_8unorm */
  21066.    NULL, /* pack_rgba_8unorm */
  21067.    NULL, /* fetch_rgba_8unorm */
  21068.    NULL, /* unpack_rgba_float */
  21069.    NULL, /* pack_rgba_float */
  21070.    NULL, /* fetch_rgba_float */
  21071.    &util_format_z32_float_s8x24_uint_unpack_z_32unorm,
  21072.    &util_format_z32_float_s8x24_uint_pack_z_32unorm,
  21073.    &util_format_z32_float_s8x24_uint_unpack_z_float,
  21074.    &util_format_z32_float_s8x24_uint_pack_z_float,
  21075.    &util_format_z32_float_s8x24_uint_unpack_s_8uint,
  21076.    &util_format_z32_float_s8x24_uint_pack_s_8uint,
  21077.    NULL, /* unpack_rgba_uint */
  21078.    NULL, /* pack_rgba_uint */
  21079.    NULL, /* unpack_rgba_sint */
  21080.    NULL, /* pack_rgba_sint */
  21081.    NULL, /* fetch_rgba_uint */
  21082.    NULL  /* fetch_rgba_sint */
  21083. };
  21084.  
  21085. const struct util_format_description
  21086. util_format_x32_s8x24_uint_description = {
  21087.    PIPE_FORMAT_X32_S8X24_UINT,
  21088.    "PIPE_FORMAT_X32_S8X24_UINT",
  21089.    "x32_s8x24_uint",
  21090.    {1, 1, 64},  /* block */
  21091.    UTIL_FORMAT_LAYOUT_PLAIN,
  21092.    3,   /* nr_channels */
  21093.    FALSE,       /* is_array */
  21094.    FALSE,       /* is_bitmask */
  21095.    FALSE,       /* is_mixed */
  21096.    {
  21097.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21098.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32},  /* y = s */
  21099.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40},    /* z = x */
  21100.       {0, 0, 0, 0, 0}
  21101.    },
  21102.    {
  21103.       UTIL_FORMAT_SWIZZLE_NONE, /* z */
  21104.       UTIL_FORMAT_SWIZZLE_Y,    /* s */
  21105.       UTIL_FORMAT_SWIZZLE_NONE, /* ignored */
  21106.       UTIL_FORMAT_SWIZZLE_NONE  /* ignored */
  21107.    },
  21108.    UTIL_FORMAT_COLORSPACE_ZS,
  21109.    NULL, /* unpack_rgba_8unorm */
  21110.    NULL, /* pack_rgba_8unorm */
  21111.    NULL, /* fetch_rgba_8unorm */
  21112.    NULL, /* unpack_rgba_float */
  21113.    NULL, /* pack_rgba_float */
  21114.    NULL, /* fetch_rgba_float */
  21115.    NULL, /* unpack_z_32unorm */
  21116.    NULL, /* pack_z_32unorm */
  21117.    NULL, /* unpack_z_float */
  21118.    NULL, /* pack_z_float */
  21119.    &util_format_x32_s8x24_uint_unpack_s_8uint,
  21120.    &util_format_x32_s8x24_uint_pack_s_8uint,
  21121.    NULL, /* unpack_rgba_uint */
  21122.    NULL, /* pack_rgba_uint */
  21123.    NULL, /* unpack_rgba_sint */
  21124.    NULL, /* pack_rgba_sint */
  21125.    NULL, /* fetch_rgba_uint */
  21126.    NULL  /* fetch_rgba_sint */
  21127. };
  21128.  
  21129. const struct util_format_description
  21130. util_format_uyvy_description = {
  21131.    PIPE_FORMAT_UYVY,
  21132.    "PIPE_FORMAT_UYVY",
  21133.    "uyvy",
  21134.    {2, 1, 32},  /* block */
  21135.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21136.    1,   /* nr_channels */
  21137.    FALSE,       /* is_array */
  21138.    FALSE,       /* is_bitmask */
  21139.    FALSE,       /* is_mixed */
  21140.    {
  21141.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21142.       {0, 0, 0, 0, 0},
  21143.       {0, 0, 0, 0, 0},
  21144.       {0, 0, 0, 0, 0}
  21145.    },
  21146.    {
  21147.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  21148.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  21149.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  21150.       UTIL_FORMAT_SWIZZLE_1     /* ignored */
  21151.    },
  21152.    UTIL_FORMAT_COLORSPACE_YUV,
  21153.    &util_format_uyvy_unpack_rgba_8unorm,
  21154.    &util_format_uyvy_pack_rgba_8unorm,
  21155.    NULL, /* fetch_rgba_8unorm */
  21156.    &util_format_uyvy_unpack_rgba_float,
  21157.    &util_format_uyvy_pack_rgba_float,
  21158.    &util_format_uyvy_fetch_rgba_float,
  21159.    NULL, /* unpack_z_32unorm */
  21160.    NULL, /* pack_z_32unorm */
  21161.    NULL, /* unpack_z_float */
  21162.    NULL, /* pack_z_float */
  21163.    NULL, /* unpack_s_8uint */
  21164.    NULL, /* pack_s_8uint */
  21165.    NULL, /* unpack_rgba_uint */
  21166.    NULL, /* pack_rgba_uint */
  21167.    NULL, /* unpack_rgba_sint */
  21168.    NULL, /* pack_rgba_sint */
  21169.    NULL, /* fetch_rgba_uint */
  21170.    NULL  /* fetch_rgba_sint */
  21171. };
  21172.  
  21173. const struct util_format_description
  21174. util_format_yuyv_description = {
  21175.    PIPE_FORMAT_YUYV,
  21176.    "PIPE_FORMAT_YUYV",
  21177.    "yuyv",
  21178.    {2, 1, 32},  /* block */
  21179.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21180.    1,   /* nr_channels */
  21181.    FALSE,       /* is_array */
  21182.    FALSE,       /* is_bitmask */
  21183.    FALSE,       /* is_mixed */
  21184.    {
  21185.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21186.       {0, 0, 0, 0, 0},
  21187.       {0, 0, 0, 0, 0},
  21188.       {0, 0, 0, 0, 0}
  21189.    },
  21190.    {
  21191.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  21192.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  21193.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  21194.       UTIL_FORMAT_SWIZZLE_1     /* ignored */
  21195.    },
  21196.    UTIL_FORMAT_COLORSPACE_YUV,
  21197.    &util_format_yuyv_unpack_rgba_8unorm,
  21198.    &util_format_yuyv_pack_rgba_8unorm,
  21199.    NULL, /* fetch_rgba_8unorm */
  21200.    &util_format_yuyv_unpack_rgba_float,
  21201.    &util_format_yuyv_pack_rgba_float,
  21202.    &util_format_yuyv_fetch_rgba_float,
  21203.    NULL, /* unpack_z_32unorm */
  21204.    NULL, /* pack_z_32unorm */
  21205.    NULL, /* unpack_z_float */
  21206.    NULL, /* pack_z_float */
  21207.    NULL, /* unpack_s_8uint */
  21208.    NULL, /* pack_s_8uint */
  21209.    NULL, /* unpack_rgba_uint */
  21210.    NULL, /* pack_rgba_uint */
  21211.    NULL, /* unpack_rgba_sint */
  21212.    NULL, /* pack_rgba_sint */
  21213.    NULL, /* fetch_rgba_uint */
  21214.    NULL  /* fetch_rgba_sint */
  21215. };
  21216.  
  21217. const struct util_format_description
  21218. util_format_r8g8_b8g8_unorm_description = {
  21219.    PIPE_FORMAT_R8G8_B8G8_UNORM,
  21220.    "PIPE_FORMAT_R8G8_B8G8_UNORM",
  21221.    "r8g8_b8g8_unorm",
  21222.    {2, 1, 32},  /* block */
  21223.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21224.    1,   /* nr_channels */
  21225.    FALSE,       /* is_array */
  21226.    FALSE,       /* is_bitmask */
  21227.    FALSE,       /* is_mixed */
  21228.    {
  21229.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21230.       {0, 0, 0, 0, 0},
  21231.       {0, 0, 0, 0, 0},
  21232.       {0, 0, 0, 0, 0}
  21233.    },
  21234.    {
  21235.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21236.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21237.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21238.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21239.    },
  21240.    UTIL_FORMAT_COLORSPACE_RGB,
  21241.    &util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm,
  21242.    &util_format_r8g8_b8g8_unorm_pack_rgba_8unorm,
  21243.    NULL, /* fetch_rgba_8unorm */
  21244.    &util_format_r8g8_b8g8_unorm_unpack_rgba_float,
  21245.    &util_format_r8g8_b8g8_unorm_pack_rgba_float,
  21246.    &util_format_r8g8_b8g8_unorm_fetch_rgba_float,
  21247.    NULL, /* unpack_z_32unorm */
  21248.    NULL, /* pack_z_32unorm */
  21249.    NULL, /* unpack_z_float */
  21250.    NULL, /* pack_z_float */
  21251.    NULL, /* unpack_s_8uint */
  21252.    NULL, /* pack_s_8uint */
  21253.    NULL, /* unpack_rgba_uint */
  21254.    NULL, /* pack_rgba_uint */
  21255.    NULL, /* unpack_rgba_sint */
  21256.    NULL, /* pack_rgba_sint */
  21257.    NULL, /* fetch_rgba_uint */
  21258.    NULL  /* fetch_rgba_sint */
  21259. };
  21260.  
  21261. const struct util_format_description
  21262. util_format_g8r8_g8b8_unorm_description = {
  21263.    PIPE_FORMAT_G8R8_G8B8_UNORM,
  21264.    "PIPE_FORMAT_G8R8_G8B8_UNORM",
  21265.    "g8r8_g8b8_unorm",
  21266.    {2, 1, 32},  /* block */
  21267.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21268.    1,   /* nr_channels */
  21269.    FALSE,       /* is_array */
  21270.    FALSE,       /* is_bitmask */
  21271.    FALSE,       /* is_mixed */
  21272.    {
  21273.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21274.       {0, 0, 0, 0, 0},
  21275.       {0, 0, 0, 0, 0},
  21276.       {0, 0, 0, 0, 0}
  21277.    },
  21278.    {
  21279.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21280.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21281.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21282.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21283.    },
  21284.    UTIL_FORMAT_COLORSPACE_RGB,
  21285.    &util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm,
  21286.    &util_format_g8r8_g8b8_unorm_pack_rgba_8unorm,
  21287.    NULL, /* fetch_rgba_8unorm */
  21288.    &util_format_g8r8_g8b8_unorm_unpack_rgba_float,
  21289.    &util_format_g8r8_g8b8_unorm_pack_rgba_float,
  21290.    &util_format_g8r8_g8b8_unorm_fetch_rgba_float,
  21291.    NULL, /* unpack_z_32unorm */
  21292.    NULL, /* pack_z_32unorm */
  21293.    NULL, /* unpack_z_float */
  21294.    NULL, /* pack_z_float */
  21295.    NULL, /* unpack_s_8uint */
  21296.    NULL, /* pack_s_8uint */
  21297.    NULL, /* unpack_rgba_uint */
  21298.    NULL, /* pack_rgba_uint */
  21299.    NULL, /* unpack_rgba_sint */
  21300.    NULL, /* pack_rgba_sint */
  21301.    NULL, /* fetch_rgba_uint */
  21302.    NULL  /* fetch_rgba_sint */
  21303. };
  21304.  
  21305. const struct util_format_description
  21306. util_format_g8r8_b8r8_unorm_description = {
  21307.    PIPE_FORMAT_G8R8_B8R8_UNORM,
  21308.    "PIPE_FORMAT_G8R8_B8R8_UNORM",
  21309.    "g8r8_b8r8_unorm",
  21310.    {2, 1, 32},  /* block */
  21311.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21312.    1,   /* nr_channels */
  21313.    FALSE,       /* is_array */
  21314.    FALSE,       /* is_bitmask */
  21315.    FALSE,       /* is_mixed */
  21316.    {
  21317.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21318.       {0, 0, 0, 0, 0},
  21319.       {0, 0, 0, 0, 0},
  21320.       {0, 0, 0, 0, 0}
  21321.    },
  21322.    {
  21323.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  21324.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  21325.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21326.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21327.    },
  21328.    UTIL_FORMAT_COLORSPACE_RGB,
  21329.    &util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm,
  21330.    &util_format_g8r8_b8r8_unorm_pack_rgba_8unorm,
  21331.    NULL, /* fetch_rgba_8unorm */
  21332.    &util_format_g8r8_b8r8_unorm_unpack_rgba_float,
  21333.    &util_format_g8r8_b8r8_unorm_pack_rgba_float,
  21334.    &util_format_g8r8_b8r8_unorm_fetch_rgba_float,
  21335.    NULL, /* unpack_z_32unorm */
  21336.    NULL, /* pack_z_32unorm */
  21337.    NULL, /* unpack_z_float */
  21338.    NULL, /* pack_z_float */
  21339.    NULL, /* unpack_s_8uint */
  21340.    NULL, /* pack_s_8uint */
  21341.    NULL, /* unpack_rgba_uint */
  21342.    NULL, /* pack_rgba_uint */
  21343.    NULL, /* unpack_rgba_sint */
  21344.    NULL, /* pack_rgba_sint */
  21345.    NULL, /* fetch_rgba_uint */
  21346.    NULL  /* fetch_rgba_sint */
  21347. };
  21348.  
  21349. const struct util_format_description
  21350. util_format_r8g8_r8b8_unorm_description = {
  21351.    PIPE_FORMAT_R8G8_R8B8_UNORM,
  21352.    "PIPE_FORMAT_R8G8_R8B8_UNORM",
  21353.    "r8g8_r8b8_unorm",
  21354.    {2, 1, 32},  /* block */
  21355.    UTIL_FORMAT_LAYOUT_SUBSAMPLED,
  21356.    1,   /* nr_channels */
  21357.    FALSE,       /* is_array */
  21358.    FALSE,       /* is_bitmask */
  21359.    FALSE,       /* is_mixed */
  21360.    {
  21361.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21362.       {0, 0, 0, 0, 0},
  21363.       {0, 0, 0, 0, 0},
  21364.       {0, 0, 0, 0, 0}
  21365.    },
  21366.    {
  21367.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  21368.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  21369.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21370.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21371.    },
  21372.    UTIL_FORMAT_COLORSPACE_RGB,
  21373.    &util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm,
  21374.    &util_format_r8g8_r8b8_unorm_pack_rgba_8unorm,
  21375.    NULL, /* fetch_rgba_8unorm */
  21376.    &util_format_r8g8_r8b8_unorm_unpack_rgba_float,
  21377.    &util_format_r8g8_r8b8_unorm_pack_rgba_float,
  21378.    &util_format_r8g8_r8b8_unorm_fetch_rgba_float,
  21379.    NULL, /* unpack_z_32unorm */
  21380.    NULL, /* pack_z_32unorm */
  21381.    NULL, /* unpack_z_float */
  21382.    NULL, /* pack_z_float */
  21383.    NULL, /* unpack_s_8uint */
  21384.    NULL, /* pack_s_8uint */
  21385.    NULL, /* unpack_rgba_uint */
  21386.    NULL, /* pack_rgba_uint */
  21387.    NULL, /* unpack_rgba_sint */
  21388.    NULL, /* pack_rgba_sint */
  21389.    NULL, /* fetch_rgba_uint */
  21390.    NULL  /* fetch_rgba_sint */
  21391. };
  21392.  
  21393. const struct util_format_description
  21394. util_format_r11g11b10_float_description = {
  21395.    PIPE_FORMAT_R11G11B10_FLOAT,
  21396.    "PIPE_FORMAT_R11G11B10_FLOAT",
  21397.    "r11g11b10_float",
  21398.    {1, 1, 32},  /* block */
  21399.    UTIL_FORMAT_LAYOUT_OTHER,
  21400.    1,   /* nr_channels */
  21401.    FALSE,       /* is_array */
  21402.    FALSE,       /* is_bitmask */
  21403.    FALSE,       /* is_mixed */
  21404.    {
  21405.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21406.       {0, 0, 0, 0, 0},
  21407.       {0, 0, 0, 0, 0},
  21408.       {0, 0, 0, 0, 0}
  21409.    },
  21410.    {
  21411.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21412.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21413.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21414.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21415.    },
  21416.    UTIL_FORMAT_COLORSPACE_RGB,
  21417.    &util_format_r11g11b10_float_unpack_rgba_8unorm,
  21418.    &util_format_r11g11b10_float_pack_rgba_8unorm,
  21419.    NULL, /* fetch_rgba_8unorm */
  21420.    &util_format_r11g11b10_float_unpack_rgba_float,
  21421.    &util_format_r11g11b10_float_pack_rgba_float,
  21422.    &util_format_r11g11b10_float_fetch_rgba_float,
  21423.    NULL, /* unpack_z_32unorm */
  21424.    NULL, /* pack_z_32unorm */
  21425.    NULL, /* unpack_z_float */
  21426.    NULL, /* pack_z_float */
  21427.    NULL, /* unpack_s_8uint */
  21428.    NULL, /* pack_s_8uint */
  21429.    NULL, /* unpack_rgba_uint */
  21430.    NULL, /* pack_rgba_uint */
  21431.    NULL, /* unpack_rgba_sint */
  21432.    NULL, /* pack_rgba_sint */
  21433.    NULL, /* fetch_rgba_uint */
  21434.    NULL  /* fetch_rgba_sint */
  21435. };
  21436.  
  21437. const struct util_format_description
  21438. util_format_r9g9b9e5_float_description = {
  21439.    PIPE_FORMAT_R9G9B9E5_FLOAT,
  21440.    "PIPE_FORMAT_R9G9B9E5_FLOAT",
  21441.    "r9g9b9e5_float",
  21442.    {1, 1, 32},  /* block */
  21443.    UTIL_FORMAT_LAYOUT_OTHER,
  21444.    1,   /* nr_channels */
  21445.    FALSE,       /* is_array */
  21446.    FALSE,       /* is_bitmask */
  21447.    FALSE,       /* is_mixed */
  21448.    {
  21449.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0},     /* x = x */
  21450.       {0, 0, 0, 0, 0},
  21451.       {0, 0, 0, 0, 0},
  21452.       {0, 0, 0, 0, 0}
  21453.    },
  21454.    {
  21455.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21456.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21457.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21458.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21459.    },
  21460.    UTIL_FORMAT_COLORSPACE_RGB,
  21461.    &util_format_r9g9b9e5_float_unpack_rgba_8unorm,
  21462.    &util_format_r9g9b9e5_float_pack_rgba_8unorm,
  21463.    NULL, /* fetch_rgba_8unorm */
  21464.    &util_format_r9g9b9e5_float_unpack_rgba_float,
  21465.    &util_format_r9g9b9e5_float_pack_rgba_float,
  21466.    &util_format_r9g9b9e5_float_fetch_rgba_float,
  21467.    NULL, /* unpack_z_32unorm */
  21468.    NULL, /* pack_z_32unorm */
  21469.    NULL, /* unpack_z_float */
  21470.    NULL, /* pack_z_float */
  21471.    NULL, /* unpack_s_8uint */
  21472.    NULL, /* pack_s_8uint */
  21473.    NULL, /* unpack_rgba_uint */
  21474.    NULL, /* pack_rgba_uint */
  21475.    NULL, /* unpack_rgba_sint */
  21476.    NULL, /* pack_rgba_sint */
  21477.    NULL, /* fetch_rgba_uint */
  21478.    NULL  /* fetch_rgba_sint */
  21479. };
  21480.  
  21481. const struct util_format_description
  21482. util_format_r1_unorm_description = {
  21483.    PIPE_FORMAT_R1_UNORM,
  21484.    "PIPE_FORMAT_R1_UNORM",
  21485.    "r1_unorm",
  21486.    {8, 1, 8},   /* block */
  21487.    UTIL_FORMAT_LAYOUT_OTHER,
  21488.    1,   /* nr_channels */
  21489.    FALSE,       /* is_array */
  21490.    FALSE,       /* is_bitmask */
  21491.    FALSE,       /* is_mixed */
  21492.    {
  21493.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  21494.       {0, 0, 0, 0, 0},
  21495.       {0, 0, 0, 0, 0},
  21496.       {0, 0, 0, 0, 0}
  21497.    },
  21498.    {
  21499.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21500.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  21501.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21502.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21503.    },
  21504.    UTIL_FORMAT_COLORSPACE_RGB,
  21505.    &util_format_r1_unorm_unpack_rgba_8unorm,
  21506.    &util_format_r1_unorm_pack_rgba_8unorm,
  21507.    NULL, /* fetch_rgba_8unorm */
  21508.    &util_format_r1_unorm_unpack_rgba_float,
  21509.    &util_format_r1_unorm_pack_rgba_float,
  21510.    &util_format_r1_unorm_fetch_rgba_float,
  21511.    NULL, /* unpack_z_32unorm */
  21512.    NULL, /* pack_z_32unorm */
  21513.    NULL, /* unpack_z_float */
  21514.    NULL, /* pack_z_float */
  21515.    NULL, /* unpack_s_8uint */
  21516.    NULL, /* pack_s_8uint */
  21517.    NULL, /* unpack_rgba_uint */
  21518.    NULL, /* pack_rgba_uint */
  21519.    NULL, /* unpack_rgba_sint */
  21520.    NULL, /* pack_rgba_sint */
  21521.    NULL, /* fetch_rgba_uint */
  21522.    NULL  /* fetch_rgba_sint */
  21523. };
  21524.  
  21525. const struct util_format_description
  21526. util_format_r8g8bx_snorm_description = {
  21527.    PIPE_FORMAT_R8G8Bx_SNORM,
  21528.    "PIPE_FORMAT_R8G8Bx_SNORM",
  21529.    "r8g8bx_snorm",
  21530.    {1, 1, 16},  /* block */
  21531.    UTIL_FORMAT_LAYOUT_OTHER,
  21532.    2,   /* nr_channels */
  21533.    FALSE,       /* is_array */
  21534.    FALSE,       /* is_bitmask */
  21535.    FALSE,       /* is_mixed */
  21536.    {
  21537.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = x */
  21538.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = y */
  21539.       {0, 0, 0, 0, 0},
  21540.       {0, 0, 0, 0, 0}
  21541.    },
  21542.    {
  21543.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21544.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21545.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21546.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21547.    },
  21548.    UTIL_FORMAT_COLORSPACE_RGB,
  21549.    &util_format_r8g8bx_snorm_unpack_rgba_8unorm,
  21550.    &util_format_r8g8bx_snorm_pack_rgba_8unorm,
  21551.    NULL, /* fetch_rgba_8unorm */
  21552.    &util_format_r8g8bx_snorm_unpack_rgba_float,
  21553.    &util_format_r8g8bx_snorm_pack_rgba_float,
  21554.    &util_format_r8g8bx_snorm_fetch_rgba_float,
  21555.    NULL, /* unpack_z_32unorm */
  21556.    NULL, /* pack_z_32unorm */
  21557.    NULL, /* unpack_z_float */
  21558.    NULL, /* pack_z_float */
  21559.    NULL, /* unpack_s_8uint */
  21560.    NULL, /* pack_s_8uint */
  21561.    NULL, /* unpack_rgba_uint */
  21562.    NULL, /* pack_rgba_uint */
  21563.    NULL, /* unpack_rgba_sint */
  21564.    NULL, /* pack_rgba_sint */
  21565.    NULL, /* fetch_rgba_uint */
  21566.    NULL  /* fetch_rgba_sint */
  21567. };
  21568.  
  21569. const struct util_format_description
  21570. util_format_r64_float_description = {
  21571.    PIPE_FORMAT_R64_FLOAT,
  21572.    "PIPE_FORMAT_R64_FLOAT",
  21573.    "r64_float",
  21574.    {1, 1, 64},  /* block */
  21575.    UTIL_FORMAT_LAYOUT_PLAIN,
  21576.    1,   /* nr_channels */
  21577.    TRUE,        /* is_array */
  21578.    FALSE,       /* is_bitmask */
  21579.    FALSE,       /* is_mixed */
  21580.    {
  21581.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0},    /* x = r */
  21582.       {0, 0, 0, 0, 0},
  21583.       {0, 0, 0, 0, 0},
  21584.       {0, 0, 0, 0, 0}
  21585.    },
  21586.    {
  21587.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21588.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  21589.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21590.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21591.    },
  21592.    UTIL_FORMAT_COLORSPACE_RGB,
  21593.    &util_format_r64_float_unpack_rgba_8unorm,
  21594.    &util_format_r64_float_pack_rgba_8unorm,
  21595.    NULL, /* fetch_rgba_8unorm */
  21596.    &util_format_r64_float_unpack_rgba_float,
  21597.    &util_format_r64_float_pack_rgba_float,
  21598.    &util_format_r64_float_fetch_rgba_float,
  21599.    NULL, /* unpack_z_32unorm */
  21600.    NULL, /* pack_z_32unorm */
  21601.    NULL, /* unpack_z_float */
  21602.    NULL, /* pack_z_float */
  21603.    NULL, /* unpack_s_8uint */
  21604.    NULL, /* pack_s_8uint */
  21605.    NULL, /* unpack_rgba_uint */
  21606.    NULL, /* pack_rgba_uint */
  21607.    NULL, /* unpack_rgba_sint */
  21608.    NULL, /* pack_rgba_sint */
  21609.    NULL, /* fetch_rgba_uint */
  21610.    NULL  /* fetch_rgba_sint */
  21611. };
  21612.  
  21613. const struct util_format_description
  21614. util_format_r64g64_float_description = {
  21615.    PIPE_FORMAT_R64G64_FLOAT,
  21616.    "PIPE_FORMAT_R64G64_FLOAT",
  21617.    "r64g64_float",
  21618.    {1, 1, 128}, /* block */
  21619.    UTIL_FORMAT_LAYOUT_PLAIN,
  21620.    2,   /* nr_channels */
  21621.    TRUE,        /* is_array */
  21622.    FALSE,       /* is_bitmask */
  21623.    FALSE,       /* is_mixed */
  21624.    {
  21625.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0},    /* x = r */
  21626.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64},   /* y = g */
  21627.       {0, 0, 0, 0, 0},
  21628.       {0, 0, 0, 0, 0}
  21629.    },
  21630.    {
  21631.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21632.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21633.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21634.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21635.    },
  21636.    UTIL_FORMAT_COLORSPACE_RGB,
  21637.    &util_format_r64g64_float_unpack_rgba_8unorm,
  21638.    &util_format_r64g64_float_pack_rgba_8unorm,
  21639.    NULL, /* fetch_rgba_8unorm */
  21640.    &util_format_r64g64_float_unpack_rgba_float,
  21641.    &util_format_r64g64_float_pack_rgba_float,
  21642.    &util_format_r64g64_float_fetch_rgba_float,
  21643.    NULL, /* unpack_z_32unorm */
  21644.    NULL, /* pack_z_32unorm */
  21645.    NULL, /* unpack_z_float */
  21646.    NULL, /* pack_z_float */
  21647.    NULL, /* unpack_s_8uint */
  21648.    NULL, /* pack_s_8uint */
  21649.    NULL, /* unpack_rgba_uint */
  21650.    NULL, /* pack_rgba_uint */
  21651.    NULL, /* unpack_rgba_sint */
  21652.    NULL, /* pack_rgba_sint */
  21653.    NULL, /* fetch_rgba_uint */
  21654.    NULL  /* fetch_rgba_sint */
  21655. };
  21656.  
  21657. const struct util_format_description
  21658. util_format_r64g64b64_float_description = {
  21659.    PIPE_FORMAT_R64G64B64_FLOAT,
  21660.    "PIPE_FORMAT_R64G64B64_FLOAT",
  21661.    "r64g64b64_float",
  21662.    {1, 1, 192}, /* block */
  21663.    UTIL_FORMAT_LAYOUT_PLAIN,
  21664.    3,   /* nr_channels */
  21665.    TRUE,        /* is_array */
  21666.    FALSE,       /* is_bitmask */
  21667.    FALSE,       /* is_mixed */
  21668.    {
  21669.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0},    /* x = r */
  21670.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64},   /* y = g */
  21671.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128},  /* z = b */
  21672.       {0, 0, 0, 0, 0}
  21673.    },
  21674.    {
  21675.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21676.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21677.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21678.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21679.    },
  21680.    UTIL_FORMAT_COLORSPACE_RGB,
  21681.    &util_format_r64g64b64_float_unpack_rgba_8unorm,
  21682.    &util_format_r64g64b64_float_pack_rgba_8unorm,
  21683.    NULL, /* fetch_rgba_8unorm */
  21684.    &util_format_r64g64b64_float_unpack_rgba_float,
  21685.    &util_format_r64g64b64_float_pack_rgba_float,
  21686.    &util_format_r64g64b64_float_fetch_rgba_float,
  21687.    NULL, /* unpack_z_32unorm */
  21688.    NULL, /* pack_z_32unorm */
  21689.    NULL, /* unpack_z_float */
  21690.    NULL, /* pack_z_float */
  21691.    NULL, /* unpack_s_8uint */
  21692.    NULL, /* pack_s_8uint */
  21693.    NULL, /* unpack_rgba_uint */
  21694.    NULL, /* pack_rgba_uint */
  21695.    NULL, /* unpack_rgba_sint */
  21696.    NULL, /* pack_rgba_sint */
  21697.    NULL, /* fetch_rgba_uint */
  21698.    NULL  /* fetch_rgba_sint */
  21699. };
  21700.  
  21701. const struct util_format_description
  21702. util_format_r64g64b64a64_float_description = {
  21703.    PIPE_FORMAT_R64G64B64A64_FLOAT,
  21704.    "PIPE_FORMAT_R64G64B64A64_FLOAT",
  21705.    "r64g64b64a64_float",
  21706.    {1, 1, 256}, /* block */
  21707.    UTIL_FORMAT_LAYOUT_PLAIN,
  21708.    4,   /* nr_channels */
  21709.    TRUE,        /* is_array */
  21710.    FALSE,       /* is_bitmask */
  21711.    FALSE,       /* is_mixed */
  21712.    {
  21713.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0},    /* x = r */
  21714.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64},   /* y = g */
  21715.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128},  /* z = b */
  21716.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 192}   /* w = a */
  21717.    },
  21718.    {
  21719.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21720.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21721.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21722.       UTIL_FORMAT_SWIZZLE_W     /* a */
  21723.    },
  21724.    UTIL_FORMAT_COLORSPACE_RGB,
  21725.    &util_format_r64g64b64a64_float_unpack_rgba_8unorm,
  21726.    &util_format_r64g64b64a64_float_pack_rgba_8unorm,
  21727.    NULL, /* fetch_rgba_8unorm */
  21728.    &util_format_r64g64b64a64_float_unpack_rgba_float,
  21729.    &util_format_r64g64b64a64_float_pack_rgba_float,
  21730.    &util_format_r64g64b64a64_float_fetch_rgba_float,
  21731.    NULL, /* unpack_z_32unorm */
  21732.    NULL, /* pack_z_32unorm */
  21733.    NULL, /* unpack_z_float */
  21734.    NULL, /* pack_z_float */
  21735.    NULL, /* unpack_s_8uint */
  21736.    NULL, /* pack_s_8uint */
  21737.    NULL, /* unpack_rgba_uint */
  21738.    NULL, /* pack_rgba_uint */
  21739.    NULL, /* unpack_rgba_sint */
  21740.    NULL, /* pack_rgba_sint */
  21741.    NULL, /* fetch_rgba_uint */
  21742.    NULL  /* fetch_rgba_sint */
  21743. };
  21744.  
  21745. const struct util_format_description
  21746. util_format_r32_float_description = {
  21747.    PIPE_FORMAT_R32_FLOAT,
  21748.    "PIPE_FORMAT_R32_FLOAT",
  21749.    "r32_float",
  21750.    {1, 1, 32},  /* block */
  21751.    UTIL_FORMAT_LAYOUT_PLAIN,
  21752.    1,   /* nr_channels */
  21753.    TRUE,        /* is_array */
  21754.    FALSE,       /* is_bitmask */
  21755.    FALSE,       /* is_mixed */
  21756.    {
  21757.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  21758.       {0, 0, 0, 0, 0},
  21759.       {0, 0, 0, 0, 0},
  21760.       {0, 0, 0, 0, 0}
  21761.    },
  21762.    {
  21763.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21764.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  21765.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21766.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21767.    },
  21768.    UTIL_FORMAT_COLORSPACE_RGB,
  21769.    &util_format_r32_float_unpack_rgba_8unorm,
  21770.    &util_format_r32_float_pack_rgba_8unorm,
  21771.    NULL, /* fetch_rgba_8unorm */
  21772.    &util_format_r32_float_unpack_rgba_float,
  21773.    &util_format_r32_float_pack_rgba_float,
  21774.    &util_format_r32_float_fetch_rgba_float,
  21775.    NULL, /* unpack_z_32unorm */
  21776.    NULL, /* pack_z_32unorm */
  21777.    NULL, /* unpack_z_float */
  21778.    NULL, /* pack_z_float */
  21779.    NULL, /* unpack_s_8uint */
  21780.    NULL, /* pack_s_8uint */
  21781.    NULL, /* unpack_rgba_uint */
  21782.    NULL, /* pack_rgba_uint */
  21783.    NULL, /* unpack_rgba_sint */
  21784.    NULL, /* pack_rgba_sint */
  21785.    NULL, /* fetch_rgba_uint */
  21786.    NULL  /* fetch_rgba_sint */
  21787. };
  21788.  
  21789. const struct util_format_description
  21790. util_format_r32g32_float_description = {
  21791.    PIPE_FORMAT_R32G32_FLOAT,
  21792.    "PIPE_FORMAT_R32G32_FLOAT",
  21793.    "r32g32_float",
  21794.    {1, 1, 64},  /* block */
  21795.    UTIL_FORMAT_LAYOUT_PLAIN,
  21796.    2,   /* nr_channels */
  21797.    TRUE,        /* is_array */
  21798.    FALSE,       /* is_bitmask */
  21799.    FALSE,       /* is_mixed */
  21800.    {
  21801.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  21802.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = g */
  21803.       {0, 0, 0, 0, 0},
  21804.       {0, 0, 0, 0, 0}
  21805.    },
  21806.    {
  21807.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21808.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21809.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21810.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21811.    },
  21812.    UTIL_FORMAT_COLORSPACE_RGB,
  21813.    &util_format_r32g32_float_unpack_rgba_8unorm,
  21814.    &util_format_r32g32_float_pack_rgba_8unorm,
  21815.    NULL, /* fetch_rgba_8unorm */
  21816.    &util_format_r32g32_float_unpack_rgba_float,
  21817.    &util_format_r32g32_float_pack_rgba_float,
  21818.    &util_format_r32g32_float_fetch_rgba_float,
  21819.    NULL, /* unpack_z_32unorm */
  21820.    NULL, /* pack_z_32unorm */
  21821.    NULL, /* unpack_z_float */
  21822.    NULL, /* pack_z_float */
  21823.    NULL, /* unpack_s_8uint */
  21824.    NULL, /* pack_s_8uint */
  21825.    NULL, /* unpack_rgba_uint */
  21826.    NULL, /* pack_rgba_uint */
  21827.    NULL, /* unpack_rgba_sint */
  21828.    NULL, /* pack_rgba_sint */
  21829.    NULL, /* fetch_rgba_uint */
  21830.    NULL  /* fetch_rgba_sint */
  21831. };
  21832.  
  21833. const struct util_format_description
  21834. util_format_r32g32b32_float_description = {
  21835.    PIPE_FORMAT_R32G32B32_FLOAT,
  21836.    "PIPE_FORMAT_R32G32B32_FLOAT",
  21837.    "r32g32b32_float",
  21838.    {1, 1, 96},  /* block */
  21839.    UTIL_FORMAT_LAYOUT_PLAIN,
  21840.    3,   /* nr_channels */
  21841.    TRUE,        /* is_array */
  21842.    FALSE,       /* is_bitmask */
  21843.    FALSE,       /* is_mixed */
  21844.    {
  21845.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  21846.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = g */
  21847.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64},   /* z = b */
  21848.       {0, 0, 0, 0, 0}
  21849.    },
  21850.    {
  21851.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21852.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21853.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21854.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21855.    },
  21856.    UTIL_FORMAT_COLORSPACE_RGB,
  21857.    &util_format_r32g32b32_float_unpack_rgba_8unorm,
  21858.    &util_format_r32g32b32_float_pack_rgba_8unorm,
  21859.    NULL, /* fetch_rgba_8unorm */
  21860.    &util_format_r32g32b32_float_unpack_rgba_float,
  21861.    &util_format_r32g32b32_float_pack_rgba_float,
  21862.    &util_format_r32g32b32_float_fetch_rgba_float,
  21863.    NULL, /* unpack_z_32unorm */
  21864.    NULL, /* pack_z_32unorm */
  21865.    NULL, /* unpack_z_float */
  21866.    NULL, /* pack_z_float */
  21867.    NULL, /* unpack_s_8uint */
  21868.    NULL, /* pack_s_8uint */
  21869.    NULL, /* unpack_rgba_uint */
  21870.    NULL, /* pack_rgba_uint */
  21871.    NULL, /* unpack_rgba_sint */
  21872.    NULL, /* pack_rgba_sint */
  21873.    NULL, /* fetch_rgba_uint */
  21874.    NULL  /* fetch_rgba_sint */
  21875. };
  21876.  
  21877. const struct util_format_description
  21878. util_format_r32g32b32a32_float_description = {
  21879.    PIPE_FORMAT_R32G32B32A32_FLOAT,
  21880.    "PIPE_FORMAT_R32G32B32A32_FLOAT",
  21881.    "r32g32b32a32_float",
  21882.    {1, 1, 128}, /* block */
  21883.    UTIL_FORMAT_LAYOUT_PLAIN,
  21884.    4,   /* nr_channels */
  21885.    TRUE,        /* is_array */
  21886.    FALSE,       /* is_bitmask */
  21887.    FALSE,       /* is_mixed */
  21888.    {
  21889.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  21890.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = g */
  21891.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64},   /* z = b */
  21892.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 96}    /* w = a */
  21893.    },
  21894.    {
  21895.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21896.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21897.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  21898.       UTIL_FORMAT_SWIZZLE_W     /* a */
  21899.    },
  21900.    UTIL_FORMAT_COLORSPACE_RGB,
  21901.    &util_format_r32g32b32a32_float_unpack_rgba_8unorm,
  21902.    &util_format_r32g32b32a32_float_pack_rgba_8unorm,
  21903.    NULL, /* fetch_rgba_8unorm */
  21904.    &util_format_r32g32b32a32_float_unpack_rgba_float,
  21905.    &util_format_r32g32b32a32_float_pack_rgba_float,
  21906.    &util_format_r32g32b32a32_float_fetch_rgba_float,
  21907.    NULL, /* unpack_z_32unorm */
  21908.    NULL, /* pack_z_32unorm */
  21909.    NULL, /* unpack_z_float */
  21910.    NULL, /* pack_z_float */
  21911.    NULL, /* unpack_s_8uint */
  21912.    NULL, /* pack_s_8uint */
  21913.    NULL, /* unpack_rgba_uint */
  21914.    NULL, /* pack_rgba_uint */
  21915.    NULL, /* unpack_rgba_sint */
  21916.    NULL, /* pack_rgba_sint */
  21917.    NULL, /* fetch_rgba_uint */
  21918.    NULL  /* fetch_rgba_sint */
  21919. };
  21920.  
  21921. const struct util_format_description
  21922. util_format_r32_unorm_description = {
  21923.    PIPE_FORMAT_R32_UNORM,
  21924.    "PIPE_FORMAT_R32_UNORM",
  21925.    "r32_unorm",
  21926.    {1, 1, 32},  /* block */
  21927.    UTIL_FORMAT_LAYOUT_PLAIN,
  21928.    1,   /* nr_channels */
  21929.    TRUE,        /* is_array */
  21930.    TRUE,        /* is_bitmask */
  21931.    FALSE,       /* is_mixed */
  21932.    {
  21933.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0},  /* x = r */
  21934.       {0, 0, 0, 0, 0},
  21935.       {0, 0, 0, 0, 0},
  21936.       {0, 0, 0, 0, 0}
  21937.    },
  21938.    {
  21939.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21940.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  21941.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21942.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21943.    },
  21944.    UTIL_FORMAT_COLORSPACE_RGB,
  21945.    &util_format_r32_unorm_unpack_rgba_8unorm,
  21946.    &util_format_r32_unorm_pack_rgba_8unorm,
  21947.    NULL, /* fetch_rgba_8unorm */
  21948.    &util_format_r32_unorm_unpack_rgba_float,
  21949.    &util_format_r32_unorm_pack_rgba_float,
  21950.    &util_format_r32_unorm_fetch_rgba_float,
  21951.    NULL, /* unpack_z_32unorm */
  21952.    NULL, /* pack_z_32unorm */
  21953.    NULL, /* unpack_z_float */
  21954.    NULL, /* pack_z_float */
  21955.    NULL, /* unpack_s_8uint */
  21956.    NULL, /* pack_s_8uint */
  21957.    NULL, /* unpack_rgba_uint */
  21958.    NULL, /* pack_rgba_uint */
  21959.    NULL, /* unpack_rgba_sint */
  21960.    NULL, /* pack_rgba_sint */
  21961.    NULL, /* fetch_rgba_uint */
  21962.    NULL  /* fetch_rgba_sint */
  21963. };
  21964.  
  21965. const struct util_format_description
  21966. util_format_r32g32_unorm_description = {
  21967.    PIPE_FORMAT_R32G32_UNORM,
  21968.    "PIPE_FORMAT_R32G32_UNORM",
  21969.    "r32g32_unorm",
  21970.    {1, 1, 64},  /* block */
  21971.    UTIL_FORMAT_LAYOUT_PLAIN,
  21972.    2,   /* nr_channels */
  21973.    TRUE,        /* is_array */
  21974.    FALSE,       /* is_bitmask */
  21975.    FALSE,       /* is_mixed */
  21976.    {
  21977.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0},  /* x = r */
  21978.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
  21979.       {0, 0, 0, 0, 0},
  21980.       {0, 0, 0, 0, 0}
  21981.    },
  21982.    {
  21983.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  21984.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  21985.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  21986.       UTIL_FORMAT_SWIZZLE_1     /* a */
  21987.    },
  21988.    UTIL_FORMAT_COLORSPACE_RGB,
  21989.    &util_format_r32g32_unorm_unpack_rgba_8unorm,
  21990.    &util_format_r32g32_unorm_pack_rgba_8unorm,
  21991.    NULL, /* fetch_rgba_8unorm */
  21992.    &util_format_r32g32_unorm_unpack_rgba_float,
  21993.    &util_format_r32g32_unorm_pack_rgba_float,
  21994.    &util_format_r32g32_unorm_fetch_rgba_float,
  21995.    NULL, /* unpack_z_32unorm */
  21996.    NULL, /* pack_z_32unorm */
  21997.    NULL, /* unpack_z_float */
  21998.    NULL, /* pack_z_float */
  21999.    NULL, /* unpack_s_8uint */
  22000.    NULL, /* pack_s_8uint */
  22001.    NULL, /* unpack_rgba_uint */
  22002.    NULL, /* pack_rgba_uint */
  22003.    NULL, /* unpack_rgba_sint */
  22004.    NULL, /* pack_rgba_sint */
  22005.    NULL, /* fetch_rgba_uint */
  22006.    NULL  /* fetch_rgba_sint */
  22007. };
  22008.  
  22009. const struct util_format_description
  22010. util_format_r32g32b32_unorm_description = {
  22011.    PIPE_FORMAT_R32G32B32_UNORM,
  22012.    "PIPE_FORMAT_R32G32B32_UNORM",
  22013.    "r32g32b32_unorm",
  22014.    {1, 1, 96},  /* block */
  22015.    UTIL_FORMAT_LAYOUT_PLAIN,
  22016.    3,   /* nr_channels */
  22017.    TRUE,        /* is_array */
  22018.    FALSE,       /* is_bitmask */
  22019.    FALSE,       /* is_mixed */
  22020.    {
  22021.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0},  /* x = r */
  22022.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
  22023.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */
  22024.       {0, 0, 0, 0, 0}
  22025.    },
  22026.    {
  22027.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22028.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22029.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22030.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22031.    },
  22032.    UTIL_FORMAT_COLORSPACE_RGB,
  22033.    &util_format_r32g32b32_unorm_unpack_rgba_8unorm,
  22034.    &util_format_r32g32b32_unorm_pack_rgba_8unorm,
  22035.    NULL, /* fetch_rgba_8unorm */
  22036.    &util_format_r32g32b32_unorm_unpack_rgba_float,
  22037.    &util_format_r32g32b32_unorm_pack_rgba_float,
  22038.    &util_format_r32g32b32_unorm_fetch_rgba_float,
  22039.    NULL, /* unpack_z_32unorm */
  22040.    NULL, /* pack_z_32unorm */
  22041.    NULL, /* unpack_z_float */
  22042.    NULL, /* pack_z_float */
  22043.    NULL, /* unpack_s_8uint */
  22044.    NULL, /* pack_s_8uint */
  22045.    NULL, /* unpack_rgba_uint */
  22046.    NULL, /* pack_rgba_uint */
  22047.    NULL, /* unpack_rgba_sint */
  22048.    NULL, /* pack_rgba_sint */
  22049.    NULL, /* fetch_rgba_uint */
  22050.    NULL  /* fetch_rgba_sint */
  22051. };
  22052.  
  22053. const struct util_format_description
  22054. util_format_r32g32b32a32_unorm_description = {
  22055.    PIPE_FORMAT_R32G32B32A32_UNORM,
  22056.    "PIPE_FORMAT_R32G32B32A32_UNORM",
  22057.    "r32g32b32a32_unorm",
  22058.    {1, 1, 128}, /* block */
  22059.    UTIL_FORMAT_LAYOUT_PLAIN,
  22060.    4,   /* nr_channels */
  22061.    TRUE,        /* is_array */
  22062.    FALSE,       /* is_bitmask */
  22063.    FALSE,       /* is_mixed */
  22064.    {
  22065.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0},  /* x = r */
  22066.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */
  22067.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */
  22068.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 96}  /* w = a */
  22069.    },
  22070.    {
  22071.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22072.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22073.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22074.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22075.    },
  22076.    UTIL_FORMAT_COLORSPACE_RGB,
  22077.    &util_format_r32g32b32a32_unorm_unpack_rgba_8unorm,
  22078.    &util_format_r32g32b32a32_unorm_pack_rgba_8unorm,
  22079.    NULL, /* fetch_rgba_8unorm */
  22080.    &util_format_r32g32b32a32_unorm_unpack_rgba_float,
  22081.    &util_format_r32g32b32a32_unorm_pack_rgba_float,
  22082.    &util_format_r32g32b32a32_unorm_fetch_rgba_float,
  22083.    NULL, /* unpack_z_32unorm */
  22084.    NULL, /* pack_z_32unorm */
  22085.    NULL, /* unpack_z_float */
  22086.    NULL, /* pack_z_float */
  22087.    NULL, /* unpack_s_8uint */
  22088.    NULL, /* pack_s_8uint */
  22089.    NULL, /* unpack_rgba_uint */
  22090.    NULL, /* pack_rgba_uint */
  22091.    NULL, /* unpack_rgba_sint */
  22092.    NULL, /* pack_rgba_sint */
  22093.    NULL, /* fetch_rgba_uint */
  22094.    NULL  /* fetch_rgba_sint */
  22095. };
  22096.  
  22097. const struct util_format_description
  22098. util_format_r32_uscaled_description = {
  22099.    PIPE_FORMAT_R32_USCALED,
  22100.    "PIPE_FORMAT_R32_USCALED",
  22101.    "r32_uscaled",
  22102.    {1, 1, 32},  /* block */
  22103.    UTIL_FORMAT_LAYOUT_PLAIN,
  22104.    1,   /* nr_channels */
  22105.    TRUE,        /* is_array */
  22106.    TRUE,        /* is_bitmask */
  22107.    FALSE,       /* is_mixed */
  22108.    {
  22109.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
  22110.       {0, 0, 0, 0, 0},
  22111.       {0, 0, 0, 0, 0},
  22112.       {0, 0, 0, 0, 0}
  22113.    },
  22114.    {
  22115.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22116.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22117.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22118.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22119.    },
  22120.    UTIL_FORMAT_COLORSPACE_RGB,
  22121.    &util_format_r32_uscaled_unpack_rgba_8unorm,
  22122.    &util_format_r32_uscaled_pack_rgba_8unorm,
  22123.    NULL, /* fetch_rgba_8unorm */
  22124.    &util_format_r32_uscaled_unpack_rgba_float,
  22125.    &util_format_r32_uscaled_pack_rgba_float,
  22126.    &util_format_r32_uscaled_fetch_rgba_float,
  22127.    NULL, /* unpack_z_32unorm */
  22128.    NULL, /* pack_z_32unorm */
  22129.    NULL, /* unpack_z_float */
  22130.    NULL, /* pack_z_float */
  22131.    NULL, /* unpack_s_8uint */
  22132.    NULL, /* pack_s_8uint */
  22133.    NULL, /* unpack_rgba_uint */
  22134.    NULL, /* pack_rgba_uint */
  22135.    NULL, /* unpack_rgba_sint */
  22136.    NULL, /* pack_rgba_sint */
  22137.    NULL, /* fetch_rgba_uint */
  22138.    NULL  /* fetch_rgba_sint */
  22139. };
  22140.  
  22141. const struct util_format_description
  22142. util_format_r32g32_uscaled_description = {
  22143.    PIPE_FORMAT_R32G32_USCALED,
  22144.    "PIPE_FORMAT_R32G32_USCALED",
  22145.    "r32g32_uscaled",
  22146.    {1, 1, 64},  /* block */
  22147.    UTIL_FORMAT_LAYOUT_PLAIN,
  22148.    2,   /* nr_channels */
  22149.    TRUE,        /* is_array */
  22150.    FALSE,       /* is_bitmask */
  22151.    FALSE,       /* is_mixed */
  22152.    {
  22153.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
  22154.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32},        /* y = g */
  22155.       {0, 0, 0, 0, 0},
  22156.       {0, 0, 0, 0, 0}
  22157.    },
  22158.    {
  22159.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22160.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22161.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22162.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22163.    },
  22164.    UTIL_FORMAT_COLORSPACE_RGB,
  22165.    &util_format_r32g32_uscaled_unpack_rgba_8unorm,
  22166.    &util_format_r32g32_uscaled_pack_rgba_8unorm,
  22167.    NULL, /* fetch_rgba_8unorm */
  22168.    &util_format_r32g32_uscaled_unpack_rgba_float,
  22169.    &util_format_r32g32_uscaled_pack_rgba_float,
  22170.    &util_format_r32g32_uscaled_fetch_rgba_float,
  22171.    NULL, /* unpack_z_32unorm */
  22172.    NULL, /* pack_z_32unorm */
  22173.    NULL, /* unpack_z_float */
  22174.    NULL, /* pack_z_float */
  22175.    NULL, /* unpack_s_8uint */
  22176.    NULL, /* pack_s_8uint */
  22177.    NULL, /* unpack_rgba_uint */
  22178.    NULL, /* pack_rgba_uint */
  22179.    NULL, /* unpack_rgba_sint */
  22180.    NULL, /* pack_rgba_sint */
  22181.    NULL, /* fetch_rgba_uint */
  22182.    NULL  /* fetch_rgba_sint */
  22183. };
  22184.  
  22185. const struct util_format_description
  22186. util_format_r32g32b32_uscaled_description = {
  22187.    PIPE_FORMAT_R32G32B32_USCALED,
  22188.    "PIPE_FORMAT_R32G32B32_USCALED",
  22189.    "r32g32b32_uscaled",
  22190.    {1, 1, 96},  /* block */
  22191.    UTIL_FORMAT_LAYOUT_PLAIN,
  22192.    3,   /* nr_channels */
  22193.    TRUE,        /* is_array */
  22194.    FALSE,       /* is_bitmask */
  22195.    FALSE,       /* is_mixed */
  22196.    {
  22197.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
  22198.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32},        /* y = g */
  22199.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64},        /* z = b */
  22200.       {0, 0, 0, 0, 0}
  22201.    },
  22202.    {
  22203.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22204.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22205.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22206.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22207.    },
  22208.    UTIL_FORMAT_COLORSPACE_RGB,
  22209.    &util_format_r32g32b32_uscaled_unpack_rgba_8unorm,
  22210.    &util_format_r32g32b32_uscaled_pack_rgba_8unorm,
  22211.    NULL, /* fetch_rgba_8unorm */
  22212.    &util_format_r32g32b32_uscaled_unpack_rgba_float,
  22213.    &util_format_r32g32b32_uscaled_pack_rgba_float,
  22214.    &util_format_r32g32b32_uscaled_fetch_rgba_float,
  22215.    NULL, /* unpack_z_32unorm */
  22216.    NULL, /* pack_z_32unorm */
  22217.    NULL, /* unpack_z_float */
  22218.    NULL, /* pack_z_float */
  22219.    NULL, /* unpack_s_8uint */
  22220.    NULL, /* pack_s_8uint */
  22221.    NULL, /* unpack_rgba_uint */
  22222.    NULL, /* pack_rgba_uint */
  22223.    NULL, /* unpack_rgba_sint */
  22224.    NULL, /* pack_rgba_sint */
  22225.    NULL, /* fetch_rgba_uint */
  22226.    NULL  /* fetch_rgba_sint */
  22227. };
  22228.  
  22229. const struct util_format_description
  22230. util_format_r32g32b32a32_uscaled_description = {
  22231.    PIPE_FORMAT_R32G32B32A32_USCALED,
  22232.    "PIPE_FORMAT_R32G32B32A32_USCALED",
  22233.    "r32g32b32a32_uscaled",
  22234.    {1, 1, 128}, /* block */
  22235.    UTIL_FORMAT_LAYOUT_PLAIN,
  22236.    4,   /* nr_channels */
  22237.    TRUE,        /* is_array */
  22238.    FALSE,       /* is_bitmask */
  22239.    FALSE,       /* is_mixed */
  22240.    {
  22241.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */
  22242.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32},        /* y = g */
  22243.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64},        /* z = b */
  22244.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 96} /* w = a */
  22245.    },
  22246.    {
  22247.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22248.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22249.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22250.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22251.    },
  22252.    UTIL_FORMAT_COLORSPACE_RGB,
  22253.    &util_format_r32g32b32a32_uscaled_unpack_rgba_8unorm,
  22254.    &util_format_r32g32b32a32_uscaled_pack_rgba_8unorm,
  22255.    NULL, /* fetch_rgba_8unorm */
  22256.    &util_format_r32g32b32a32_uscaled_unpack_rgba_float,
  22257.    &util_format_r32g32b32a32_uscaled_pack_rgba_float,
  22258.    &util_format_r32g32b32a32_uscaled_fetch_rgba_float,
  22259.    NULL, /* unpack_z_32unorm */
  22260.    NULL, /* pack_z_32unorm */
  22261.    NULL, /* unpack_z_float */
  22262.    NULL, /* pack_z_float */
  22263.    NULL, /* unpack_s_8uint */
  22264.    NULL, /* pack_s_8uint */
  22265.    NULL, /* unpack_rgba_uint */
  22266.    NULL, /* pack_rgba_uint */
  22267.    NULL, /* unpack_rgba_sint */
  22268.    NULL, /* pack_rgba_sint */
  22269.    NULL, /* fetch_rgba_uint */
  22270.    NULL  /* fetch_rgba_sint */
  22271. };
  22272.  
  22273. const struct util_format_description
  22274. util_format_r32_snorm_description = {
  22275.    PIPE_FORMAT_R32_SNORM,
  22276.    "PIPE_FORMAT_R32_SNORM",
  22277.    "r32_snorm",
  22278.    {1, 1, 32},  /* block */
  22279.    UTIL_FORMAT_LAYOUT_PLAIN,
  22280.    1,   /* nr_channels */
  22281.    TRUE,        /* is_array */
  22282.    TRUE,        /* is_bitmask */
  22283.    FALSE,       /* is_mixed */
  22284.    {
  22285.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0},    /* x = r */
  22286.       {0, 0, 0, 0, 0},
  22287.       {0, 0, 0, 0, 0},
  22288.       {0, 0, 0, 0, 0}
  22289.    },
  22290.    {
  22291.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22292.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22293.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22294.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22295.    },
  22296.    UTIL_FORMAT_COLORSPACE_RGB,
  22297.    &util_format_r32_snorm_unpack_rgba_8unorm,
  22298.    &util_format_r32_snorm_pack_rgba_8unorm,
  22299.    NULL, /* fetch_rgba_8unorm */
  22300.    &util_format_r32_snorm_unpack_rgba_float,
  22301.    &util_format_r32_snorm_pack_rgba_float,
  22302.    &util_format_r32_snorm_fetch_rgba_float,
  22303.    NULL, /* unpack_z_32unorm */
  22304.    NULL, /* pack_z_32unorm */
  22305.    NULL, /* unpack_z_float */
  22306.    NULL, /* pack_z_float */
  22307.    NULL, /* unpack_s_8uint */
  22308.    NULL, /* pack_s_8uint */
  22309.    NULL, /* unpack_rgba_uint */
  22310.    NULL, /* pack_rgba_uint */
  22311.    NULL, /* unpack_rgba_sint */
  22312.    NULL, /* pack_rgba_sint */
  22313.    NULL, /* fetch_rgba_uint */
  22314.    NULL  /* fetch_rgba_sint */
  22315. };
  22316.  
  22317. const struct util_format_description
  22318. util_format_r32g32_snorm_description = {
  22319.    PIPE_FORMAT_R32G32_SNORM,
  22320.    "PIPE_FORMAT_R32G32_SNORM",
  22321.    "r32g32_snorm",
  22322.    {1, 1, 64},  /* block */
  22323.    UTIL_FORMAT_LAYOUT_PLAIN,
  22324.    2,   /* nr_channels */
  22325.    TRUE,        /* is_array */
  22326.    FALSE,       /* is_bitmask */
  22327.    FALSE,       /* is_mixed */
  22328.    {
  22329.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0},    /* x = r */
  22330.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32},   /* y = g */
  22331.       {0, 0, 0, 0, 0},
  22332.       {0, 0, 0, 0, 0}
  22333.    },
  22334.    {
  22335.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22336.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22337.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22338.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22339.    },
  22340.    UTIL_FORMAT_COLORSPACE_RGB,
  22341.    &util_format_r32g32_snorm_unpack_rgba_8unorm,
  22342.    &util_format_r32g32_snorm_pack_rgba_8unorm,
  22343.    NULL, /* fetch_rgba_8unorm */
  22344.    &util_format_r32g32_snorm_unpack_rgba_float,
  22345.    &util_format_r32g32_snorm_pack_rgba_float,
  22346.    &util_format_r32g32_snorm_fetch_rgba_float,
  22347.    NULL, /* unpack_z_32unorm */
  22348.    NULL, /* pack_z_32unorm */
  22349.    NULL, /* unpack_z_float */
  22350.    NULL, /* pack_z_float */
  22351.    NULL, /* unpack_s_8uint */
  22352.    NULL, /* pack_s_8uint */
  22353.    NULL, /* unpack_rgba_uint */
  22354.    NULL, /* pack_rgba_uint */
  22355.    NULL, /* unpack_rgba_sint */
  22356.    NULL, /* pack_rgba_sint */
  22357.    NULL, /* fetch_rgba_uint */
  22358.    NULL  /* fetch_rgba_sint */
  22359. };
  22360.  
  22361. const struct util_format_description
  22362. util_format_r32g32b32_snorm_description = {
  22363.    PIPE_FORMAT_R32G32B32_SNORM,
  22364.    "PIPE_FORMAT_R32G32B32_SNORM",
  22365.    "r32g32b32_snorm",
  22366.    {1, 1, 96},  /* block */
  22367.    UTIL_FORMAT_LAYOUT_PLAIN,
  22368.    3,   /* nr_channels */
  22369.    TRUE,        /* is_array */
  22370.    FALSE,       /* is_bitmask */
  22371.    FALSE,       /* is_mixed */
  22372.    {
  22373.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0},    /* x = r */
  22374.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32},   /* y = g */
  22375.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64},   /* z = b */
  22376.       {0, 0, 0, 0, 0}
  22377.    },
  22378.    {
  22379.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22380.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22381.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22382.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22383.    },
  22384.    UTIL_FORMAT_COLORSPACE_RGB,
  22385.    &util_format_r32g32b32_snorm_unpack_rgba_8unorm,
  22386.    &util_format_r32g32b32_snorm_pack_rgba_8unorm,
  22387.    NULL, /* fetch_rgba_8unorm */
  22388.    &util_format_r32g32b32_snorm_unpack_rgba_float,
  22389.    &util_format_r32g32b32_snorm_pack_rgba_float,
  22390.    &util_format_r32g32b32_snorm_fetch_rgba_float,
  22391.    NULL, /* unpack_z_32unorm */
  22392.    NULL, /* pack_z_32unorm */
  22393.    NULL, /* unpack_z_float */
  22394.    NULL, /* pack_z_float */
  22395.    NULL, /* unpack_s_8uint */
  22396.    NULL, /* pack_s_8uint */
  22397.    NULL, /* unpack_rgba_uint */
  22398.    NULL, /* pack_rgba_uint */
  22399.    NULL, /* unpack_rgba_sint */
  22400.    NULL, /* pack_rgba_sint */
  22401.    NULL, /* fetch_rgba_uint */
  22402.    NULL  /* fetch_rgba_sint */
  22403. };
  22404.  
  22405. const struct util_format_description
  22406. util_format_r32g32b32a32_snorm_description = {
  22407.    PIPE_FORMAT_R32G32B32A32_SNORM,
  22408.    "PIPE_FORMAT_R32G32B32A32_SNORM",
  22409.    "r32g32b32a32_snorm",
  22410.    {1, 1, 128}, /* block */
  22411.    UTIL_FORMAT_LAYOUT_PLAIN,
  22412.    4,   /* nr_channels */
  22413.    TRUE,        /* is_array */
  22414.    FALSE,       /* is_bitmask */
  22415.    FALSE,       /* is_mixed */
  22416.    {
  22417.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0},    /* x = r */
  22418.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32},   /* y = g */
  22419.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64},   /* z = b */
  22420.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 96}    /* w = a */
  22421.    },
  22422.    {
  22423.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22424.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22425.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22426.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22427.    },
  22428.    UTIL_FORMAT_COLORSPACE_RGB,
  22429.    &util_format_r32g32b32a32_snorm_unpack_rgba_8unorm,
  22430.    &util_format_r32g32b32a32_snorm_pack_rgba_8unorm,
  22431.    NULL, /* fetch_rgba_8unorm */
  22432.    &util_format_r32g32b32a32_snorm_unpack_rgba_float,
  22433.    &util_format_r32g32b32a32_snorm_pack_rgba_float,
  22434.    &util_format_r32g32b32a32_snorm_fetch_rgba_float,
  22435.    NULL, /* unpack_z_32unorm */
  22436.    NULL, /* pack_z_32unorm */
  22437.    NULL, /* unpack_z_float */
  22438.    NULL, /* pack_z_float */
  22439.    NULL, /* unpack_s_8uint */
  22440.    NULL, /* pack_s_8uint */
  22441.    NULL, /* unpack_rgba_uint */
  22442.    NULL, /* pack_rgba_uint */
  22443.    NULL, /* unpack_rgba_sint */
  22444.    NULL, /* pack_rgba_sint */
  22445.    NULL, /* fetch_rgba_uint */
  22446.    NULL  /* fetch_rgba_sint */
  22447. };
  22448.  
  22449. const struct util_format_description
  22450. util_format_r32_sscaled_description = {
  22451.    PIPE_FORMAT_R32_SSCALED,
  22452.    "PIPE_FORMAT_R32_SSCALED",
  22453.    "r32_sscaled",
  22454.    {1, 1, 32},  /* block */
  22455.    UTIL_FORMAT_LAYOUT_PLAIN,
  22456.    1,   /* nr_channels */
  22457.    TRUE,        /* is_array */
  22458.    TRUE,        /* is_bitmask */
  22459.    FALSE,       /* is_mixed */
  22460.    {
  22461.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0},   /* x = r */
  22462.       {0, 0, 0, 0, 0},
  22463.       {0, 0, 0, 0, 0},
  22464.       {0, 0, 0, 0, 0}
  22465.    },
  22466.    {
  22467.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22468.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22469.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22470.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22471.    },
  22472.    UTIL_FORMAT_COLORSPACE_RGB,
  22473.    &util_format_r32_sscaled_unpack_rgba_8unorm,
  22474.    &util_format_r32_sscaled_pack_rgba_8unorm,
  22475.    NULL, /* fetch_rgba_8unorm */
  22476.    &util_format_r32_sscaled_unpack_rgba_float,
  22477.    &util_format_r32_sscaled_pack_rgba_float,
  22478.    &util_format_r32_sscaled_fetch_rgba_float,
  22479.    NULL, /* unpack_z_32unorm */
  22480.    NULL, /* pack_z_32unorm */
  22481.    NULL, /* unpack_z_float */
  22482.    NULL, /* pack_z_float */
  22483.    NULL, /* unpack_s_8uint */
  22484.    NULL, /* pack_s_8uint */
  22485.    NULL, /* unpack_rgba_uint */
  22486.    NULL, /* pack_rgba_uint */
  22487.    NULL, /* unpack_rgba_sint */
  22488.    NULL, /* pack_rgba_sint */
  22489.    NULL, /* fetch_rgba_uint */
  22490.    NULL  /* fetch_rgba_sint */
  22491. };
  22492.  
  22493. const struct util_format_description
  22494. util_format_r32g32_sscaled_description = {
  22495.    PIPE_FORMAT_R32G32_SSCALED,
  22496.    "PIPE_FORMAT_R32G32_SSCALED",
  22497.    "r32g32_sscaled",
  22498.    {1, 1, 64},  /* block */
  22499.    UTIL_FORMAT_LAYOUT_PLAIN,
  22500.    2,   /* nr_channels */
  22501.    TRUE,        /* is_array */
  22502.    FALSE,       /* is_bitmask */
  22503.    FALSE,       /* is_mixed */
  22504.    {
  22505.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0},   /* x = r */
  22506.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32},  /* y = g */
  22507.       {0, 0, 0, 0, 0},
  22508.       {0, 0, 0, 0, 0}
  22509.    },
  22510.    {
  22511.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22512.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22513.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22514.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22515.    },
  22516.    UTIL_FORMAT_COLORSPACE_RGB,
  22517.    &util_format_r32g32_sscaled_unpack_rgba_8unorm,
  22518.    &util_format_r32g32_sscaled_pack_rgba_8unorm,
  22519.    NULL, /* fetch_rgba_8unorm */
  22520.    &util_format_r32g32_sscaled_unpack_rgba_float,
  22521.    &util_format_r32g32_sscaled_pack_rgba_float,
  22522.    &util_format_r32g32_sscaled_fetch_rgba_float,
  22523.    NULL, /* unpack_z_32unorm */
  22524.    NULL, /* pack_z_32unorm */
  22525.    NULL, /* unpack_z_float */
  22526.    NULL, /* pack_z_float */
  22527.    NULL, /* unpack_s_8uint */
  22528.    NULL, /* pack_s_8uint */
  22529.    NULL, /* unpack_rgba_uint */
  22530.    NULL, /* pack_rgba_uint */
  22531.    NULL, /* unpack_rgba_sint */
  22532.    NULL, /* pack_rgba_sint */
  22533.    NULL, /* fetch_rgba_uint */
  22534.    NULL  /* fetch_rgba_sint */
  22535. };
  22536.  
  22537. const struct util_format_description
  22538. util_format_r32g32b32_sscaled_description = {
  22539.    PIPE_FORMAT_R32G32B32_SSCALED,
  22540.    "PIPE_FORMAT_R32G32B32_SSCALED",
  22541.    "r32g32b32_sscaled",
  22542.    {1, 1, 96},  /* block */
  22543.    UTIL_FORMAT_LAYOUT_PLAIN,
  22544.    3,   /* nr_channels */
  22545.    TRUE,        /* is_array */
  22546.    FALSE,       /* is_bitmask */
  22547.    FALSE,       /* is_mixed */
  22548.    {
  22549.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0},   /* x = r */
  22550.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32},  /* y = g */
  22551.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64},  /* z = b */
  22552.       {0, 0, 0, 0, 0}
  22553.    },
  22554.    {
  22555.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22556.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22557.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22558.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22559.    },
  22560.    UTIL_FORMAT_COLORSPACE_RGB,
  22561.    &util_format_r32g32b32_sscaled_unpack_rgba_8unorm,
  22562.    &util_format_r32g32b32_sscaled_pack_rgba_8unorm,
  22563.    NULL, /* fetch_rgba_8unorm */
  22564.    &util_format_r32g32b32_sscaled_unpack_rgba_float,
  22565.    &util_format_r32g32b32_sscaled_pack_rgba_float,
  22566.    &util_format_r32g32b32_sscaled_fetch_rgba_float,
  22567.    NULL, /* unpack_z_32unorm */
  22568.    NULL, /* pack_z_32unorm */
  22569.    NULL, /* unpack_z_float */
  22570.    NULL, /* pack_z_float */
  22571.    NULL, /* unpack_s_8uint */
  22572.    NULL, /* pack_s_8uint */
  22573.    NULL, /* unpack_rgba_uint */
  22574.    NULL, /* pack_rgba_uint */
  22575.    NULL, /* unpack_rgba_sint */
  22576.    NULL, /* pack_rgba_sint */
  22577.    NULL, /* fetch_rgba_uint */
  22578.    NULL  /* fetch_rgba_sint */
  22579. };
  22580.  
  22581. const struct util_format_description
  22582. util_format_r32g32b32a32_sscaled_description = {
  22583.    PIPE_FORMAT_R32G32B32A32_SSCALED,
  22584.    "PIPE_FORMAT_R32G32B32A32_SSCALED",
  22585.    "r32g32b32a32_sscaled",
  22586.    {1, 1, 128}, /* block */
  22587.    UTIL_FORMAT_LAYOUT_PLAIN,
  22588.    4,   /* nr_channels */
  22589.    TRUE,        /* is_array */
  22590.    FALSE,       /* is_bitmask */
  22591.    FALSE,       /* is_mixed */
  22592.    {
  22593.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0},   /* x = r */
  22594.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32},  /* y = g */
  22595.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64},  /* z = b */
  22596.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 96}   /* w = a */
  22597.    },
  22598.    {
  22599.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22600.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22601.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22602.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22603.    },
  22604.    UTIL_FORMAT_COLORSPACE_RGB,
  22605.    &util_format_r32g32b32a32_sscaled_unpack_rgba_8unorm,
  22606.    &util_format_r32g32b32a32_sscaled_pack_rgba_8unorm,
  22607.    NULL, /* fetch_rgba_8unorm */
  22608.    &util_format_r32g32b32a32_sscaled_unpack_rgba_float,
  22609.    &util_format_r32g32b32a32_sscaled_pack_rgba_float,
  22610.    &util_format_r32g32b32a32_sscaled_fetch_rgba_float,
  22611.    NULL, /* unpack_z_32unorm */
  22612.    NULL, /* pack_z_32unorm */
  22613.    NULL, /* unpack_z_float */
  22614.    NULL, /* pack_z_float */
  22615.    NULL, /* unpack_s_8uint */
  22616.    NULL, /* pack_s_8uint */
  22617.    NULL, /* unpack_rgba_uint */
  22618.    NULL, /* pack_rgba_uint */
  22619.    NULL, /* unpack_rgba_sint */
  22620.    NULL, /* pack_rgba_sint */
  22621.    NULL, /* fetch_rgba_uint */
  22622.    NULL  /* fetch_rgba_sint */
  22623. };
  22624.  
  22625. const struct util_format_description
  22626. util_format_r16_float_description = {
  22627.    PIPE_FORMAT_R16_FLOAT,
  22628.    "PIPE_FORMAT_R16_FLOAT",
  22629.    "r16_float",
  22630.    {1, 1, 16},  /* block */
  22631.    UTIL_FORMAT_LAYOUT_PLAIN,
  22632.    1,   /* nr_channels */
  22633.    TRUE,        /* is_array */
  22634.    FALSE,       /* is_bitmask */
  22635.    FALSE,       /* is_mixed */
  22636.    {
  22637.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  22638.       {0, 0, 0, 0, 0},
  22639.       {0, 0, 0, 0, 0},
  22640.       {0, 0, 0, 0, 0}
  22641.    },
  22642.    {
  22643.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22644.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22645.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22646.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22647.    },
  22648.    UTIL_FORMAT_COLORSPACE_RGB,
  22649.    &util_format_r16_float_unpack_rgba_8unorm,
  22650.    &util_format_r16_float_pack_rgba_8unorm,
  22651.    NULL, /* fetch_rgba_8unorm */
  22652.    &util_format_r16_float_unpack_rgba_float,
  22653.    &util_format_r16_float_pack_rgba_float,
  22654.    &util_format_r16_float_fetch_rgba_float,
  22655.    NULL, /* unpack_z_32unorm */
  22656.    NULL, /* pack_z_32unorm */
  22657.    NULL, /* unpack_z_float */
  22658.    NULL, /* pack_z_float */
  22659.    NULL, /* unpack_s_8uint */
  22660.    NULL, /* pack_s_8uint */
  22661.    NULL, /* unpack_rgba_uint */
  22662.    NULL, /* pack_rgba_uint */
  22663.    NULL, /* unpack_rgba_sint */
  22664.    NULL, /* pack_rgba_sint */
  22665.    NULL, /* fetch_rgba_uint */
  22666.    NULL  /* fetch_rgba_sint */
  22667. };
  22668.  
  22669. const struct util_format_description
  22670. util_format_r16g16_float_description = {
  22671.    PIPE_FORMAT_R16G16_FLOAT,
  22672.    "PIPE_FORMAT_R16G16_FLOAT",
  22673.    "r16g16_float",
  22674.    {1, 1, 32},  /* block */
  22675.    UTIL_FORMAT_LAYOUT_PLAIN,
  22676.    2,   /* nr_channels */
  22677.    TRUE,        /* is_array */
  22678.    FALSE,       /* is_bitmask */
  22679.    FALSE,       /* is_mixed */
  22680.    {
  22681.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  22682.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = g */
  22683.       {0, 0, 0, 0, 0},
  22684.       {0, 0, 0, 0, 0}
  22685.    },
  22686.    {
  22687.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22688.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22689.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22690.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22691.    },
  22692.    UTIL_FORMAT_COLORSPACE_RGB,
  22693.    &util_format_r16g16_float_unpack_rgba_8unorm,
  22694.    &util_format_r16g16_float_pack_rgba_8unorm,
  22695.    NULL, /* fetch_rgba_8unorm */
  22696.    &util_format_r16g16_float_unpack_rgba_float,
  22697.    &util_format_r16g16_float_pack_rgba_float,
  22698.    &util_format_r16g16_float_fetch_rgba_float,
  22699.    NULL, /* unpack_z_32unorm */
  22700.    NULL, /* pack_z_32unorm */
  22701.    NULL, /* unpack_z_float */
  22702.    NULL, /* pack_z_float */
  22703.    NULL, /* unpack_s_8uint */
  22704.    NULL, /* pack_s_8uint */
  22705.    NULL, /* unpack_rgba_uint */
  22706.    NULL, /* pack_rgba_uint */
  22707.    NULL, /* unpack_rgba_sint */
  22708.    NULL, /* pack_rgba_sint */
  22709.    NULL, /* fetch_rgba_uint */
  22710.    NULL  /* fetch_rgba_sint */
  22711. };
  22712.  
  22713. const struct util_format_description
  22714. util_format_r16g16b16_float_description = {
  22715.    PIPE_FORMAT_R16G16B16_FLOAT,
  22716.    "PIPE_FORMAT_R16G16B16_FLOAT",
  22717.    "r16g16b16_float",
  22718.    {1, 1, 48},  /* block */
  22719.    UTIL_FORMAT_LAYOUT_PLAIN,
  22720.    3,   /* nr_channels */
  22721.    TRUE,        /* is_array */
  22722.    FALSE,       /* is_bitmask */
  22723.    FALSE,       /* is_mixed */
  22724.    {
  22725.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  22726.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = g */
  22727.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32},   /* z = b */
  22728.       {0, 0, 0, 0, 0}
  22729.    },
  22730.    {
  22731.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22732.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22733.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22734.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22735.    },
  22736.    UTIL_FORMAT_COLORSPACE_RGB,
  22737.    &util_format_r16g16b16_float_unpack_rgba_8unorm,
  22738.    &util_format_r16g16b16_float_pack_rgba_8unorm,
  22739.    NULL, /* fetch_rgba_8unorm */
  22740.    &util_format_r16g16b16_float_unpack_rgba_float,
  22741.    &util_format_r16g16b16_float_pack_rgba_float,
  22742.    &util_format_r16g16b16_float_fetch_rgba_float,
  22743.    NULL, /* unpack_z_32unorm */
  22744.    NULL, /* pack_z_32unorm */
  22745.    NULL, /* unpack_z_float */
  22746.    NULL, /* pack_z_float */
  22747.    NULL, /* unpack_s_8uint */
  22748.    NULL, /* pack_s_8uint */
  22749.    NULL, /* unpack_rgba_uint */
  22750.    NULL, /* pack_rgba_uint */
  22751.    NULL, /* unpack_rgba_sint */
  22752.    NULL, /* pack_rgba_sint */
  22753.    NULL, /* fetch_rgba_uint */
  22754.    NULL  /* fetch_rgba_sint */
  22755. };
  22756.  
  22757. const struct util_format_description
  22758. util_format_r16g16b16a16_float_description = {
  22759.    PIPE_FORMAT_R16G16B16A16_FLOAT,
  22760.    "PIPE_FORMAT_R16G16B16A16_FLOAT",
  22761.    "r16g16b16a16_float",
  22762.    {1, 1, 64},  /* block */
  22763.    UTIL_FORMAT_LAYOUT_PLAIN,
  22764.    4,   /* nr_channels */
  22765.    TRUE,        /* is_array */
  22766.    FALSE,       /* is_bitmask */
  22767.    FALSE,       /* is_mixed */
  22768.    {
  22769.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  22770.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = g */
  22771.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32},   /* z = b */
  22772.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 48}    /* w = a */
  22773.    },
  22774.    {
  22775.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22776.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22777.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22778.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22779.    },
  22780.    UTIL_FORMAT_COLORSPACE_RGB,
  22781.    &util_format_r16g16b16a16_float_unpack_rgba_8unorm,
  22782.    &util_format_r16g16b16a16_float_pack_rgba_8unorm,
  22783.    NULL, /* fetch_rgba_8unorm */
  22784.    &util_format_r16g16b16a16_float_unpack_rgba_float,
  22785.    &util_format_r16g16b16a16_float_pack_rgba_float,
  22786.    &util_format_r16g16b16a16_float_fetch_rgba_float,
  22787.    NULL, /* unpack_z_32unorm */
  22788.    NULL, /* pack_z_32unorm */
  22789.    NULL, /* unpack_z_float */
  22790.    NULL, /* pack_z_float */
  22791.    NULL, /* unpack_s_8uint */
  22792.    NULL, /* pack_s_8uint */
  22793.    NULL, /* unpack_rgba_uint */
  22794.    NULL, /* pack_rgba_uint */
  22795.    NULL, /* unpack_rgba_sint */
  22796.    NULL, /* pack_rgba_sint */
  22797.    NULL, /* fetch_rgba_uint */
  22798.    NULL  /* fetch_rgba_sint */
  22799. };
  22800.  
  22801. const struct util_format_description
  22802. util_format_r16_unorm_description = {
  22803.    PIPE_FORMAT_R16_UNORM,
  22804.    "PIPE_FORMAT_R16_UNORM",
  22805.    "r16_unorm",
  22806.    {1, 1, 16},  /* block */
  22807.    UTIL_FORMAT_LAYOUT_PLAIN,
  22808.    1,   /* nr_channels */
  22809.    TRUE,        /* is_array */
  22810.    TRUE,        /* is_bitmask */
  22811.    FALSE,       /* is_mixed */
  22812.    {
  22813.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  22814.       {0, 0, 0, 0, 0},
  22815.       {0, 0, 0, 0, 0},
  22816.       {0, 0, 0, 0, 0}
  22817.    },
  22818.    {
  22819.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22820.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22821.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22822.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22823.    },
  22824.    UTIL_FORMAT_COLORSPACE_RGB,
  22825.    &util_format_r16_unorm_unpack_rgba_8unorm,
  22826.    &util_format_r16_unorm_pack_rgba_8unorm,
  22827.    NULL, /* fetch_rgba_8unorm */
  22828.    &util_format_r16_unorm_unpack_rgba_float,
  22829.    &util_format_r16_unorm_pack_rgba_float,
  22830.    &util_format_r16_unorm_fetch_rgba_float,
  22831.    NULL, /* unpack_z_32unorm */
  22832.    NULL, /* pack_z_32unorm */
  22833.    NULL, /* unpack_z_float */
  22834.    NULL, /* pack_z_float */
  22835.    NULL, /* unpack_s_8uint */
  22836.    NULL, /* pack_s_8uint */
  22837.    NULL, /* unpack_rgba_uint */
  22838.    NULL, /* pack_rgba_uint */
  22839.    NULL, /* unpack_rgba_sint */
  22840.    NULL, /* pack_rgba_sint */
  22841.    NULL, /* fetch_rgba_uint */
  22842.    NULL  /* fetch_rgba_sint */
  22843. };
  22844.  
  22845. const struct util_format_description
  22846. util_format_r16g16_unorm_description = {
  22847.    PIPE_FORMAT_R16G16_UNORM,
  22848.    "PIPE_FORMAT_R16G16_UNORM",
  22849.    "r16g16_unorm",
  22850.    {1, 1, 32},  /* block */
  22851.    UTIL_FORMAT_LAYOUT_PLAIN,
  22852.    2,   /* nr_channels */
  22853.    TRUE,        /* is_array */
  22854.    TRUE,        /* is_bitmask */
  22855.    FALSE,       /* is_mixed */
  22856.    {
  22857.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  22858.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
  22859.       {0, 0, 0, 0, 0},
  22860.       {0, 0, 0, 0, 0}
  22861.    },
  22862.    {
  22863.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22864.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22865.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22866.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22867.    },
  22868.    UTIL_FORMAT_COLORSPACE_RGB,
  22869.    &util_format_r16g16_unorm_unpack_rgba_8unorm,
  22870.    &util_format_r16g16_unorm_pack_rgba_8unorm,
  22871.    NULL, /* fetch_rgba_8unorm */
  22872.    &util_format_r16g16_unorm_unpack_rgba_float,
  22873.    &util_format_r16g16_unorm_pack_rgba_float,
  22874.    &util_format_r16g16_unorm_fetch_rgba_float,
  22875.    NULL, /* unpack_z_32unorm */
  22876.    NULL, /* pack_z_32unorm */
  22877.    NULL, /* unpack_z_float */
  22878.    NULL, /* pack_z_float */
  22879.    NULL, /* unpack_s_8uint */
  22880.    NULL, /* pack_s_8uint */
  22881.    NULL, /* unpack_rgba_uint */
  22882.    NULL, /* pack_rgba_uint */
  22883.    NULL, /* unpack_rgba_sint */
  22884.    NULL, /* pack_rgba_sint */
  22885.    NULL, /* fetch_rgba_uint */
  22886.    NULL  /* fetch_rgba_sint */
  22887. };
  22888.  
  22889. const struct util_format_description
  22890. util_format_r16g16b16_unorm_description = {
  22891.    PIPE_FORMAT_R16G16B16_UNORM,
  22892.    "PIPE_FORMAT_R16G16B16_UNORM",
  22893.    "r16g16b16_unorm",
  22894.    {1, 1, 48},  /* block */
  22895.    UTIL_FORMAT_LAYOUT_PLAIN,
  22896.    3,   /* nr_channels */
  22897.    TRUE,        /* is_array */
  22898.    FALSE,       /* is_bitmask */
  22899.    FALSE,       /* is_mixed */
  22900.    {
  22901.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  22902.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
  22903.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
  22904.       {0, 0, 0, 0, 0}
  22905.    },
  22906.    {
  22907.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22908.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22909.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22910.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22911.    },
  22912.    UTIL_FORMAT_COLORSPACE_RGB,
  22913.    &util_format_r16g16b16_unorm_unpack_rgba_8unorm,
  22914.    &util_format_r16g16b16_unorm_pack_rgba_8unorm,
  22915.    NULL, /* fetch_rgba_8unorm */
  22916.    &util_format_r16g16b16_unorm_unpack_rgba_float,
  22917.    &util_format_r16g16b16_unorm_pack_rgba_float,
  22918.    &util_format_r16g16b16_unorm_fetch_rgba_float,
  22919.    NULL, /* unpack_z_32unorm */
  22920.    NULL, /* pack_z_32unorm */
  22921.    NULL, /* unpack_z_float */
  22922.    NULL, /* pack_z_float */
  22923.    NULL, /* unpack_s_8uint */
  22924.    NULL, /* pack_s_8uint */
  22925.    NULL, /* unpack_rgba_uint */
  22926.    NULL, /* pack_rgba_uint */
  22927.    NULL, /* unpack_rgba_sint */
  22928.    NULL, /* pack_rgba_sint */
  22929.    NULL, /* fetch_rgba_uint */
  22930.    NULL  /* fetch_rgba_sint */
  22931. };
  22932.  
  22933. const struct util_format_description
  22934. util_format_r16g16b16a16_unorm_description = {
  22935.    PIPE_FORMAT_R16G16B16A16_UNORM,
  22936.    "PIPE_FORMAT_R16G16B16A16_UNORM",
  22937.    "r16g16b16a16_unorm",
  22938.    {1, 1, 64},  /* block */
  22939.    UTIL_FORMAT_LAYOUT_PLAIN,
  22940.    4,   /* nr_channels */
  22941.    TRUE,        /* is_array */
  22942.    FALSE,       /* is_bitmask */
  22943.    FALSE,       /* is_mixed */
  22944.    {
  22945.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  22946.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
  22947.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
  22948.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 48}  /* w = a */
  22949.    },
  22950.    {
  22951.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22952.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  22953.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  22954.       UTIL_FORMAT_SWIZZLE_W     /* a */
  22955.    },
  22956.    UTIL_FORMAT_COLORSPACE_RGB,
  22957.    &util_format_r16g16b16a16_unorm_unpack_rgba_8unorm,
  22958.    &util_format_r16g16b16a16_unorm_pack_rgba_8unorm,
  22959.    NULL, /* fetch_rgba_8unorm */
  22960.    &util_format_r16g16b16a16_unorm_unpack_rgba_float,
  22961.    &util_format_r16g16b16a16_unorm_pack_rgba_float,
  22962.    &util_format_r16g16b16a16_unorm_fetch_rgba_float,
  22963.    NULL, /* unpack_z_32unorm */
  22964.    NULL, /* pack_z_32unorm */
  22965.    NULL, /* unpack_z_float */
  22966.    NULL, /* pack_z_float */
  22967.    NULL, /* unpack_s_8uint */
  22968.    NULL, /* pack_s_8uint */
  22969.    NULL, /* unpack_rgba_uint */
  22970.    NULL, /* pack_rgba_uint */
  22971.    NULL, /* unpack_rgba_sint */
  22972.    NULL, /* pack_rgba_sint */
  22973.    NULL, /* fetch_rgba_uint */
  22974.    NULL  /* fetch_rgba_sint */
  22975. };
  22976.  
  22977. const struct util_format_description
  22978. util_format_r16_uscaled_description = {
  22979.    PIPE_FORMAT_R16_USCALED,
  22980.    "PIPE_FORMAT_R16_USCALED",
  22981.    "r16_uscaled",
  22982.    {1, 1, 16},  /* block */
  22983.    UTIL_FORMAT_LAYOUT_PLAIN,
  22984.    1,   /* nr_channels */
  22985.    TRUE,        /* is_array */
  22986.    TRUE,        /* is_bitmask */
  22987.    FALSE,       /* is_mixed */
  22988.    {
  22989.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
  22990.       {0, 0, 0, 0, 0},
  22991.       {0, 0, 0, 0, 0},
  22992.       {0, 0, 0, 0, 0}
  22993.    },
  22994.    {
  22995.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  22996.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  22997.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  22998.       UTIL_FORMAT_SWIZZLE_1     /* a */
  22999.    },
  23000.    UTIL_FORMAT_COLORSPACE_RGB,
  23001.    &util_format_r16_uscaled_unpack_rgba_8unorm,
  23002.    &util_format_r16_uscaled_pack_rgba_8unorm,
  23003.    NULL, /* fetch_rgba_8unorm */
  23004.    &util_format_r16_uscaled_unpack_rgba_float,
  23005.    &util_format_r16_uscaled_pack_rgba_float,
  23006.    &util_format_r16_uscaled_fetch_rgba_float,
  23007.    NULL, /* unpack_z_32unorm */
  23008.    NULL, /* pack_z_32unorm */
  23009.    NULL, /* unpack_z_float */
  23010.    NULL, /* pack_z_float */
  23011.    NULL, /* unpack_s_8uint */
  23012.    NULL, /* pack_s_8uint */
  23013.    NULL, /* unpack_rgba_uint */
  23014.    NULL, /* pack_rgba_uint */
  23015.    NULL, /* unpack_rgba_sint */
  23016.    NULL, /* pack_rgba_sint */
  23017.    NULL, /* fetch_rgba_uint */
  23018.    NULL  /* fetch_rgba_sint */
  23019. };
  23020.  
  23021. const struct util_format_description
  23022. util_format_r16g16_uscaled_description = {
  23023.    PIPE_FORMAT_R16G16_USCALED,
  23024.    "PIPE_FORMAT_R16G16_USCALED",
  23025.    "r16g16_uscaled",
  23026.    {1, 1, 32},  /* block */
  23027.    UTIL_FORMAT_LAYOUT_PLAIN,
  23028.    2,   /* nr_channels */
  23029.    TRUE,        /* is_array */
  23030.    TRUE,        /* is_bitmask */
  23031.    FALSE,       /* is_mixed */
  23032.    {
  23033.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
  23034.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16},        /* y = g */
  23035.       {0, 0, 0, 0, 0},
  23036.       {0, 0, 0, 0, 0}
  23037.    },
  23038.    {
  23039.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23040.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23041.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23042.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23043.    },
  23044.    UTIL_FORMAT_COLORSPACE_RGB,
  23045.    &util_format_r16g16_uscaled_unpack_rgba_8unorm,
  23046.    &util_format_r16g16_uscaled_pack_rgba_8unorm,
  23047.    NULL, /* fetch_rgba_8unorm */
  23048.    &util_format_r16g16_uscaled_unpack_rgba_float,
  23049.    &util_format_r16g16_uscaled_pack_rgba_float,
  23050.    &util_format_r16g16_uscaled_fetch_rgba_float,
  23051.    NULL, /* unpack_z_32unorm */
  23052.    NULL, /* pack_z_32unorm */
  23053.    NULL, /* unpack_z_float */
  23054.    NULL, /* pack_z_float */
  23055.    NULL, /* unpack_s_8uint */
  23056.    NULL, /* pack_s_8uint */
  23057.    NULL, /* unpack_rgba_uint */
  23058.    NULL, /* pack_rgba_uint */
  23059.    NULL, /* unpack_rgba_sint */
  23060.    NULL, /* pack_rgba_sint */
  23061.    NULL, /* fetch_rgba_uint */
  23062.    NULL  /* fetch_rgba_sint */
  23063. };
  23064.  
  23065. const struct util_format_description
  23066. util_format_r16g16b16_uscaled_description = {
  23067.    PIPE_FORMAT_R16G16B16_USCALED,
  23068.    "PIPE_FORMAT_R16G16B16_USCALED",
  23069.    "r16g16b16_uscaled",
  23070.    {1, 1, 48},  /* block */
  23071.    UTIL_FORMAT_LAYOUT_PLAIN,
  23072.    3,   /* nr_channels */
  23073.    TRUE,        /* is_array */
  23074.    FALSE,       /* is_bitmask */
  23075.    FALSE,       /* is_mixed */
  23076.    {
  23077.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
  23078.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16},        /* y = g */
  23079.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32},        /* z = b */
  23080.       {0, 0, 0, 0, 0}
  23081.    },
  23082.    {
  23083.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23084.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23085.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23086.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23087.    },
  23088.    UTIL_FORMAT_COLORSPACE_RGB,
  23089.    &util_format_r16g16b16_uscaled_unpack_rgba_8unorm,
  23090.    &util_format_r16g16b16_uscaled_pack_rgba_8unorm,
  23091.    NULL, /* fetch_rgba_8unorm */
  23092.    &util_format_r16g16b16_uscaled_unpack_rgba_float,
  23093.    &util_format_r16g16b16_uscaled_pack_rgba_float,
  23094.    &util_format_r16g16b16_uscaled_fetch_rgba_float,
  23095.    NULL, /* unpack_z_32unorm */
  23096.    NULL, /* pack_z_32unorm */
  23097.    NULL, /* unpack_z_float */
  23098.    NULL, /* pack_z_float */
  23099.    NULL, /* unpack_s_8uint */
  23100.    NULL, /* pack_s_8uint */
  23101.    NULL, /* unpack_rgba_uint */
  23102.    NULL, /* pack_rgba_uint */
  23103.    NULL, /* unpack_rgba_sint */
  23104.    NULL, /* pack_rgba_sint */
  23105.    NULL, /* fetch_rgba_uint */
  23106.    NULL  /* fetch_rgba_sint */
  23107. };
  23108.  
  23109. const struct util_format_description
  23110. util_format_r16g16b16a16_uscaled_description = {
  23111.    PIPE_FORMAT_R16G16B16A16_USCALED,
  23112.    "PIPE_FORMAT_R16G16B16A16_USCALED",
  23113.    "r16g16b16a16_uscaled",
  23114.    {1, 1, 64},  /* block */
  23115.    UTIL_FORMAT_LAYOUT_PLAIN,
  23116.    4,   /* nr_channels */
  23117.    TRUE,        /* is_array */
  23118.    FALSE,       /* is_bitmask */
  23119.    FALSE,       /* is_mixed */
  23120.    {
  23121.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */
  23122.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16},        /* y = g */
  23123.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32},        /* z = b */
  23124.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 48} /* w = a */
  23125.    },
  23126.    {
  23127.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23128.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23129.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23130.       UTIL_FORMAT_SWIZZLE_W     /* a */
  23131.    },
  23132.    UTIL_FORMAT_COLORSPACE_RGB,
  23133.    &util_format_r16g16b16a16_uscaled_unpack_rgba_8unorm,
  23134.    &util_format_r16g16b16a16_uscaled_pack_rgba_8unorm,
  23135.    NULL, /* fetch_rgba_8unorm */
  23136.    &util_format_r16g16b16a16_uscaled_unpack_rgba_float,
  23137.    &util_format_r16g16b16a16_uscaled_pack_rgba_float,
  23138.    &util_format_r16g16b16a16_uscaled_fetch_rgba_float,
  23139.    NULL, /* unpack_z_32unorm */
  23140.    NULL, /* pack_z_32unorm */
  23141.    NULL, /* unpack_z_float */
  23142.    NULL, /* pack_z_float */
  23143.    NULL, /* unpack_s_8uint */
  23144.    NULL, /* pack_s_8uint */
  23145.    NULL, /* unpack_rgba_uint */
  23146.    NULL, /* pack_rgba_uint */
  23147.    NULL, /* unpack_rgba_sint */
  23148.    NULL, /* pack_rgba_sint */
  23149.    NULL, /* fetch_rgba_uint */
  23150.    NULL  /* fetch_rgba_sint */
  23151. };
  23152.  
  23153. const struct util_format_description
  23154. util_format_r16_snorm_description = {
  23155.    PIPE_FORMAT_R16_SNORM,
  23156.    "PIPE_FORMAT_R16_SNORM",
  23157.    "r16_snorm",
  23158.    {1, 1, 16},  /* block */
  23159.    UTIL_FORMAT_LAYOUT_PLAIN,
  23160.    1,   /* nr_channels */
  23161.    TRUE,        /* is_array */
  23162.    TRUE,        /* is_bitmask */
  23163.    FALSE,       /* is_mixed */
  23164.    {
  23165.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  23166.       {0, 0, 0, 0, 0},
  23167.       {0, 0, 0, 0, 0},
  23168.       {0, 0, 0, 0, 0}
  23169.    },
  23170.    {
  23171.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23172.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  23173.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23174.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23175.    },
  23176.    UTIL_FORMAT_COLORSPACE_RGB,
  23177.    &util_format_r16_snorm_unpack_rgba_8unorm,
  23178.    &util_format_r16_snorm_pack_rgba_8unorm,
  23179.    NULL, /* fetch_rgba_8unorm */
  23180.    &util_format_r16_snorm_unpack_rgba_float,
  23181.    &util_format_r16_snorm_pack_rgba_float,
  23182.    &util_format_r16_snorm_fetch_rgba_float,
  23183.    NULL, /* unpack_z_32unorm */
  23184.    NULL, /* pack_z_32unorm */
  23185.    NULL, /* unpack_z_float */
  23186.    NULL, /* pack_z_float */
  23187.    NULL, /* unpack_s_8uint */
  23188.    NULL, /* pack_s_8uint */
  23189.    NULL, /* unpack_rgba_uint */
  23190.    NULL, /* pack_rgba_uint */
  23191.    NULL, /* unpack_rgba_sint */
  23192.    NULL, /* pack_rgba_sint */
  23193.    NULL, /* fetch_rgba_uint */
  23194.    NULL  /* fetch_rgba_sint */
  23195. };
  23196.  
  23197. const struct util_format_description
  23198. util_format_r16g16_snorm_description = {
  23199.    PIPE_FORMAT_R16G16_SNORM,
  23200.    "PIPE_FORMAT_R16G16_SNORM",
  23201.    "r16g16_snorm",
  23202.    {1, 1, 32},  /* block */
  23203.    UTIL_FORMAT_LAYOUT_PLAIN,
  23204.    2,   /* nr_channels */
  23205.    TRUE,        /* is_array */
  23206.    TRUE,        /* is_bitmask */
  23207.    FALSE,       /* is_mixed */
  23208.    {
  23209.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  23210.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = g */
  23211.       {0, 0, 0, 0, 0},
  23212.       {0, 0, 0, 0, 0}
  23213.    },
  23214.    {
  23215.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23216.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23217.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23218.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23219.    },
  23220.    UTIL_FORMAT_COLORSPACE_RGB,
  23221.    &util_format_r16g16_snorm_unpack_rgba_8unorm,
  23222.    &util_format_r16g16_snorm_pack_rgba_8unorm,
  23223.    NULL, /* fetch_rgba_8unorm */
  23224.    &util_format_r16g16_snorm_unpack_rgba_float,
  23225.    &util_format_r16g16_snorm_pack_rgba_float,
  23226.    &util_format_r16g16_snorm_fetch_rgba_float,
  23227.    NULL, /* unpack_z_32unorm */
  23228.    NULL, /* pack_z_32unorm */
  23229.    NULL, /* unpack_z_float */
  23230.    NULL, /* pack_z_float */
  23231.    NULL, /* unpack_s_8uint */
  23232.    NULL, /* pack_s_8uint */
  23233.    NULL, /* unpack_rgba_uint */
  23234.    NULL, /* pack_rgba_uint */
  23235.    NULL, /* unpack_rgba_sint */
  23236.    NULL, /* pack_rgba_sint */
  23237.    NULL, /* fetch_rgba_uint */
  23238.    NULL  /* fetch_rgba_sint */
  23239. };
  23240.  
  23241. const struct util_format_description
  23242. util_format_r16g16b16_snorm_description = {
  23243.    PIPE_FORMAT_R16G16B16_SNORM,
  23244.    "PIPE_FORMAT_R16G16B16_SNORM",
  23245.    "r16g16b16_snorm",
  23246.    {1, 1, 48},  /* block */
  23247.    UTIL_FORMAT_LAYOUT_PLAIN,
  23248.    3,   /* nr_channels */
  23249.    TRUE,        /* is_array */
  23250.    FALSE,       /* is_bitmask */
  23251.    FALSE,       /* is_mixed */
  23252.    {
  23253.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  23254.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = g */
  23255.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32},   /* z = b */
  23256.       {0, 0, 0, 0, 0}
  23257.    },
  23258.    {
  23259.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23260.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23261.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23262.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23263.    },
  23264.    UTIL_FORMAT_COLORSPACE_RGB,
  23265.    &util_format_r16g16b16_snorm_unpack_rgba_8unorm,
  23266.    &util_format_r16g16b16_snorm_pack_rgba_8unorm,
  23267.    NULL, /* fetch_rgba_8unorm */
  23268.    &util_format_r16g16b16_snorm_unpack_rgba_float,
  23269.    &util_format_r16g16b16_snorm_pack_rgba_float,
  23270.    &util_format_r16g16b16_snorm_fetch_rgba_float,
  23271.    NULL, /* unpack_z_32unorm */
  23272.    NULL, /* pack_z_32unorm */
  23273.    NULL, /* unpack_z_float */
  23274.    NULL, /* pack_z_float */
  23275.    NULL, /* unpack_s_8uint */
  23276.    NULL, /* pack_s_8uint */
  23277.    NULL, /* unpack_rgba_uint */
  23278.    NULL, /* pack_rgba_uint */
  23279.    NULL, /* unpack_rgba_sint */
  23280.    NULL, /* pack_rgba_sint */
  23281.    NULL, /* fetch_rgba_uint */
  23282.    NULL  /* fetch_rgba_sint */
  23283. };
  23284.  
  23285. const struct util_format_description
  23286. util_format_r16g16b16a16_snorm_description = {
  23287.    PIPE_FORMAT_R16G16B16A16_SNORM,
  23288.    "PIPE_FORMAT_R16G16B16A16_SNORM",
  23289.    "r16g16b16a16_snorm",
  23290.    {1, 1, 64},  /* block */
  23291.    UTIL_FORMAT_LAYOUT_PLAIN,
  23292.    4,   /* nr_channels */
  23293.    TRUE,        /* is_array */
  23294.    FALSE,       /* is_bitmask */
  23295.    FALSE,       /* is_mixed */
  23296.    {
  23297.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  23298.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = g */
  23299.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32},   /* z = b */
  23300.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 48}    /* w = a */
  23301.    },
  23302.    {
  23303.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23304.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23305.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23306.       UTIL_FORMAT_SWIZZLE_W     /* a */
  23307.    },
  23308.    UTIL_FORMAT_COLORSPACE_RGB,
  23309.    &util_format_r16g16b16a16_snorm_unpack_rgba_8unorm,
  23310.    &util_format_r16g16b16a16_snorm_pack_rgba_8unorm,
  23311.    NULL, /* fetch_rgba_8unorm */
  23312.    &util_format_r16g16b16a16_snorm_unpack_rgba_float,
  23313.    &util_format_r16g16b16a16_snorm_pack_rgba_float,
  23314.    &util_format_r16g16b16a16_snorm_fetch_rgba_float,
  23315.    NULL, /* unpack_z_32unorm */
  23316.    NULL, /* pack_z_32unorm */
  23317.    NULL, /* unpack_z_float */
  23318.    NULL, /* pack_z_float */
  23319.    NULL, /* unpack_s_8uint */
  23320.    NULL, /* pack_s_8uint */
  23321.    NULL, /* unpack_rgba_uint */
  23322.    NULL, /* pack_rgba_uint */
  23323.    NULL, /* unpack_rgba_sint */
  23324.    NULL, /* pack_rgba_sint */
  23325.    NULL, /* fetch_rgba_uint */
  23326.    NULL  /* fetch_rgba_sint */
  23327. };
  23328.  
  23329. const struct util_format_description
  23330. util_format_r16_sscaled_description = {
  23331.    PIPE_FORMAT_R16_SSCALED,
  23332.    "PIPE_FORMAT_R16_SSCALED",
  23333.    "r16_sscaled",
  23334.    {1, 1, 16},  /* block */
  23335.    UTIL_FORMAT_LAYOUT_PLAIN,
  23336.    1,   /* nr_channels */
  23337.    TRUE,        /* is_array */
  23338.    TRUE,        /* is_bitmask */
  23339.    FALSE,       /* is_mixed */
  23340.    {
  23341.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0},   /* x = r */
  23342.       {0, 0, 0, 0, 0},
  23343.       {0, 0, 0, 0, 0},
  23344.       {0, 0, 0, 0, 0}
  23345.    },
  23346.    {
  23347.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23348.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  23349.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23350.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23351.    },
  23352.    UTIL_FORMAT_COLORSPACE_RGB,
  23353.    &util_format_r16_sscaled_unpack_rgba_8unorm,
  23354.    &util_format_r16_sscaled_pack_rgba_8unorm,
  23355.    NULL, /* fetch_rgba_8unorm */
  23356.    &util_format_r16_sscaled_unpack_rgba_float,
  23357.    &util_format_r16_sscaled_pack_rgba_float,
  23358.    &util_format_r16_sscaled_fetch_rgba_float,
  23359.    NULL, /* unpack_z_32unorm */
  23360.    NULL, /* pack_z_32unorm */
  23361.    NULL, /* unpack_z_float */
  23362.    NULL, /* pack_z_float */
  23363.    NULL, /* unpack_s_8uint */
  23364.    NULL, /* pack_s_8uint */
  23365.    NULL, /* unpack_rgba_uint */
  23366.    NULL, /* pack_rgba_uint */
  23367.    NULL, /* unpack_rgba_sint */
  23368.    NULL, /* pack_rgba_sint */
  23369.    NULL, /* fetch_rgba_uint */
  23370.    NULL  /* fetch_rgba_sint */
  23371. };
  23372.  
  23373. const struct util_format_description
  23374. util_format_r16g16_sscaled_description = {
  23375.    PIPE_FORMAT_R16G16_SSCALED,
  23376.    "PIPE_FORMAT_R16G16_SSCALED",
  23377.    "r16g16_sscaled",
  23378.    {1, 1, 32},  /* block */
  23379.    UTIL_FORMAT_LAYOUT_PLAIN,
  23380.    2,   /* nr_channels */
  23381.    TRUE,        /* is_array */
  23382.    TRUE,        /* is_bitmask */
  23383.    FALSE,       /* is_mixed */
  23384.    {
  23385.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0},   /* x = r */
  23386.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16},  /* y = g */
  23387.       {0, 0, 0, 0, 0},
  23388.       {0, 0, 0, 0, 0}
  23389.    },
  23390.    {
  23391.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23392.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23393.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23394.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23395.    },
  23396.    UTIL_FORMAT_COLORSPACE_RGB,
  23397.    &util_format_r16g16_sscaled_unpack_rgba_8unorm,
  23398.    &util_format_r16g16_sscaled_pack_rgba_8unorm,
  23399.    NULL, /* fetch_rgba_8unorm */
  23400.    &util_format_r16g16_sscaled_unpack_rgba_float,
  23401.    &util_format_r16g16_sscaled_pack_rgba_float,
  23402.    &util_format_r16g16_sscaled_fetch_rgba_float,
  23403.    NULL, /* unpack_z_32unorm */
  23404.    NULL, /* pack_z_32unorm */
  23405.    NULL, /* unpack_z_float */
  23406.    NULL, /* pack_z_float */
  23407.    NULL, /* unpack_s_8uint */
  23408.    NULL, /* pack_s_8uint */
  23409.    NULL, /* unpack_rgba_uint */
  23410.    NULL, /* pack_rgba_uint */
  23411.    NULL, /* unpack_rgba_sint */
  23412.    NULL, /* pack_rgba_sint */
  23413.    NULL, /* fetch_rgba_uint */
  23414.    NULL  /* fetch_rgba_sint */
  23415. };
  23416.  
  23417. const struct util_format_description
  23418. util_format_r16g16b16_sscaled_description = {
  23419.    PIPE_FORMAT_R16G16B16_SSCALED,
  23420.    "PIPE_FORMAT_R16G16B16_SSCALED",
  23421.    "r16g16b16_sscaled",
  23422.    {1, 1, 48},  /* block */
  23423.    UTIL_FORMAT_LAYOUT_PLAIN,
  23424.    3,   /* nr_channels */
  23425.    TRUE,        /* is_array */
  23426.    FALSE,       /* is_bitmask */
  23427.    FALSE,       /* is_mixed */
  23428.    {
  23429.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0},   /* x = r */
  23430.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16},  /* y = g */
  23431.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32},  /* z = b */
  23432.       {0, 0, 0, 0, 0}
  23433.    },
  23434.    {
  23435.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23436.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23437.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23438.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23439.    },
  23440.    UTIL_FORMAT_COLORSPACE_RGB,
  23441.    &util_format_r16g16b16_sscaled_unpack_rgba_8unorm,
  23442.    &util_format_r16g16b16_sscaled_pack_rgba_8unorm,
  23443.    NULL, /* fetch_rgba_8unorm */
  23444.    &util_format_r16g16b16_sscaled_unpack_rgba_float,
  23445.    &util_format_r16g16b16_sscaled_pack_rgba_float,
  23446.    &util_format_r16g16b16_sscaled_fetch_rgba_float,
  23447.    NULL, /* unpack_z_32unorm */
  23448.    NULL, /* pack_z_32unorm */
  23449.    NULL, /* unpack_z_float */
  23450.    NULL, /* pack_z_float */
  23451.    NULL, /* unpack_s_8uint */
  23452.    NULL, /* pack_s_8uint */
  23453.    NULL, /* unpack_rgba_uint */
  23454.    NULL, /* pack_rgba_uint */
  23455.    NULL, /* unpack_rgba_sint */
  23456.    NULL, /* pack_rgba_sint */
  23457.    NULL, /* fetch_rgba_uint */
  23458.    NULL  /* fetch_rgba_sint */
  23459. };
  23460.  
  23461. const struct util_format_description
  23462. util_format_r16g16b16a16_sscaled_description = {
  23463.    PIPE_FORMAT_R16G16B16A16_SSCALED,
  23464.    "PIPE_FORMAT_R16G16B16A16_SSCALED",
  23465.    "r16g16b16a16_sscaled",
  23466.    {1, 1, 64},  /* block */
  23467.    UTIL_FORMAT_LAYOUT_PLAIN,
  23468.    4,   /* nr_channels */
  23469.    TRUE,        /* is_array */
  23470.    FALSE,       /* is_bitmask */
  23471.    FALSE,       /* is_mixed */
  23472.    {
  23473.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0},   /* x = r */
  23474.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16},  /* y = g */
  23475.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32},  /* z = b */
  23476.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 48}   /* w = a */
  23477.    },
  23478.    {
  23479.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23480.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23481.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23482.       UTIL_FORMAT_SWIZZLE_W     /* a */
  23483.    },
  23484.    UTIL_FORMAT_COLORSPACE_RGB,
  23485.    &util_format_r16g16b16a16_sscaled_unpack_rgba_8unorm,
  23486.    &util_format_r16g16b16a16_sscaled_pack_rgba_8unorm,
  23487.    NULL, /* fetch_rgba_8unorm */
  23488.    &util_format_r16g16b16a16_sscaled_unpack_rgba_float,
  23489.    &util_format_r16g16b16a16_sscaled_pack_rgba_float,
  23490.    &util_format_r16g16b16a16_sscaled_fetch_rgba_float,
  23491.    NULL, /* unpack_z_32unorm */
  23492.    NULL, /* pack_z_32unorm */
  23493.    NULL, /* unpack_z_float */
  23494.    NULL, /* pack_z_float */
  23495.    NULL, /* unpack_s_8uint */
  23496.    NULL, /* pack_s_8uint */
  23497.    NULL, /* unpack_rgba_uint */
  23498.    NULL, /* pack_rgba_uint */
  23499.    NULL, /* unpack_rgba_sint */
  23500.    NULL, /* pack_rgba_sint */
  23501.    NULL, /* fetch_rgba_uint */
  23502.    NULL  /* fetch_rgba_sint */
  23503. };
  23504.  
  23505. const struct util_format_description
  23506. util_format_r8_unorm_description = {
  23507.    PIPE_FORMAT_R8_UNORM,
  23508.    "PIPE_FORMAT_R8_UNORM",
  23509.    "r8_unorm",
  23510.    {1, 1, 8},   /* block */
  23511.    UTIL_FORMAT_LAYOUT_PLAIN,
  23512.    1,   /* nr_channels */
  23513.    TRUE,        /* is_array */
  23514.    TRUE,        /* is_bitmask */
  23515.    FALSE,       /* is_mixed */
  23516.    {
  23517.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  23518.       {0, 0, 0, 0, 0},
  23519.       {0, 0, 0, 0, 0},
  23520.       {0, 0, 0, 0, 0}
  23521.    },
  23522.    {
  23523.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23524.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  23525.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23526.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23527.    },
  23528.    UTIL_FORMAT_COLORSPACE_RGB,
  23529.    &util_format_r8_unorm_unpack_rgba_8unorm,
  23530.    &util_format_r8_unorm_pack_rgba_8unorm,
  23531.    NULL, /* fetch_rgba_8unorm */
  23532.    &util_format_r8_unorm_unpack_rgba_float,
  23533.    &util_format_r8_unorm_pack_rgba_float,
  23534.    &util_format_r8_unorm_fetch_rgba_float,
  23535.    NULL, /* unpack_z_32unorm */
  23536.    NULL, /* pack_z_32unorm */
  23537.    NULL, /* unpack_z_float */
  23538.    NULL, /* pack_z_float */
  23539.    NULL, /* unpack_s_8uint */
  23540.    NULL, /* pack_s_8uint */
  23541.    NULL, /* unpack_rgba_uint */
  23542.    NULL, /* pack_rgba_uint */
  23543.    NULL, /* unpack_rgba_sint */
  23544.    NULL, /* pack_rgba_sint */
  23545.    NULL, /* fetch_rgba_uint */
  23546.    NULL  /* fetch_rgba_sint */
  23547. };
  23548.  
  23549. const struct util_format_description
  23550. util_format_r8g8_unorm_description = {
  23551.    PIPE_FORMAT_R8G8_UNORM,
  23552.    "PIPE_FORMAT_R8G8_UNORM",
  23553.    "r8g8_unorm",
  23554.    {1, 1, 16},  /* block */
  23555.    UTIL_FORMAT_LAYOUT_PLAIN,
  23556.    2,   /* nr_channels */
  23557.    TRUE,        /* is_array */
  23558.    TRUE,        /* is_bitmask */
  23559.    FALSE,       /* is_mixed */
  23560.    {
  23561.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  23562.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  23563.       {0, 0, 0, 0, 0},
  23564.       {0, 0, 0, 0, 0}
  23565.    },
  23566.    {
  23567.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23568.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23569.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23570.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23571.    },
  23572.    UTIL_FORMAT_COLORSPACE_RGB,
  23573.    &util_format_r8g8_unorm_unpack_rgba_8unorm,
  23574.    &util_format_r8g8_unorm_pack_rgba_8unorm,
  23575.    NULL, /* fetch_rgba_8unorm */
  23576.    &util_format_r8g8_unorm_unpack_rgba_float,
  23577.    &util_format_r8g8_unorm_pack_rgba_float,
  23578.    &util_format_r8g8_unorm_fetch_rgba_float,
  23579.    NULL, /* unpack_z_32unorm */
  23580.    NULL, /* pack_z_32unorm */
  23581.    NULL, /* unpack_z_float */
  23582.    NULL, /* pack_z_float */
  23583.    NULL, /* unpack_s_8uint */
  23584.    NULL, /* pack_s_8uint */
  23585.    NULL, /* unpack_rgba_uint */
  23586.    NULL, /* pack_rgba_uint */
  23587.    NULL, /* unpack_rgba_sint */
  23588.    NULL, /* pack_rgba_sint */
  23589.    NULL, /* fetch_rgba_uint */
  23590.    NULL  /* fetch_rgba_sint */
  23591. };
  23592.  
  23593. const struct util_format_description
  23594. util_format_r8g8b8_unorm_description = {
  23595.    PIPE_FORMAT_R8G8B8_UNORM,
  23596.    "PIPE_FORMAT_R8G8B8_UNORM",
  23597.    "r8g8b8_unorm",
  23598.    {1, 1, 24},  /* block */
  23599.    UTIL_FORMAT_LAYOUT_PLAIN,
  23600.    3,   /* nr_channels */
  23601.    TRUE,        /* is_array */
  23602.    FALSE,       /* is_bitmask */
  23603.    FALSE,       /* is_mixed */
  23604.    {
  23605.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  23606.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  23607.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = b */
  23608.       {0, 0, 0, 0, 0}
  23609.    },
  23610.    {
  23611.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23612.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23613.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23614.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23615.    },
  23616.    UTIL_FORMAT_COLORSPACE_RGB,
  23617.    &util_format_r8g8b8_unorm_unpack_rgba_8unorm,
  23618.    &util_format_r8g8b8_unorm_pack_rgba_8unorm,
  23619.    NULL, /* fetch_rgba_8unorm */
  23620.    &util_format_r8g8b8_unorm_unpack_rgba_float,
  23621.    &util_format_r8g8b8_unorm_pack_rgba_float,
  23622.    &util_format_r8g8b8_unorm_fetch_rgba_float,
  23623.    NULL, /* unpack_z_32unorm */
  23624.    NULL, /* pack_z_32unorm */
  23625.    NULL, /* unpack_z_float */
  23626.    NULL, /* pack_z_float */
  23627.    NULL, /* unpack_s_8uint */
  23628.    NULL, /* pack_s_8uint */
  23629.    NULL, /* unpack_rgba_uint */
  23630.    NULL, /* pack_rgba_uint */
  23631.    NULL, /* unpack_rgba_sint */
  23632.    NULL, /* pack_rgba_sint */
  23633.    NULL, /* fetch_rgba_uint */
  23634.    NULL  /* fetch_rgba_sint */
  23635. };
  23636.  
  23637. const struct util_format_description
  23638. util_format_r8g8b8a8_unorm_description = {
  23639.    PIPE_FORMAT_R8G8B8A8_UNORM,
  23640.    "PIPE_FORMAT_R8G8B8A8_UNORM",
  23641.    "r8g8b8a8_unorm",
  23642.    {1, 1, 32},  /* block */
  23643.    UTIL_FORMAT_LAYOUT_PLAIN,
  23644.    4,   /* nr_channels */
  23645.    TRUE,        /* is_array */
  23646.    TRUE,        /* is_bitmask */
  23647.    FALSE,       /* is_mixed */
  23648.    {
  23649.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  23650.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  23651.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = b */
  23652.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24}   /* w = a */
  23653.    },
  23654.    {
  23655.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23656.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23657.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23658.       UTIL_FORMAT_SWIZZLE_W     /* a */
  23659.    },
  23660.    UTIL_FORMAT_COLORSPACE_RGB,
  23661.    &util_format_r8g8b8a8_unorm_unpack_rgba_8unorm,
  23662.    &util_format_r8g8b8a8_unorm_pack_rgba_8unorm,
  23663.    NULL, /* fetch_rgba_8unorm */
  23664.    &util_format_r8g8b8a8_unorm_unpack_rgba_float,
  23665.    &util_format_r8g8b8a8_unorm_pack_rgba_float,
  23666.    &util_format_r8g8b8a8_unorm_fetch_rgba_float,
  23667.    NULL, /* unpack_z_32unorm */
  23668.    NULL, /* pack_z_32unorm */
  23669.    NULL, /* unpack_z_float */
  23670.    NULL, /* pack_z_float */
  23671.    NULL, /* unpack_s_8uint */
  23672.    NULL, /* pack_s_8uint */
  23673.    NULL, /* unpack_rgba_uint */
  23674.    NULL, /* pack_rgba_uint */
  23675.    NULL, /* unpack_rgba_sint */
  23676.    NULL, /* pack_rgba_sint */
  23677.    NULL, /* fetch_rgba_uint */
  23678.    NULL  /* fetch_rgba_sint */
  23679. };
  23680.  
  23681. const struct util_format_description
  23682. util_format_r8_uscaled_description = {
  23683.    PIPE_FORMAT_R8_USCALED,
  23684.    "PIPE_FORMAT_R8_USCALED",
  23685.    "r8_uscaled",
  23686.    {1, 1, 8},   /* block */
  23687.    UTIL_FORMAT_LAYOUT_PLAIN,
  23688.    1,   /* nr_channels */
  23689.    TRUE,        /* is_array */
  23690.    TRUE,        /* is_bitmask */
  23691.    FALSE,       /* is_mixed */
  23692.    {
  23693.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0},  /* x = r */
  23694.       {0, 0, 0, 0, 0},
  23695.       {0, 0, 0, 0, 0},
  23696.       {0, 0, 0, 0, 0}
  23697.    },
  23698.    {
  23699.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23700.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  23701.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23702.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23703.    },
  23704.    UTIL_FORMAT_COLORSPACE_RGB,
  23705.    &util_format_r8_uscaled_unpack_rgba_8unorm,
  23706.    &util_format_r8_uscaled_pack_rgba_8unorm,
  23707.    NULL, /* fetch_rgba_8unorm */
  23708.    &util_format_r8_uscaled_unpack_rgba_float,
  23709.    &util_format_r8_uscaled_pack_rgba_float,
  23710.    &util_format_r8_uscaled_fetch_rgba_float,
  23711.    NULL, /* unpack_z_32unorm */
  23712.    NULL, /* pack_z_32unorm */
  23713.    NULL, /* unpack_z_float */
  23714.    NULL, /* pack_z_float */
  23715.    NULL, /* unpack_s_8uint */
  23716.    NULL, /* pack_s_8uint */
  23717.    NULL, /* unpack_rgba_uint */
  23718.    NULL, /* pack_rgba_uint */
  23719.    NULL, /* unpack_rgba_sint */
  23720.    NULL, /* pack_rgba_sint */
  23721.    NULL, /* fetch_rgba_uint */
  23722.    NULL  /* fetch_rgba_sint */
  23723. };
  23724.  
  23725. const struct util_format_description
  23726. util_format_r8g8_uscaled_description = {
  23727.    PIPE_FORMAT_R8G8_USCALED,
  23728.    "PIPE_FORMAT_R8G8_USCALED",
  23729.    "r8g8_uscaled",
  23730.    {1, 1, 16},  /* block */
  23731.    UTIL_FORMAT_LAYOUT_PLAIN,
  23732.    2,   /* nr_channels */
  23733.    TRUE,        /* is_array */
  23734.    TRUE,        /* is_bitmask */
  23735.    FALSE,       /* is_mixed */
  23736.    {
  23737.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0},  /* x = r */
  23738.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8},  /* y = g */
  23739.       {0, 0, 0, 0, 0},
  23740.       {0, 0, 0, 0, 0}
  23741.    },
  23742.    {
  23743.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23744.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23745.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23746.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23747.    },
  23748.    UTIL_FORMAT_COLORSPACE_RGB,
  23749.    &util_format_r8g8_uscaled_unpack_rgba_8unorm,
  23750.    &util_format_r8g8_uscaled_pack_rgba_8unorm,
  23751.    NULL, /* fetch_rgba_8unorm */
  23752.    &util_format_r8g8_uscaled_unpack_rgba_float,
  23753.    &util_format_r8g8_uscaled_pack_rgba_float,
  23754.    &util_format_r8g8_uscaled_fetch_rgba_float,
  23755.    NULL, /* unpack_z_32unorm */
  23756.    NULL, /* pack_z_32unorm */
  23757.    NULL, /* unpack_z_float */
  23758.    NULL, /* pack_z_float */
  23759.    NULL, /* unpack_s_8uint */
  23760.    NULL, /* pack_s_8uint */
  23761.    NULL, /* unpack_rgba_uint */
  23762.    NULL, /* pack_rgba_uint */
  23763.    NULL, /* unpack_rgba_sint */
  23764.    NULL, /* pack_rgba_sint */
  23765.    NULL, /* fetch_rgba_uint */
  23766.    NULL  /* fetch_rgba_sint */
  23767. };
  23768.  
  23769. const struct util_format_description
  23770. util_format_r8g8b8_uscaled_description = {
  23771.    PIPE_FORMAT_R8G8B8_USCALED,
  23772.    "PIPE_FORMAT_R8G8B8_USCALED",
  23773.    "r8g8b8_uscaled",
  23774.    {1, 1, 24},  /* block */
  23775.    UTIL_FORMAT_LAYOUT_PLAIN,
  23776.    3,   /* nr_channels */
  23777.    TRUE,        /* is_array */
  23778.    FALSE,       /* is_bitmask */
  23779.    FALSE,       /* is_mixed */
  23780.    {
  23781.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0},  /* x = r */
  23782.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8},  /* y = g */
  23783.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */
  23784.       {0, 0, 0, 0, 0}
  23785.    },
  23786.    {
  23787.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23788.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23789.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23790.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23791.    },
  23792.    UTIL_FORMAT_COLORSPACE_RGB,
  23793.    &util_format_r8g8b8_uscaled_unpack_rgba_8unorm,
  23794.    &util_format_r8g8b8_uscaled_pack_rgba_8unorm,
  23795.    NULL, /* fetch_rgba_8unorm */
  23796.    &util_format_r8g8b8_uscaled_unpack_rgba_float,
  23797.    &util_format_r8g8b8_uscaled_pack_rgba_float,
  23798.    &util_format_r8g8b8_uscaled_fetch_rgba_float,
  23799.    NULL, /* unpack_z_32unorm */
  23800.    NULL, /* pack_z_32unorm */
  23801.    NULL, /* unpack_z_float */
  23802.    NULL, /* pack_z_float */
  23803.    NULL, /* unpack_s_8uint */
  23804.    NULL, /* pack_s_8uint */
  23805.    NULL, /* unpack_rgba_uint */
  23806.    NULL, /* pack_rgba_uint */
  23807.    NULL, /* unpack_rgba_sint */
  23808.    NULL, /* pack_rgba_sint */
  23809.    NULL, /* fetch_rgba_uint */
  23810.    NULL  /* fetch_rgba_sint */
  23811. };
  23812.  
  23813. const struct util_format_description
  23814. util_format_r8g8b8a8_uscaled_description = {
  23815.    PIPE_FORMAT_R8G8B8A8_USCALED,
  23816.    "PIPE_FORMAT_R8G8B8A8_USCALED",
  23817.    "r8g8b8a8_uscaled",
  23818.    {1, 1, 32},  /* block */
  23819.    UTIL_FORMAT_LAYOUT_PLAIN,
  23820.    4,   /* nr_channels */
  23821.    TRUE,        /* is_array */
  23822.    TRUE,        /* is_bitmask */
  23823.    FALSE,       /* is_mixed */
  23824.    {
  23825.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0},  /* x = r */
  23826.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8},  /* y = g */
  23827.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */
  23828.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 24}  /* w = a */
  23829.    },
  23830.    {
  23831.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23832.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23833.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23834.       UTIL_FORMAT_SWIZZLE_W     /* a */
  23835.    },
  23836.    UTIL_FORMAT_COLORSPACE_RGB,
  23837.    &util_format_r8g8b8a8_uscaled_unpack_rgba_8unorm,
  23838.    &util_format_r8g8b8a8_uscaled_pack_rgba_8unorm,
  23839.    NULL, /* fetch_rgba_8unorm */
  23840.    &util_format_r8g8b8a8_uscaled_unpack_rgba_float,
  23841.    &util_format_r8g8b8a8_uscaled_pack_rgba_float,
  23842.    &util_format_r8g8b8a8_uscaled_fetch_rgba_float,
  23843.    NULL, /* unpack_z_32unorm */
  23844.    NULL, /* pack_z_32unorm */
  23845.    NULL, /* unpack_z_float */
  23846.    NULL, /* pack_z_float */
  23847.    NULL, /* unpack_s_8uint */
  23848.    NULL, /* pack_s_8uint */
  23849.    NULL, /* unpack_rgba_uint */
  23850.    NULL, /* pack_rgba_uint */
  23851.    NULL, /* unpack_rgba_sint */
  23852.    NULL, /* pack_rgba_sint */
  23853.    NULL, /* fetch_rgba_uint */
  23854.    NULL  /* fetch_rgba_sint */
  23855. };
  23856.  
  23857. const struct util_format_description
  23858. util_format_r8_snorm_description = {
  23859.    PIPE_FORMAT_R8_SNORM,
  23860.    "PIPE_FORMAT_R8_SNORM",
  23861.    "r8_snorm",
  23862.    {1, 1, 8},   /* block */
  23863.    UTIL_FORMAT_LAYOUT_PLAIN,
  23864.    1,   /* nr_channels */
  23865.    TRUE,        /* is_array */
  23866.    TRUE,        /* is_bitmask */
  23867.    FALSE,       /* is_mixed */
  23868.    {
  23869.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  23870.       {0, 0, 0, 0, 0},
  23871.       {0, 0, 0, 0, 0},
  23872.       {0, 0, 0, 0, 0}
  23873.    },
  23874.    {
  23875.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23876.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  23877.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23878.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23879.    },
  23880.    UTIL_FORMAT_COLORSPACE_RGB,
  23881.    &util_format_r8_snorm_unpack_rgba_8unorm,
  23882.    &util_format_r8_snorm_pack_rgba_8unorm,
  23883.    NULL, /* fetch_rgba_8unorm */
  23884.    &util_format_r8_snorm_unpack_rgba_float,
  23885.    &util_format_r8_snorm_pack_rgba_float,
  23886.    &util_format_r8_snorm_fetch_rgba_float,
  23887.    NULL, /* unpack_z_32unorm */
  23888.    NULL, /* pack_z_32unorm */
  23889.    NULL, /* unpack_z_float */
  23890.    NULL, /* pack_z_float */
  23891.    NULL, /* unpack_s_8uint */
  23892.    NULL, /* pack_s_8uint */
  23893.    NULL, /* unpack_rgba_uint */
  23894.    NULL, /* pack_rgba_uint */
  23895.    NULL, /* unpack_rgba_sint */
  23896.    NULL, /* pack_rgba_sint */
  23897.    NULL, /* fetch_rgba_uint */
  23898.    NULL  /* fetch_rgba_sint */
  23899. };
  23900.  
  23901. const struct util_format_description
  23902. util_format_r8g8_snorm_description = {
  23903.    PIPE_FORMAT_R8G8_SNORM,
  23904.    "PIPE_FORMAT_R8G8_SNORM",
  23905.    "r8g8_snorm",
  23906.    {1, 1, 16},  /* block */
  23907.    UTIL_FORMAT_LAYOUT_PLAIN,
  23908.    2,   /* nr_channels */
  23909.    TRUE,        /* is_array */
  23910.    TRUE,        /* is_bitmask */
  23911.    FALSE,       /* is_mixed */
  23912.    {
  23913.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  23914.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = g */
  23915.       {0, 0, 0, 0, 0},
  23916.       {0, 0, 0, 0, 0}
  23917.    },
  23918.    {
  23919.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23920.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23921.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  23922.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23923.    },
  23924.    UTIL_FORMAT_COLORSPACE_RGB,
  23925.    &util_format_r8g8_snorm_unpack_rgba_8unorm,
  23926.    &util_format_r8g8_snorm_pack_rgba_8unorm,
  23927.    NULL, /* fetch_rgba_8unorm */
  23928.    &util_format_r8g8_snorm_unpack_rgba_float,
  23929.    &util_format_r8g8_snorm_pack_rgba_float,
  23930.    &util_format_r8g8_snorm_fetch_rgba_float,
  23931.    NULL, /* unpack_z_32unorm */
  23932.    NULL, /* pack_z_32unorm */
  23933.    NULL, /* unpack_z_float */
  23934.    NULL, /* pack_z_float */
  23935.    NULL, /* unpack_s_8uint */
  23936.    NULL, /* pack_s_8uint */
  23937.    NULL, /* unpack_rgba_uint */
  23938.    NULL, /* pack_rgba_uint */
  23939.    NULL, /* unpack_rgba_sint */
  23940.    NULL, /* pack_rgba_sint */
  23941.    NULL, /* fetch_rgba_uint */
  23942.    NULL  /* fetch_rgba_sint */
  23943. };
  23944.  
  23945. const struct util_format_description
  23946. util_format_r8g8b8_snorm_description = {
  23947.    PIPE_FORMAT_R8G8B8_SNORM,
  23948.    "PIPE_FORMAT_R8G8B8_SNORM",
  23949.    "r8g8b8_snorm",
  23950.    {1, 1, 24},  /* block */
  23951.    UTIL_FORMAT_LAYOUT_PLAIN,
  23952.    3,   /* nr_channels */
  23953.    TRUE,        /* is_array */
  23954.    FALSE,       /* is_bitmask */
  23955.    FALSE,       /* is_mixed */
  23956.    {
  23957.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  23958.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = g */
  23959.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16},    /* z = b */
  23960.       {0, 0, 0, 0, 0}
  23961.    },
  23962.    {
  23963.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  23964.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  23965.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  23966.       UTIL_FORMAT_SWIZZLE_1     /* a */
  23967.    },
  23968.    UTIL_FORMAT_COLORSPACE_RGB,
  23969.    &util_format_r8g8b8_snorm_unpack_rgba_8unorm,
  23970.    &util_format_r8g8b8_snorm_pack_rgba_8unorm,
  23971.    NULL, /* fetch_rgba_8unorm */
  23972.    &util_format_r8g8b8_snorm_unpack_rgba_float,
  23973.    &util_format_r8g8b8_snorm_pack_rgba_float,
  23974.    &util_format_r8g8b8_snorm_fetch_rgba_float,
  23975.    NULL, /* unpack_z_32unorm */
  23976.    NULL, /* pack_z_32unorm */
  23977.    NULL, /* unpack_z_float */
  23978.    NULL, /* pack_z_float */
  23979.    NULL, /* unpack_s_8uint */
  23980.    NULL, /* pack_s_8uint */
  23981.    NULL, /* unpack_rgba_uint */
  23982.    NULL, /* pack_rgba_uint */
  23983.    NULL, /* unpack_rgba_sint */
  23984.    NULL, /* pack_rgba_sint */
  23985.    NULL, /* fetch_rgba_uint */
  23986.    NULL  /* fetch_rgba_sint */
  23987. };
  23988.  
  23989. const struct util_format_description
  23990. util_format_r8g8b8a8_snorm_description = {
  23991.    PIPE_FORMAT_R8G8B8A8_SNORM,
  23992.    "PIPE_FORMAT_R8G8B8A8_SNORM",
  23993.    "r8g8b8a8_snorm",
  23994.    {1, 1, 32},  /* block */
  23995.    UTIL_FORMAT_LAYOUT_PLAIN,
  23996.    4,   /* nr_channels */
  23997.    TRUE,        /* is_array */
  23998.    TRUE,        /* is_bitmask */
  23999.    FALSE,       /* is_mixed */
  24000.    {
  24001.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  24002.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = g */
  24003.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16},    /* z = b */
  24004.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 24}     /* w = a */
  24005.    },
  24006.    {
  24007.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24008.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24009.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24010.       UTIL_FORMAT_SWIZZLE_W     /* a */
  24011.    },
  24012.    UTIL_FORMAT_COLORSPACE_RGB,
  24013.    &util_format_r8g8b8a8_snorm_unpack_rgba_8unorm,
  24014.    &util_format_r8g8b8a8_snorm_pack_rgba_8unorm,
  24015.    NULL, /* fetch_rgba_8unorm */
  24016.    &util_format_r8g8b8a8_snorm_unpack_rgba_float,
  24017.    &util_format_r8g8b8a8_snorm_pack_rgba_float,
  24018.    &util_format_r8g8b8a8_snorm_fetch_rgba_float,
  24019.    NULL, /* unpack_z_32unorm */
  24020.    NULL, /* pack_z_32unorm */
  24021.    NULL, /* unpack_z_float */
  24022.    NULL, /* pack_z_float */
  24023.    NULL, /* unpack_s_8uint */
  24024.    NULL, /* pack_s_8uint */
  24025.    NULL, /* unpack_rgba_uint */
  24026.    NULL, /* pack_rgba_uint */
  24027.    NULL, /* unpack_rgba_sint */
  24028.    NULL, /* pack_rgba_sint */
  24029.    NULL, /* fetch_rgba_uint */
  24030.    NULL  /* fetch_rgba_sint */
  24031. };
  24032.  
  24033. const struct util_format_description
  24034. util_format_r8_sscaled_description = {
  24035.    PIPE_FORMAT_R8_SSCALED,
  24036.    "PIPE_FORMAT_R8_SSCALED",
  24037.    "r8_sscaled",
  24038.    {1, 1, 8},   /* block */
  24039.    UTIL_FORMAT_LAYOUT_PLAIN,
  24040.    1,   /* nr_channels */
  24041.    TRUE,        /* is_array */
  24042.    TRUE,        /* is_bitmask */
  24043.    FALSE,       /* is_mixed */
  24044.    {
  24045.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0},    /* x = r */
  24046.       {0, 0, 0, 0, 0},
  24047.       {0, 0, 0, 0, 0},
  24048.       {0, 0, 0, 0, 0}
  24049.    },
  24050.    {
  24051.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24052.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24053.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24054.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24055.    },
  24056.    UTIL_FORMAT_COLORSPACE_RGB,
  24057.    &util_format_r8_sscaled_unpack_rgba_8unorm,
  24058.    &util_format_r8_sscaled_pack_rgba_8unorm,
  24059.    NULL, /* fetch_rgba_8unorm */
  24060.    &util_format_r8_sscaled_unpack_rgba_float,
  24061.    &util_format_r8_sscaled_pack_rgba_float,
  24062.    &util_format_r8_sscaled_fetch_rgba_float,
  24063.    NULL, /* unpack_z_32unorm */
  24064.    NULL, /* pack_z_32unorm */
  24065.    NULL, /* unpack_z_float */
  24066.    NULL, /* pack_z_float */
  24067.    NULL, /* unpack_s_8uint */
  24068.    NULL, /* pack_s_8uint */
  24069.    NULL, /* unpack_rgba_uint */
  24070.    NULL, /* pack_rgba_uint */
  24071.    NULL, /* unpack_rgba_sint */
  24072.    NULL, /* pack_rgba_sint */
  24073.    NULL, /* fetch_rgba_uint */
  24074.    NULL  /* fetch_rgba_sint */
  24075. };
  24076.  
  24077. const struct util_format_description
  24078. util_format_r8g8_sscaled_description = {
  24079.    PIPE_FORMAT_R8G8_SSCALED,
  24080.    "PIPE_FORMAT_R8G8_SSCALED",
  24081.    "r8g8_sscaled",
  24082.    {1, 1, 16},  /* block */
  24083.    UTIL_FORMAT_LAYOUT_PLAIN,
  24084.    2,   /* nr_channels */
  24085.    TRUE,        /* is_array */
  24086.    TRUE,        /* is_bitmask */
  24087.    FALSE,       /* is_mixed */
  24088.    {
  24089.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0},    /* x = r */
  24090.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8},    /* y = g */
  24091.       {0, 0, 0, 0, 0},
  24092.       {0, 0, 0, 0, 0}
  24093.    },
  24094.    {
  24095.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24096.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24097.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24098.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24099.    },
  24100.    UTIL_FORMAT_COLORSPACE_RGB,
  24101.    &util_format_r8g8_sscaled_unpack_rgba_8unorm,
  24102.    &util_format_r8g8_sscaled_pack_rgba_8unorm,
  24103.    NULL, /* fetch_rgba_8unorm */
  24104.    &util_format_r8g8_sscaled_unpack_rgba_float,
  24105.    &util_format_r8g8_sscaled_pack_rgba_float,
  24106.    &util_format_r8g8_sscaled_fetch_rgba_float,
  24107.    NULL, /* unpack_z_32unorm */
  24108.    NULL, /* pack_z_32unorm */
  24109.    NULL, /* unpack_z_float */
  24110.    NULL, /* pack_z_float */
  24111.    NULL, /* unpack_s_8uint */
  24112.    NULL, /* pack_s_8uint */
  24113.    NULL, /* unpack_rgba_uint */
  24114.    NULL, /* pack_rgba_uint */
  24115.    NULL, /* unpack_rgba_sint */
  24116.    NULL, /* pack_rgba_sint */
  24117.    NULL, /* fetch_rgba_uint */
  24118.    NULL  /* fetch_rgba_sint */
  24119. };
  24120.  
  24121. const struct util_format_description
  24122. util_format_r8g8b8_sscaled_description = {
  24123.    PIPE_FORMAT_R8G8B8_SSCALED,
  24124.    "PIPE_FORMAT_R8G8B8_SSCALED",
  24125.    "r8g8b8_sscaled",
  24126.    {1, 1, 24},  /* block */
  24127.    UTIL_FORMAT_LAYOUT_PLAIN,
  24128.    3,   /* nr_channels */
  24129.    TRUE,        /* is_array */
  24130.    FALSE,       /* is_bitmask */
  24131.    FALSE,       /* is_mixed */
  24132.    {
  24133.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0},    /* x = r */
  24134.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8},    /* y = g */
  24135.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16},   /* z = b */
  24136.       {0, 0, 0, 0, 0}
  24137.    },
  24138.    {
  24139.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24140.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24141.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24142.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24143.    },
  24144.    UTIL_FORMAT_COLORSPACE_RGB,
  24145.    &util_format_r8g8b8_sscaled_unpack_rgba_8unorm,
  24146.    &util_format_r8g8b8_sscaled_pack_rgba_8unorm,
  24147.    NULL, /* fetch_rgba_8unorm */
  24148.    &util_format_r8g8b8_sscaled_unpack_rgba_float,
  24149.    &util_format_r8g8b8_sscaled_pack_rgba_float,
  24150.    &util_format_r8g8b8_sscaled_fetch_rgba_float,
  24151.    NULL, /* unpack_z_32unorm */
  24152.    NULL, /* pack_z_32unorm */
  24153.    NULL, /* unpack_z_float */
  24154.    NULL, /* pack_z_float */
  24155.    NULL, /* unpack_s_8uint */
  24156.    NULL, /* pack_s_8uint */
  24157.    NULL, /* unpack_rgba_uint */
  24158.    NULL, /* pack_rgba_uint */
  24159.    NULL, /* unpack_rgba_sint */
  24160.    NULL, /* pack_rgba_sint */
  24161.    NULL, /* fetch_rgba_uint */
  24162.    NULL  /* fetch_rgba_sint */
  24163. };
  24164.  
  24165. const struct util_format_description
  24166. util_format_r8g8b8a8_sscaled_description = {
  24167.    PIPE_FORMAT_R8G8B8A8_SSCALED,
  24168.    "PIPE_FORMAT_R8G8B8A8_SSCALED",
  24169.    "r8g8b8a8_sscaled",
  24170.    {1, 1, 32},  /* block */
  24171.    UTIL_FORMAT_LAYOUT_PLAIN,
  24172.    4,   /* nr_channels */
  24173.    TRUE,        /* is_array */
  24174.    TRUE,        /* is_bitmask */
  24175.    FALSE,       /* is_mixed */
  24176.    {
  24177.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0},    /* x = r */
  24178.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8},    /* y = g */
  24179.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16},   /* z = b */
  24180.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 24}    /* w = a */
  24181.    },
  24182.    {
  24183.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24184.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24185.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24186.       UTIL_FORMAT_SWIZZLE_W     /* a */
  24187.    },
  24188.    UTIL_FORMAT_COLORSPACE_RGB,
  24189.    &util_format_r8g8b8a8_sscaled_unpack_rgba_8unorm,
  24190.    &util_format_r8g8b8a8_sscaled_pack_rgba_8unorm,
  24191.    NULL, /* fetch_rgba_8unorm */
  24192.    &util_format_r8g8b8a8_sscaled_unpack_rgba_float,
  24193.    &util_format_r8g8b8a8_sscaled_pack_rgba_float,
  24194.    &util_format_r8g8b8a8_sscaled_fetch_rgba_float,
  24195.    NULL, /* unpack_z_32unorm */
  24196.    NULL, /* pack_z_32unorm */
  24197.    NULL, /* unpack_z_float */
  24198.    NULL, /* pack_z_float */
  24199.    NULL, /* unpack_s_8uint */
  24200.    NULL, /* pack_s_8uint */
  24201.    NULL, /* unpack_rgba_uint */
  24202.    NULL, /* pack_rgba_uint */
  24203.    NULL, /* unpack_rgba_sint */
  24204.    NULL, /* pack_rgba_sint */
  24205.    NULL, /* fetch_rgba_uint */
  24206.    NULL  /* fetch_rgba_sint */
  24207. };
  24208.  
  24209. const struct util_format_description
  24210. util_format_r32_fixed_description = {
  24211.    PIPE_FORMAT_R32_FIXED,
  24212.    "PIPE_FORMAT_R32_FIXED",
  24213.    "r32_fixed",
  24214.    {1, 1, 32},  /* block */
  24215.    UTIL_FORMAT_LAYOUT_PLAIN,
  24216.    1,   /* nr_channels */
  24217.    TRUE,        /* is_array */
  24218.    FALSE,       /* is_bitmask */
  24219.    FALSE,       /* is_mixed */
  24220.    {
  24221.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0},    /* x = r */
  24222.       {0, 0, 0, 0, 0},
  24223.       {0, 0, 0, 0, 0},
  24224.       {0, 0, 0, 0, 0}
  24225.    },
  24226.    {
  24227.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24228.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24229.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24230.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24231.    },
  24232.    UTIL_FORMAT_COLORSPACE_RGB,
  24233.    &util_format_r32_fixed_unpack_rgba_8unorm,
  24234.    &util_format_r32_fixed_pack_rgba_8unorm,
  24235.    NULL, /* fetch_rgba_8unorm */
  24236.    &util_format_r32_fixed_unpack_rgba_float,
  24237.    &util_format_r32_fixed_pack_rgba_float,
  24238.    &util_format_r32_fixed_fetch_rgba_float,
  24239.    NULL, /* unpack_z_32unorm */
  24240.    NULL, /* pack_z_32unorm */
  24241.    NULL, /* unpack_z_float */
  24242.    NULL, /* pack_z_float */
  24243.    NULL, /* unpack_s_8uint */
  24244.    NULL, /* pack_s_8uint */
  24245.    NULL, /* unpack_rgba_uint */
  24246.    NULL, /* pack_rgba_uint */
  24247.    NULL, /* unpack_rgba_sint */
  24248.    NULL, /* pack_rgba_sint */
  24249.    NULL, /* fetch_rgba_uint */
  24250.    NULL  /* fetch_rgba_sint */
  24251. };
  24252.  
  24253. const struct util_format_description
  24254. util_format_r32g32_fixed_description = {
  24255.    PIPE_FORMAT_R32G32_FIXED,
  24256.    "PIPE_FORMAT_R32G32_FIXED",
  24257.    "r32g32_fixed",
  24258.    {1, 1, 64},  /* block */
  24259.    UTIL_FORMAT_LAYOUT_PLAIN,
  24260.    2,   /* nr_channels */
  24261.    TRUE,        /* is_array */
  24262.    FALSE,       /* is_bitmask */
  24263.    FALSE,       /* is_mixed */
  24264.    {
  24265.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0},    /* x = r */
  24266.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32},   /* y = g */
  24267.       {0, 0, 0, 0, 0},
  24268.       {0, 0, 0, 0, 0}
  24269.    },
  24270.    {
  24271.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24272.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24273.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24274.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24275.    },
  24276.    UTIL_FORMAT_COLORSPACE_RGB,
  24277.    &util_format_r32g32_fixed_unpack_rgba_8unorm,
  24278.    &util_format_r32g32_fixed_pack_rgba_8unorm,
  24279.    NULL, /* fetch_rgba_8unorm */
  24280.    &util_format_r32g32_fixed_unpack_rgba_float,
  24281.    &util_format_r32g32_fixed_pack_rgba_float,
  24282.    &util_format_r32g32_fixed_fetch_rgba_float,
  24283.    NULL, /* unpack_z_32unorm */
  24284.    NULL, /* pack_z_32unorm */
  24285.    NULL, /* unpack_z_float */
  24286.    NULL, /* pack_z_float */
  24287.    NULL, /* unpack_s_8uint */
  24288.    NULL, /* pack_s_8uint */
  24289.    NULL, /* unpack_rgba_uint */
  24290.    NULL, /* pack_rgba_uint */
  24291.    NULL, /* unpack_rgba_sint */
  24292.    NULL, /* pack_rgba_sint */
  24293.    NULL, /* fetch_rgba_uint */
  24294.    NULL  /* fetch_rgba_sint */
  24295. };
  24296.  
  24297. const struct util_format_description
  24298. util_format_r32g32b32_fixed_description = {
  24299.    PIPE_FORMAT_R32G32B32_FIXED,
  24300.    "PIPE_FORMAT_R32G32B32_FIXED",
  24301.    "r32g32b32_fixed",
  24302.    {1, 1, 96},  /* block */
  24303.    UTIL_FORMAT_LAYOUT_PLAIN,
  24304.    3,   /* nr_channels */
  24305.    TRUE,        /* is_array */
  24306.    FALSE,       /* is_bitmask */
  24307.    FALSE,       /* is_mixed */
  24308.    {
  24309.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0},    /* x = r */
  24310.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32},   /* y = g */
  24311.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64},   /* z = b */
  24312.       {0, 0, 0, 0, 0}
  24313.    },
  24314.    {
  24315.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24316.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24317.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24318.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24319.    },
  24320.    UTIL_FORMAT_COLORSPACE_RGB,
  24321.    &util_format_r32g32b32_fixed_unpack_rgba_8unorm,
  24322.    &util_format_r32g32b32_fixed_pack_rgba_8unorm,
  24323.    NULL, /* fetch_rgba_8unorm */
  24324.    &util_format_r32g32b32_fixed_unpack_rgba_float,
  24325.    &util_format_r32g32b32_fixed_pack_rgba_float,
  24326.    &util_format_r32g32b32_fixed_fetch_rgba_float,
  24327.    NULL, /* unpack_z_32unorm */
  24328.    NULL, /* pack_z_32unorm */
  24329.    NULL, /* unpack_z_float */
  24330.    NULL, /* pack_z_float */
  24331.    NULL, /* unpack_s_8uint */
  24332.    NULL, /* pack_s_8uint */
  24333.    NULL, /* unpack_rgba_uint */
  24334.    NULL, /* pack_rgba_uint */
  24335.    NULL, /* unpack_rgba_sint */
  24336.    NULL, /* pack_rgba_sint */
  24337.    NULL, /* fetch_rgba_uint */
  24338.    NULL  /* fetch_rgba_sint */
  24339. };
  24340.  
  24341. const struct util_format_description
  24342. util_format_r32g32b32a32_fixed_description = {
  24343.    PIPE_FORMAT_R32G32B32A32_FIXED,
  24344.    "PIPE_FORMAT_R32G32B32A32_FIXED",
  24345.    "r32g32b32a32_fixed",
  24346.    {1, 1, 128}, /* block */
  24347.    UTIL_FORMAT_LAYOUT_PLAIN,
  24348.    4,   /* nr_channels */
  24349.    TRUE,        /* is_array */
  24350.    FALSE,       /* is_bitmask */
  24351.    FALSE,       /* is_mixed */
  24352.    {
  24353.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0},    /* x = r */
  24354.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32},   /* y = g */
  24355.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64},   /* z = b */
  24356.       {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 96}    /* w = a */
  24357.    },
  24358.    {
  24359.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24360.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24361.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24362.       UTIL_FORMAT_SWIZZLE_W     /* a */
  24363.    },
  24364.    UTIL_FORMAT_COLORSPACE_RGB,
  24365.    &util_format_r32g32b32a32_fixed_unpack_rgba_8unorm,
  24366.    &util_format_r32g32b32a32_fixed_pack_rgba_8unorm,
  24367.    NULL, /* fetch_rgba_8unorm */
  24368.    &util_format_r32g32b32a32_fixed_unpack_rgba_float,
  24369.    &util_format_r32g32b32a32_fixed_pack_rgba_float,
  24370.    &util_format_r32g32b32a32_fixed_fetch_rgba_float,
  24371.    NULL, /* unpack_z_32unorm */
  24372.    NULL, /* pack_z_32unorm */
  24373.    NULL, /* unpack_z_float */
  24374.    NULL, /* pack_z_float */
  24375.    NULL, /* unpack_s_8uint */
  24376.    NULL, /* pack_s_8uint */
  24377.    NULL, /* unpack_rgba_uint */
  24378.    NULL, /* pack_rgba_uint */
  24379.    NULL, /* unpack_rgba_sint */
  24380.    NULL, /* pack_rgba_sint */
  24381.    NULL, /* fetch_rgba_uint */
  24382.    NULL  /* fetch_rgba_sint */
  24383. };
  24384.  
  24385. const struct util_format_description
  24386. util_format_r10g10b10x2_uscaled_description = {
  24387.    PIPE_FORMAT_R10G10B10X2_USCALED,
  24388.    "PIPE_FORMAT_R10G10B10X2_USCALED",
  24389.    "r10g10b10x2_uscaled",
  24390.    {1, 1, 32},  /* block */
  24391.    UTIL_FORMAT_LAYOUT_PLAIN,
  24392.    4,   /* nr_channels */
  24393.    FALSE,       /* is_array */
  24394.    TRUE,        /* is_bitmask */
  24395.    FALSE,       /* is_mixed */
  24396.    {
  24397.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 0}, /* x = r */
  24398.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 10},        /* y = g */
  24399.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 20},        /* z = b */
  24400.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30}      /* w = x */
  24401.    },
  24402.    {
  24403.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24404.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24405.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24406.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24407.    },
  24408.    UTIL_FORMAT_COLORSPACE_RGB,
  24409.    &util_format_r10g10b10x2_uscaled_unpack_rgba_8unorm,
  24410.    &util_format_r10g10b10x2_uscaled_pack_rgba_8unorm,
  24411.    NULL, /* fetch_rgba_8unorm */
  24412.    &util_format_r10g10b10x2_uscaled_unpack_rgba_float,
  24413.    &util_format_r10g10b10x2_uscaled_pack_rgba_float,
  24414.    &util_format_r10g10b10x2_uscaled_fetch_rgba_float,
  24415.    NULL, /* unpack_z_32unorm */
  24416.    NULL, /* pack_z_32unorm */
  24417.    NULL, /* unpack_z_float */
  24418.    NULL, /* pack_z_float */
  24419.    NULL, /* unpack_s_8uint */
  24420.    NULL, /* pack_s_8uint */
  24421.    NULL, /* unpack_rgba_uint */
  24422.    NULL, /* pack_rgba_uint */
  24423.    NULL, /* unpack_rgba_sint */
  24424.    NULL, /* pack_rgba_sint */
  24425.    NULL, /* fetch_rgba_uint */
  24426.    NULL  /* fetch_rgba_sint */
  24427. };
  24428.  
  24429. const struct util_format_description
  24430. util_format_r10g10b10x2_snorm_description = {
  24431.    PIPE_FORMAT_R10G10B10X2_SNORM,
  24432.    "PIPE_FORMAT_R10G10B10X2_SNORM",
  24433.    "r10g10b10x2_snorm",
  24434.    {1, 1, 32},  /* block */
  24435.    UTIL_FORMAT_LAYOUT_PLAIN,
  24436.    4,   /* nr_channels */
  24437.    FALSE,       /* is_array */
  24438.    TRUE,        /* is_bitmask */
  24439.    FALSE,       /* is_mixed */
  24440.    {
  24441.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0},    /* x = r */
  24442.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10},   /* y = g */
  24443.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20},   /* z = b */
  24444.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30}      /* w = x */
  24445.    },
  24446.    {
  24447.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24448.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24449.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24450.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24451.    },
  24452.    UTIL_FORMAT_COLORSPACE_RGB,
  24453.    &util_format_r10g10b10x2_snorm_unpack_rgba_8unorm,
  24454.    &util_format_r10g10b10x2_snorm_pack_rgba_8unorm,
  24455.    NULL, /* fetch_rgba_8unorm */
  24456.    &util_format_r10g10b10x2_snorm_unpack_rgba_float,
  24457.    &util_format_r10g10b10x2_snorm_pack_rgba_float,
  24458.    &util_format_r10g10b10x2_snorm_fetch_rgba_float,
  24459.    NULL, /* unpack_z_32unorm */
  24460.    NULL, /* pack_z_32unorm */
  24461.    NULL, /* unpack_z_float */
  24462.    NULL, /* pack_z_float */
  24463.    NULL, /* unpack_s_8uint */
  24464.    NULL, /* pack_s_8uint */
  24465.    NULL, /* unpack_rgba_uint */
  24466.    NULL, /* pack_rgba_uint */
  24467.    NULL, /* unpack_rgba_sint */
  24468.    NULL, /* pack_rgba_sint */
  24469.    NULL, /* fetch_rgba_uint */
  24470.    NULL  /* fetch_rgba_sint */
  24471. };
  24472.  
  24473. const struct util_format_description
  24474. util_format_yv12_description = {
  24475.    PIPE_FORMAT_YV12,
  24476.    "PIPE_FORMAT_YV12",
  24477.    "yv12",
  24478.    {1, 1, 32},  /* block */
  24479.    UTIL_FORMAT_LAYOUT_OTHER,
  24480.    4,   /* nr_channels */
  24481.    FALSE,       /* is_array */
  24482.    FALSE,       /* is_bitmask */
  24483.    FALSE,       /* is_mixed */
  24484.    {
  24485.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  24486.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8},      /* y = y */
  24487.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16},     /* z = z */
  24488.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = w */
  24489.    },
  24490.    {
  24491.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  24492.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  24493.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  24494.       UTIL_FORMAT_SWIZZLE_W     /* ignored */
  24495.    },
  24496.    UTIL_FORMAT_COLORSPACE_YUV,
  24497.    &util_format_yv12_unpack_rgba_8unorm,
  24498.    &util_format_yv12_pack_rgba_8unorm,
  24499.    NULL, /* fetch_rgba_8unorm */
  24500.    &util_format_yv12_unpack_rgba_float,
  24501.    &util_format_yv12_pack_rgba_float,
  24502.    &util_format_yv12_fetch_rgba_float,
  24503.    NULL, /* unpack_z_32unorm */
  24504.    NULL, /* pack_z_32unorm */
  24505.    NULL, /* unpack_z_float */
  24506.    NULL, /* pack_z_float */
  24507.    NULL, /* unpack_s_8uint */
  24508.    NULL, /* pack_s_8uint */
  24509.    NULL, /* unpack_rgba_uint */
  24510.    NULL, /* pack_rgba_uint */
  24511.    NULL, /* unpack_rgba_sint */
  24512.    NULL, /* pack_rgba_sint */
  24513.    NULL, /* fetch_rgba_uint */
  24514.    NULL  /* fetch_rgba_sint */
  24515. };
  24516.  
  24517. const struct util_format_description
  24518. util_format_yv16_description = {
  24519.    PIPE_FORMAT_YV16,
  24520.    "PIPE_FORMAT_YV16",
  24521.    "yv16",
  24522.    {1, 1, 32},  /* block */
  24523.    UTIL_FORMAT_LAYOUT_OTHER,
  24524.    4,   /* nr_channels */
  24525.    FALSE,       /* is_array */
  24526.    FALSE,       /* is_bitmask */
  24527.    FALSE,       /* is_mixed */
  24528.    {
  24529.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  24530.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8},      /* y = y */
  24531.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16},     /* z = z */
  24532.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = w */
  24533.    },
  24534.    {
  24535.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  24536.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  24537.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  24538.       UTIL_FORMAT_SWIZZLE_W     /* ignored */
  24539.    },
  24540.    UTIL_FORMAT_COLORSPACE_YUV,
  24541.    &util_format_yv16_unpack_rgba_8unorm,
  24542.    &util_format_yv16_pack_rgba_8unorm,
  24543.    NULL, /* fetch_rgba_8unorm */
  24544.    &util_format_yv16_unpack_rgba_float,
  24545.    &util_format_yv16_pack_rgba_float,
  24546.    &util_format_yv16_fetch_rgba_float,
  24547.    NULL, /* unpack_z_32unorm */
  24548.    NULL, /* pack_z_32unorm */
  24549.    NULL, /* unpack_z_float */
  24550.    NULL, /* pack_z_float */
  24551.    NULL, /* unpack_s_8uint */
  24552.    NULL, /* pack_s_8uint */
  24553.    NULL, /* unpack_rgba_uint */
  24554.    NULL, /* pack_rgba_uint */
  24555.    NULL, /* unpack_rgba_sint */
  24556.    NULL, /* pack_rgba_sint */
  24557.    NULL, /* fetch_rgba_uint */
  24558.    NULL  /* fetch_rgba_sint */
  24559. };
  24560.  
  24561. const struct util_format_description
  24562. util_format_iyuv_description = {
  24563.    PIPE_FORMAT_IYUV,
  24564.    "PIPE_FORMAT_IYUV",
  24565.    "iyuv",
  24566.    {1, 1, 32},  /* block */
  24567.    UTIL_FORMAT_LAYOUT_OTHER,
  24568.    4,   /* nr_channels */
  24569.    FALSE,       /* is_array */
  24570.    FALSE,       /* is_bitmask */
  24571.    FALSE,       /* is_mixed */
  24572.    {
  24573.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  24574.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8},      /* y = y */
  24575.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16},     /* z = z */
  24576.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = w */
  24577.    },
  24578.    {
  24579.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  24580.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  24581.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  24582.       UTIL_FORMAT_SWIZZLE_W     /* ignored */
  24583.    },
  24584.    UTIL_FORMAT_COLORSPACE_YUV,
  24585.    &util_format_iyuv_unpack_rgba_8unorm,
  24586.    &util_format_iyuv_pack_rgba_8unorm,
  24587.    NULL, /* fetch_rgba_8unorm */
  24588.    &util_format_iyuv_unpack_rgba_float,
  24589.    &util_format_iyuv_pack_rgba_float,
  24590.    &util_format_iyuv_fetch_rgba_float,
  24591.    NULL, /* unpack_z_32unorm */
  24592.    NULL, /* pack_z_32unorm */
  24593.    NULL, /* unpack_z_float */
  24594.    NULL, /* pack_z_float */
  24595.    NULL, /* unpack_s_8uint */
  24596.    NULL, /* pack_s_8uint */
  24597.    NULL, /* unpack_rgba_uint */
  24598.    NULL, /* pack_rgba_uint */
  24599.    NULL, /* unpack_rgba_sint */
  24600.    NULL, /* pack_rgba_sint */
  24601.    NULL, /* fetch_rgba_uint */
  24602.    NULL  /* fetch_rgba_sint */
  24603. };
  24604.  
  24605. const struct util_format_description
  24606. util_format_nv12_description = {
  24607.    PIPE_FORMAT_NV12,
  24608.    "PIPE_FORMAT_NV12",
  24609.    "nv12",
  24610.    {1, 1, 32},  /* block */
  24611.    UTIL_FORMAT_LAYOUT_OTHER,
  24612.    4,   /* nr_channels */
  24613.    FALSE,       /* is_array */
  24614.    FALSE,       /* is_bitmask */
  24615.    FALSE,       /* is_mixed */
  24616.    {
  24617.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  24618.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8},      /* y = y */
  24619.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16},     /* z = z */
  24620.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = w */
  24621.    },
  24622.    {
  24623.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  24624.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  24625.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  24626.       UTIL_FORMAT_SWIZZLE_W     /* ignored */
  24627.    },
  24628.    UTIL_FORMAT_COLORSPACE_YUV,
  24629.    &util_format_nv12_unpack_rgba_8unorm,
  24630.    &util_format_nv12_pack_rgba_8unorm,
  24631.    NULL, /* fetch_rgba_8unorm */
  24632.    &util_format_nv12_unpack_rgba_float,
  24633.    &util_format_nv12_pack_rgba_float,
  24634.    &util_format_nv12_fetch_rgba_float,
  24635.    NULL, /* unpack_z_32unorm */
  24636.    NULL, /* pack_z_32unorm */
  24637.    NULL, /* unpack_z_float */
  24638.    NULL, /* pack_z_float */
  24639.    NULL, /* unpack_s_8uint */
  24640.    NULL, /* pack_s_8uint */
  24641.    NULL, /* unpack_rgba_uint */
  24642.    NULL, /* pack_rgba_uint */
  24643.    NULL, /* unpack_rgba_sint */
  24644.    NULL, /* pack_rgba_sint */
  24645.    NULL, /* fetch_rgba_uint */
  24646.    NULL  /* fetch_rgba_sint */
  24647. };
  24648.  
  24649. const struct util_format_description
  24650. util_format_nv21_description = {
  24651.    PIPE_FORMAT_NV21,
  24652.    "PIPE_FORMAT_NV21",
  24653.    "nv21",
  24654.    {1, 1, 32},  /* block */
  24655.    UTIL_FORMAT_LAYOUT_OTHER,
  24656.    4,   /* nr_channels */
  24657.    FALSE,       /* is_array */
  24658.    FALSE,       /* is_bitmask */
  24659.    FALSE,       /* is_mixed */
  24660.    {
  24661.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0},      /* x = x */
  24662.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8},      /* y = y */
  24663.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16},     /* z = z */
  24664.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = w */
  24665.    },
  24666.    {
  24667.       UTIL_FORMAT_SWIZZLE_X,    /* y */
  24668.       UTIL_FORMAT_SWIZZLE_Y,    /* u */
  24669.       UTIL_FORMAT_SWIZZLE_Z,    /* v */
  24670.       UTIL_FORMAT_SWIZZLE_W     /* ignored */
  24671.    },
  24672.    UTIL_FORMAT_COLORSPACE_YUV,
  24673.    &util_format_nv21_unpack_rgba_8unorm,
  24674.    &util_format_nv21_pack_rgba_8unorm,
  24675.    NULL, /* fetch_rgba_8unorm */
  24676.    &util_format_nv21_unpack_rgba_float,
  24677.    &util_format_nv21_pack_rgba_float,
  24678.    &util_format_nv21_fetch_rgba_float,
  24679.    NULL, /* unpack_z_32unorm */
  24680.    NULL, /* pack_z_32unorm */
  24681.    NULL, /* unpack_z_float */
  24682.    NULL, /* pack_z_float */
  24683.    NULL, /* unpack_s_8uint */
  24684.    NULL, /* pack_s_8uint */
  24685.    NULL, /* unpack_rgba_uint */
  24686.    NULL, /* pack_rgba_uint */
  24687.    NULL, /* unpack_rgba_sint */
  24688.    NULL, /* pack_rgba_sint */
  24689.    NULL, /* fetch_rgba_uint */
  24690.    NULL  /* fetch_rgba_sint */
  24691. };
  24692.  
  24693. const struct util_format_description
  24694. util_format_r4a4_unorm_description = {
  24695.    PIPE_FORMAT_R4A4_UNORM,
  24696.    "PIPE_FORMAT_R4A4_UNORM",
  24697.    "r4a4_unorm",
  24698.    {1, 1, 8},   /* block */
  24699.    UTIL_FORMAT_LAYOUT_PLAIN,
  24700.    2,   /* nr_channels */
  24701.    FALSE,       /* is_array */
  24702.    TRUE,        /* is_bitmask */
  24703.    FALSE,       /* is_mixed */
  24704.    {
  24705.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0},   /* x = a */
  24706.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4},   /* y = r */
  24707.       {0, 0, 0, 0, 0},
  24708.       {0, 0, 0, 0, 0}
  24709.    },
  24710.    {
  24711.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  24712.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24713.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24714.       UTIL_FORMAT_SWIZZLE_X     /* a */
  24715.    },
  24716.    UTIL_FORMAT_COLORSPACE_RGB,
  24717.    &util_format_r4a4_unorm_unpack_rgba_8unorm,
  24718.    &util_format_r4a4_unorm_pack_rgba_8unorm,
  24719.    NULL, /* fetch_rgba_8unorm */
  24720.    &util_format_r4a4_unorm_unpack_rgba_float,
  24721.    &util_format_r4a4_unorm_pack_rgba_float,
  24722.    &util_format_r4a4_unorm_fetch_rgba_float,
  24723.    NULL, /* unpack_z_32unorm */
  24724.    NULL, /* pack_z_32unorm */
  24725.    NULL, /* unpack_z_float */
  24726.    NULL, /* pack_z_float */
  24727.    NULL, /* unpack_s_8uint */
  24728.    NULL, /* pack_s_8uint */
  24729.    NULL, /* unpack_rgba_uint */
  24730.    NULL, /* pack_rgba_uint */
  24731.    NULL, /* unpack_rgba_sint */
  24732.    NULL, /* pack_rgba_sint */
  24733.    NULL, /* fetch_rgba_uint */
  24734.    NULL  /* fetch_rgba_sint */
  24735. };
  24736.  
  24737. const struct util_format_description
  24738. util_format_a4r4_unorm_description = {
  24739.    PIPE_FORMAT_A4R4_UNORM,
  24740.    "PIPE_FORMAT_A4R4_UNORM",
  24741.    "a4r4_unorm",
  24742.    {1, 1, 8},   /* block */
  24743.    UTIL_FORMAT_LAYOUT_PLAIN,
  24744.    2,   /* nr_channels */
  24745.    FALSE,       /* is_array */
  24746.    TRUE,        /* is_bitmask */
  24747.    FALSE,       /* is_mixed */
  24748.    {
  24749.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0},   /* x = r */
  24750.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4},   /* y = a */
  24751.       {0, 0, 0, 0, 0},
  24752.       {0, 0, 0, 0, 0}
  24753.    },
  24754.    {
  24755.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24756.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24757.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24758.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  24759.    },
  24760.    UTIL_FORMAT_COLORSPACE_RGB,
  24761.    &util_format_a4r4_unorm_unpack_rgba_8unorm,
  24762.    &util_format_a4r4_unorm_pack_rgba_8unorm,
  24763.    NULL, /* fetch_rgba_8unorm */
  24764.    &util_format_a4r4_unorm_unpack_rgba_float,
  24765.    &util_format_a4r4_unorm_pack_rgba_float,
  24766.    &util_format_a4r4_unorm_fetch_rgba_float,
  24767.    NULL, /* unpack_z_32unorm */
  24768.    NULL, /* pack_z_32unorm */
  24769.    NULL, /* unpack_z_float */
  24770.    NULL, /* pack_z_float */
  24771.    NULL, /* unpack_s_8uint */
  24772.    NULL, /* pack_s_8uint */
  24773.    NULL, /* unpack_rgba_uint */
  24774.    NULL, /* pack_rgba_uint */
  24775.    NULL, /* unpack_rgba_sint */
  24776.    NULL, /* pack_rgba_sint */
  24777.    NULL, /* fetch_rgba_uint */
  24778.    NULL  /* fetch_rgba_sint */
  24779. };
  24780.  
  24781. const struct util_format_description
  24782. util_format_r8a8_unorm_description = {
  24783.    PIPE_FORMAT_R8A8_UNORM,
  24784.    "PIPE_FORMAT_R8A8_UNORM",
  24785.    "r8a8_unorm",
  24786.    {1, 1, 16},  /* block */
  24787.    UTIL_FORMAT_LAYOUT_PLAIN,
  24788.    2,   /* nr_channels */
  24789.    TRUE,        /* is_array */
  24790.    TRUE,        /* is_bitmask */
  24791.    FALSE,       /* is_mixed */
  24792.    {
  24793.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  24794.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = a */
  24795.       {0, 0, 0, 0, 0},
  24796.       {0, 0, 0, 0, 0}
  24797.    },
  24798.    {
  24799.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24800.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24801.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24802.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  24803.    },
  24804.    UTIL_FORMAT_COLORSPACE_RGB,
  24805.    &util_format_r8a8_unorm_unpack_rgba_8unorm,
  24806.    &util_format_r8a8_unorm_pack_rgba_8unorm,
  24807.    NULL, /* fetch_rgba_8unorm */
  24808.    &util_format_r8a8_unorm_unpack_rgba_float,
  24809.    &util_format_r8a8_unorm_pack_rgba_float,
  24810.    &util_format_r8a8_unorm_fetch_rgba_float,
  24811.    NULL, /* unpack_z_32unorm */
  24812.    NULL, /* pack_z_32unorm */
  24813.    NULL, /* unpack_z_float */
  24814.    NULL, /* pack_z_float */
  24815.    NULL, /* unpack_s_8uint */
  24816.    NULL, /* pack_s_8uint */
  24817.    NULL, /* unpack_rgba_uint */
  24818.    NULL, /* pack_rgba_uint */
  24819.    NULL, /* unpack_rgba_sint */
  24820.    NULL, /* pack_rgba_sint */
  24821.    NULL, /* fetch_rgba_uint */
  24822.    NULL  /* fetch_rgba_sint */
  24823. };
  24824.  
  24825. const struct util_format_description
  24826. util_format_a8r8_unorm_description = {
  24827.    PIPE_FORMAT_A8R8_UNORM,
  24828.    "PIPE_FORMAT_A8R8_UNORM",
  24829.    "a8r8_unorm",
  24830.    {1, 1, 16},  /* block */
  24831.    UTIL_FORMAT_LAYOUT_PLAIN,
  24832.    2,   /* nr_channels */
  24833.    TRUE,        /* is_array */
  24834.    TRUE,        /* is_bitmask */
  24835.    FALSE,       /* is_mixed */
  24836.    {
  24837.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = a */
  24838.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = r */
  24839.       {0, 0, 0, 0, 0},
  24840.       {0, 0, 0, 0, 0}
  24841.    },
  24842.    {
  24843.       UTIL_FORMAT_SWIZZLE_Y,    /* r */
  24844.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24845.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24846.       UTIL_FORMAT_SWIZZLE_X     /* a */
  24847.    },
  24848.    UTIL_FORMAT_COLORSPACE_RGB,
  24849.    &util_format_a8r8_unorm_unpack_rgba_8unorm,
  24850.    &util_format_a8r8_unorm_pack_rgba_8unorm,
  24851.    NULL, /* fetch_rgba_8unorm */
  24852.    &util_format_a8r8_unorm_unpack_rgba_float,
  24853.    &util_format_a8r8_unorm_pack_rgba_float,
  24854.    &util_format_a8r8_unorm_fetch_rgba_float,
  24855.    NULL, /* unpack_z_32unorm */
  24856.    NULL, /* pack_z_32unorm */
  24857.    NULL, /* unpack_z_float */
  24858.    NULL, /* pack_z_float */
  24859.    NULL, /* unpack_s_8uint */
  24860.    NULL, /* pack_s_8uint */
  24861.    NULL, /* unpack_rgba_uint */
  24862.    NULL, /* pack_rgba_uint */
  24863.    NULL, /* unpack_rgba_sint */
  24864.    NULL, /* pack_rgba_sint */
  24865.    NULL, /* fetch_rgba_uint */
  24866.    NULL  /* fetch_rgba_sint */
  24867. };
  24868.  
  24869. const struct util_format_description
  24870. util_format_r8_uint_description = {
  24871.    PIPE_FORMAT_R8_UINT,
  24872.    "PIPE_FORMAT_R8_UINT",
  24873.    "r8_uint",
  24874.    {1, 1, 8},   /* block */
  24875.    UTIL_FORMAT_LAYOUT_PLAIN,
  24876.    1,   /* nr_channels */
  24877.    TRUE,        /* is_array */
  24878.    TRUE,        /* is_bitmask */
  24879.    FALSE,       /* is_mixed */
  24880.    {
  24881.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  24882.       {0, 0, 0, 0, 0},
  24883.       {0, 0, 0, 0, 0},
  24884.       {0, 0, 0, 0, 0}
  24885.    },
  24886.    {
  24887.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24888.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  24889.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24890.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24891.    },
  24892.    UTIL_FORMAT_COLORSPACE_RGB,
  24893.    NULL, /* unpack_rgba_8unorm */
  24894.    NULL, /* pack_rgba_8unorm */
  24895.    NULL, /* fetch_rgba_8unorm */
  24896.    NULL, /* unpack_rgba_float */
  24897.    NULL, /* pack_rgba_float */
  24898.    NULL, /* fetch_rgba_float */
  24899.    NULL, /* unpack_z_32unorm */
  24900.    NULL, /* pack_z_32unorm */
  24901.    NULL, /* unpack_z_float */
  24902.    NULL, /* pack_z_float */
  24903.    NULL, /* unpack_s_8uint */
  24904.    NULL, /* pack_s_8uint */
  24905.    &util_format_r8_uint_unpack_unsigned, /* unpack_rgba_uint */
  24906.    &util_format_r8_uint_pack_unsigned, /* pack_rgba_uint */
  24907.    &util_format_r8_uint_unpack_signed, /* unpack_rgba_sint */
  24908.    &util_format_r8_uint_pack_signed,  /* pack_rgba_sint */
  24909.    &util_format_r8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  24910.    NULL  /* fetch_rgba_sint */
  24911. };
  24912.  
  24913. const struct util_format_description
  24914. util_format_r8g8_uint_description = {
  24915.    PIPE_FORMAT_R8G8_UINT,
  24916.    "PIPE_FORMAT_R8G8_UINT",
  24917.    "r8g8_uint",
  24918.    {1, 1, 16},  /* block */
  24919.    UTIL_FORMAT_LAYOUT_PLAIN,
  24920.    2,   /* nr_channels */
  24921.    TRUE,        /* is_array */
  24922.    TRUE,        /* is_bitmask */
  24923.    FALSE,       /* is_mixed */
  24924.    {
  24925.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  24926.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = g */
  24927.       {0, 0, 0, 0, 0},
  24928.       {0, 0, 0, 0, 0}
  24929.    },
  24930.    {
  24931.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24932.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24933.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  24934.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24935.    },
  24936.    UTIL_FORMAT_COLORSPACE_RGB,
  24937.    NULL, /* unpack_rgba_8unorm */
  24938.    NULL, /* pack_rgba_8unorm */
  24939.    NULL, /* fetch_rgba_8unorm */
  24940.    NULL, /* unpack_rgba_float */
  24941.    NULL, /* pack_rgba_float */
  24942.    NULL, /* fetch_rgba_float */
  24943.    NULL, /* unpack_z_32unorm */
  24944.    NULL, /* pack_z_32unorm */
  24945.    NULL, /* unpack_z_float */
  24946.    NULL, /* pack_z_float */
  24947.    NULL, /* unpack_s_8uint */
  24948.    NULL, /* pack_s_8uint */
  24949.    &util_format_r8g8_uint_unpack_unsigned, /* unpack_rgba_uint */
  24950.    &util_format_r8g8_uint_pack_unsigned, /* pack_rgba_uint */
  24951.    &util_format_r8g8_uint_unpack_signed, /* unpack_rgba_sint */
  24952.    &util_format_r8g8_uint_pack_signed,  /* pack_rgba_sint */
  24953.    &util_format_r8g8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  24954.    NULL  /* fetch_rgba_sint */
  24955. };
  24956.  
  24957. const struct util_format_description
  24958. util_format_r8g8b8_uint_description = {
  24959.    PIPE_FORMAT_R8G8B8_UINT,
  24960.    "PIPE_FORMAT_R8G8B8_UINT",
  24961.    "r8g8b8_uint",
  24962.    {1, 1, 24},  /* block */
  24963.    UTIL_FORMAT_LAYOUT_PLAIN,
  24964.    3,   /* nr_channels */
  24965.    TRUE,        /* is_array */
  24966.    FALSE,       /* is_bitmask */
  24967.    FALSE,       /* is_mixed */
  24968.    {
  24969.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  24970.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = g */
  24971.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16},  /* z = b */
  24972.       {0, 0, 0, 0, 0}
  24973.    },
  24974.    {
  24975.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  24976.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  24977.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  24978.       UTIL_FORMAT_SWIZZLE_1     /* a */
  24979.    },
  24980.    UTIL_FORMAT_COLORSPACE_RGB,
  24981.    NULL, /* unpack_rgba_8unorm */
  24982.    NULL, /* pack_rgba_8unorm */
  24983.    NULL, /* fetch_rgba_8unorm */
  24984.    NULL, /* unpack_rgba_float */
  24985.    NULL, /* pack_rgba_float */
  24986.    NULL, /* fetch_rgba_float */
  24987.    NULL, /* unpack_z_32unorm */
  24988.    NULL, /* pack_z_32unorm */
  24989.    NULL, /* unpack_z_float */
  24990.    NULL, /* pack_z_float */
  24991.    NULL, /* unpack_s_8uint */
  24992.    NULL, /* pack_s_8uint */
  24993.    &util_format_r8g8b8_uint_unpack_unsigned, /* unpack_rgba_uint */
  24994.    &util_format_r8g8b8_uint_pack_unsigned, /* pack_rgba_uint */
  24995.    &util_format_r8g8b8_uint_unpack_signed, /* unpack_rgba_sint */
  24996.    &util_format_r8g8b8_uint_pack_signed,  /* pack_rgba_sint */
  24997.    &util_format_r8g8b8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  24998.    NULL  /* fetch_rgba_sint */
  24999. };
  25000.  
  25001. const struct util_format_description
  25002. util_format_r8g8b8a8_uint_description = {
  25003.    PIPE_FORMAT_R8G8B8A8_UINT,
  25004.    "PIPE_FORMAT_R8G8B8A8_UINT",
  25005.    "r8g8b8a8_uint",
  25006.    {1, 1, 32},  /* block */
  25007.    UTIL_FORMAT_LAYOUT_PLAIN,
  25008.    4,   /* nr_channels */
  25009.    TRUE,        /* is_array */
  25010.    TRUE,        /* is_bitmask */
  25011.    FALSE,       /* is_mixed */
  25012.    {
  25013.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  25014.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = g */
  25015.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16},  /* z = b */
  25016.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24}   /* w = a */
  25017.    },
  25018.    {
  25019.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25020.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25021.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25022.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25023.    },
  25024.    UTIL_FORMAT_COLORSPACE_RGB,
  25025.    NULL, /* unpack_rgba_8unorm */
  25026.    NULL, /* pack_rgba_8unorm */
  25027.    NULL, /* fetch_rgba_8unorm */
  25028.    NULL, /* unpack_rgba_float */
  25029.    NULL, /* pack_rgba_float */
  25030.    NULL, /* fetch_rgba_float */
  25031.    NULL, /* unpack_z_32unorm */
  25032.    NULL, /* pack_z_32unorm */
  25033.    NULL, /* unpack_z_float */
  25034.    NULL, /* pack_z_float */
  25035.    NULL, /* unpack_s_8uint */
  25036.    NULL, /* pack_s_8uint */
  25037.    &util_format_r8g8b8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
  25038.    &util_format_r8g8b8a8_uint_pack_unsigned, /* pack_rgba_uint */
  25039.    &util_format_r8g8b8a8_uint_unpack_signed, /* unpack_rgba_sint */
  25040.    &util_format_r8g8b8a8_uint_pack_signed,  /* pack_rgba_sint */
  25041.    &util_format_r8g8b8a8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25042.    NULL  /* fetch_rgba_sint */
  25043. };
  25044.  
  25045. const struct util_format_description
  25046. util_format_r8_sint_description = {
  25047.    PIPE_FORMAT_R8_SINT,
  25048.    "PIPE_FORMAT_R8_SINT",
  25049.    "r8_sint",
  25050.    {1, 1, 8},   /* block */
  25051.    UTIL_FORMAT_LAYOUT_PLAIN,
  25052.    1,   /* nr_channels */
  25053.    TRUE,        /* is_array */
  25054.    TRUE,        /* is_bitmask */
  25055.    FALSE,       /* is_mixed */
  25056.    {
  25057.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  25058.       {0, 0, 0, 0, 0},
  25059.       {0, 0, 0, 0, 0},
  25060.       {0, 0, 0, 0, 0}
  25061.    },
  25062.    {
  25063.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25064.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25065.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25066.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25067.    },
  25068.    UTIL_FORMAT_COLORSPACE_RGB,
  25069.    NULL, /* unpack_rgba_8unorm */
  25070.    NULL, /* pack_rgba_8unorm */
  25071.    NULL, /* fetch_rgba_8unorm */
  25072.    NULL, /* unpack_rgba_float */
  25073.    NULL, /* pack_rgba_float */
  25074.    NULL, /* fetch_rgba_float */
  25075.    NULL, /* unpack_z_32unorm */
  25076.    NULL, /* pack_z_32unorm */
  25077.    NULL, /* unpack_z_float */
  25078.    NULL, /* pack_z_float */
  25079.    NULL, /* unpack_s_8uint */
  25080.    NULL, /* pack_s_8uint */
  25081.    &util_format_r8_sint_unpack_unsigned, /* unpack_rgba_uint */
  25082.    &util_format_r8_sint_pack_unsigned, /* pack_rgba_uint */
  25083.    &util_format_r8_sint_unpack_signed, /* unpack_rgba_sint */
  25084.    &util_format_r8_sint_pack_signed,  /* pack_rgba_sint */
  25085.    NULL,  /* fetch_rgba_uint */
  25086.    &util_format_r8_sint_fetch_signed  /* fetch_rgba_sint */
  25087. };
  25088.  
  25089. const struct util_format_description
  25090. util_format_r8g8_sint_description = {
  25091.    PIPE_FORMAT_R8G8_SINT,
  25092.    "PIPE_FORMAT_R8G8_SINT",
  25093.    "r8g8_sint",
  25094.    {1, 1, 16},  /* block */
  25095.    UTIL_FORMAT_LAYOUT_PLAIN,
  25096.    2,   /* nr_channels */
  25097.    TRUE,        /* is_array */
  25098.    TRUE,        /* is_bitmask */
  25099.    FALSE,       /* is_mixed */
  25100.    {
  25101.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  25102.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = g */
  25103.       {0, 0, 0, 0, 0},
  25104.       {0, 0, 0, 0, 0}
  25105.    },
  25106.    {
  25107.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25108.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25109.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25110.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25111.    },
  25112.    UTIL_FORMAT_COLORSPACE_RGB,
  25113.    NULL, /* unpack_rgba_8unorm */
  25114.    NULL, /* pack_rgba_8unorm */
  25115.    NULL, /* fetch_rgba_8unorm */
  25116.    NULL, /* unpack_rgba_float */
  25117.    NULL, /* pack_rgba_float */
  25118.    NULL, /* fetch_rgba_float */
  25119.    NULL, /* unpack_z_32unorm */
  25120.    NULL, /* pack_z_32unorm */
  25121.    NULL, /* unpack_z_float */
  25122.    NULL, /* pack_z_float */
  25123.    NULL, /* unpack_s_8uint */
  25124.    NULL, /* pack_s_8uint */
  25125.    &util_format_r8g8_sint_unpack_unsigned, /* unpack_rgba_uint */
  25126.    &util_format_r8g8_sint_pack_unsigned, /* pack_rgba_uint */
  25127.    &util_format_r8g8_sint_unpack_signed, /* unpack_rgba_sint */
  25128.    &util_format_r8g8_sint_pack_signed,  /* pack_rgba_sint */
  25129.    NULL,  /* fetch_rgba_uint */
  25130.    &util_format_r8g8_sint_fetch_signed  /* fetch_rgba_sint */
  25131. };
  25132.  
  25133. const struct util_format_description
  25134. util_format_r8g8b8_sint_description = {
  25135.    PIPE_FORMAT_R8G8B8_SINT,
  25136.    "PIPE_FORMAT_R8G8B8_SINT",
  25137.    "r8g8b8_sint",
  25138.    {1, 1, 24},  /* block */
  25139.    UTIL_FORMAT_LAYOUT_PLAIN,
  25140.    3,   /* nr_channels */
  25141.    TRUE,        /* is_array */
  25142.    FALSE,       /* is_bitmask */
  25143.    FALSE,       /* is_mixed */
  25144.    {
  25145.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  25146.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = g */
  25147.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16},    /* z = b */
  25148.       {0, 0, 0, 0, 0}
  25149.    },
  25150.    {
  25151.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25152.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25153.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25154.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25155.    },
  25156.    UTIL_FORMAT_COLORSPACE_RGB,
  25157.    NULL, /* unpack_rgba_8unorm */
  25158.    NULL, /* pack_rgba_8unorm */
  25159.    NULL, /* fetch_rgba_8unorm */
  25160.    NULL, /* unpack_rgba_float */
  25161.    NULL, /* pack_rgba_float */
  25162.    NULL, /* fetch_rgba_float */
  25163.    NULL, /* unpack_z_32unorm */
  25164.    NULL, /* pack_z_32unorm */
  25165.    NULL, /* unpack_z_float */
  25166.    NULL, /* pack_z_float */
  25167.    NULL, /* unpack_s_8uint */
  25168.    NULL, /* pack_s_8uint */
  25169.    &util_format_r8g8b8_sint_unpack_unsigned, /* unpack_rgba_uint */
  25170.    &util_format_r8g8b8_sint_pack_unsigned, /* pack_rgba_uint */
  25171.    &util_format_r8g8b8_sint_unpack_signed, /* unpack_rgba_sint */
  25172.    &util_format_r8g8b8_sint_pack_signed,  /* pack_rgba_sint */
  25173.    NULL,  /* fetch_rgba_uint */
  25174.    &util_format_r8g8b8_sint_fetch_signed  /* fetch_rgba_sint */
  25175. };
  25176.  
  25177. const struct util_format_description
  25178. util_format_r8g8b8a8_sint_description = {
  25179.    PIPE_FORMAT_R8G8B8A8_SINT,
  25180.    "PIPE_FORMAT_R8G8B8A8_SINT",
  25181.    "r8g8b8a8_sint",
  25182.    {1, 1, 32},  /* block */
  25183.    UTIL_FORMAT_LAYOUT_PLAIN,
  25184.    4,   /* nr_channels */
  25185.    TRUE,        /* is_array */
  25186.    TRUE,        /* is_bitmask */
  25187.    FALSE,       /* is_mixed */
  25188.    {
  25189.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  25190.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = g */
  25191.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16},    /* z = b */
  25192.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 24}     /* w = a */
  25193.    },
  25194.    {
  25195.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25196.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25197.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25198.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25199.    },
  25200.    UTIL_FORMAT_COLORSPACE_RGB,
  25201.    NULL, /* unpack_rgba_8unorm */
  25202.    NULL, /* pack_rgba_8unorm */
  25203.    NULL, /* fetch_rgba_8unorm */
  25204.    NULL, /* unpack_rgba_float */
  25205.    NULL, /* pack_rgba_float */
  25206.    NULL, /* fetch_rgba_float */
  25207.    NULL, /* unpack_z_32unorm */
  25208.    NULL, /* pack_z_32unorm */
  25209.    NULL, /* unpack_z_float */
  25210.    NULL, /* pack_z_float */
  25211.    NULL, /* unpack_s_8uint */
  25212.    NULL, /* pack_s_8uint */
  25213.    &util_format_r8g8b8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
  25214.    &util_format_r8g8b8a8_sint_pack_unsigned, /* pack_rgba_uint */
  25215.    &util_format_r8g8b8a8_sint_unpack_signed, /* unpack_rgba_sint */
  25216.    &util_format_r8g8b8a8_sint_pack_signed,  /* pack_rgba_sint */
  25217.    NULL,  /* fetch_rgba_uint */
  25218.    &util_format_r8g8b8a8_sint_fetch_signed  /* fetch_rgba_sint */
  25219. };
  25220.  
  25221. const struct util_format_description
  25222. util_format_r16_uint_description = {
  25223.    PIPE_FORMAT_R16_UINT,
  25224.    "PIPE_FORMAT_R16_UINT",
  25225.    "r16_uint",
  25226.    {1, 1, 16},  /* block */
  25227.    UTIL_FORMAT_LAYOUT_PLAIN,
  25228.    1,   /* nr_channels */
  25229.    TRUE,        /* is_array */
  25230.    TRUE,        /* is_bitmask */
  25231.    FALSE,       /* is_mixed */
  25232.    {
  25233.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  25234.       {0, 0, 0, 0, 0},
  25235.       {0, 0, 0, 0, 0},
  25236.       {0, 0, 0, 0, 0}
  25237.    },
  25238.    {
  25239.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25240.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25241.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25242.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25243.    },
  25244.    UTIL_FORMAT_COLORSPACE_RGB,
  25245.    NULL, /* unpack_rgba_8unorm */
  25246.    NULL, /* pack_rgba_8unorm */
  25247.    NULL, /* fetch_rgba_8unorm */
  25248.    NULL, /* unpack_rgba_float */
  25249.    NULL, /* pack_rgba_float */
  25250.    NULL, /* fetch_rgba_float */
  25251.    NULL, /* unpack_z_32unorm */
  25252.    NULL, /* pack_z_32unorm */
  25253.    NULL, /* unpack_z_float */
  25254.    NULL, /* pack_z_float */
  25255.    NULL, /* unpack_s_8uint */
  25256.    NULL, /* pack_s_8uint */
  25257.    &util_format_r16_uint_unpack_unsigned, /* unpack_rgba_uint */
  25258.    &util_format_r16_uint_pack_unsigned, /* pack_rgba_uint */
  25259.    &util_format_r16_uint_unpack_signed, /* unpack_rgba_sint */
  25260.    &util_format_r16_uint_pack_signed,  /* pack_rgba_sint */
  25261.    &util_format_r16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25262.    NULL  /* fetch_rgba_sint */
  25263. };
  25264.  
  25265. const struct util_format_description
  25266. util_format_r16g16_uint_description = {
  25267.    PIPE_FORMAT_R16G16_UINT,
  25268.    "PIPE_FORMAT_R16G16_UINT",
  25269.    "r16g16_uint",
  25270.    {1, 1, 32},  /* block */
  25271.    UTIL_FORMAT_LAYOUT_PLAIN,
  25272.    2,   /* nr_channels */
  25273.    TRUE,        /* is_array */
  25274.    TRUE,        /* is_bitmask */
  25275.    FALSE,       /* is_mixed */
  25276.    {
  25277.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  25278.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
  25279.       {0, 0, 0, 0, 0},
  25280.       {0, 0, 0, 0, 0}
  25281.    },
  25282.    {
  25283.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25284.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25285.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25286.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25287.    },
  25288.    UTIL_FORMAT_COLORSPACE_RGB,
  25289.    NULL, /* unpack_rgba_8unorm */
  25290.    NULL, /* pack_rgba_8unorm */
  25291.    NULL, /* fetch_rgba_8unorm */
  25292.    NULL, /* unpack_rgba_float */
  25293.    NULL, /* pack_rgba_float */
  25294.    NULL, /* fetch_rgba_float */
  25295.    NULL, /* unpack_z_32unorm */
  25296.    NULL, /* pack_z_32unorm */
  25297.    NULL, /* unpack_z_float */
  25298.    NULL, /* pack_z_float */
  25299.    NULL, /* unpack_s_8uint */
  25300.    NULL, /* pack_s_8uint */
  25301.    &util_format_r16g16_uint_unpack_unsigned, /* unpack_rgba_uint */
  25302.    &util_format_r16g16_uint_pack_unsigned, /* pack_rgba_uint */
  25303.    &util_format_r16g16_uint_unpack_signed, /* unpack_rgba_sint */
  25304.    &util_format_r16g16_uint_pack_signed,  /* pack_rgba_sint */
  25305.    &util_format_r16g16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25306.    NULL  /* fetch_rgba_sint */
  25307. };
  25308.  
  25309. const struct util_format_description
  25310. util_format_r16g16b16_uint_description = {
  25311.    PIPE_FORMAT_R16G16B16_UINT,
  25312.    "PIPE_FORMAT_R16G16B16_UINT",
  25313.    "r16g16b16_uint",
  25314.    {1, 1, 48},  /* block */
  25315.    UTIL_FORMAT_LAYOUT_PLAIN,
  25316.    3,   /* nr_channels */
  25317.    TRUE,        /* is_array */
  25318.    FALSE,       /* is_bitmask */
  25319.    FALSE,       /* is_mixed */
  25320.    {
  25321.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  25322.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
  25323.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
  25324.       {0, 0, 0, 0, 0}
  25325.    },
  25326.    {
  25327.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25328.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25329.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25330.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25331.    },
  25332.    UTIL_FORMAT_COLORSPACE_RGB,
  25333.    NULL, /* unpack_rgba_8unorm */
  25334.    NULL, /* pack_rgba_8unorm */
  25335.    NULL, /* fetch_rgba_8unorm */
  25336.    NULL, /* unpack_rgba_float */
  25337.    NULL, /* pack_rgba_float */
  25338.    NULL, /* fetch_rgba_float */
  25339.    NULL, /* unpack_z_32unorm */
  25340.    NULL, /* pack_z_32unorm */
  25341.    NULL, /* unpack_z_float */
  25342.    NULL, /* pack_z_float */
  25343.    NULL, /* unpack_s_8uint */
  25344.    NULL, /* pack_s_8uint */
  25345.    &util_format_r16g16b16_uint_unpack_unsigned, /* unpack_rgba_uint */
  25346.    &util_format_r16g16b16_uint_pack_unsigned, /* pack_rgba_uint */
  25347.    &util_format_r16g16b16_uint_unpack_signed, /* unpack_rgba_sint */
  25348.    &util_format_r16g16b16_uint_pack_signed,  /* pack_rgba_sint */
  25349.    &util_format_r16g16b16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25350.    NULL  /* fetch_rgba_sint */
  25351. };
  25352.  
  25353. const struct util_format_description
  25354. util_format_r16g16b16a16_uint_description = {
  25355.    PIPE_FORMAT_R16G16B16A16_UINT,
  25356.    "PIPE_FORMAT_R16G16B16A16_UINT",
  25357.    "r16g16b16a16_uint",
  25358.    {1, 1, 64},  /* block */
  25359.    UTIL_FORMAT_LAYOUT_PLAIN,
  25360.    4,   /* nr_channels */
  25361.    TRUE,        /* is_array */
  25362.    FALSE,       /* is_bitmask */
  25363.    FALSE,       /* is_mixed */
  25364.    {
  25365.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  25366.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
  25367.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
  25368.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 48}  /* w = a */
  25369.    },
  25370.    {
  25371.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25372.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25373.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25374.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25375.    },
  25376.    UTIL_FORMAT_COLORSPACE_RGB,
  25377.    NULL, /* unpack_rgba_8unorm */
  25378.    NULL, /* pack_rgba_8unorm */
  25379.    NULL, /* fetch_rgba_8unorm */
  25380.    NULL, /* unpack_rgba_float */
  25381.    NULL, /* pack_rgba_float */
  25382.    NULL, /* fetch_rgba_float */
  25383.    NULL, /* unpack_z_32unorm */
  25384.    NULL, /* pack_z_32unorm */
  25385.    NULL, /* unpack_z_float */
  25386.    NULL, /* pack_z_float */
  25387.    NULL, /* unpack_s_8uint */
  25388.    NULL, /* pack_s_8uint */
  25389.    &util_format_r16g16b16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
  25390.    &util_format_r16g16b16a16_uint_pack_unsigned, /* pack_rgba_uint */
  25391.    &util_format_r16g16b16a16_uint_unpack_signed, /* unpack_rgba_sint */
  25392.    &util_format_r16g16b16a16_uint_pack_signed,  /* pack_rgba_sint */
  25393.    &util_format_r16g16b16a16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25394.    NULL  /* fetch_rgba_sint */
  25395. };
  25396.  
  25397. const struct util_format_description
  25398. util_format_r16_sint_description = {
  25399.    PIPE_FORMAT_R16_SINT,
  25400.    "PIPE_FORMAT_R16_SINT",
  25401.    "r16_sint",
  25402.    {1, 1, 16},  /* block */
  25403.    UTIL_FORMAT_LAYOUT_PLAIN,
  25404.    1,   /* nr_channels */
  25405.    TRUE,        /* is_array */
  25406.    TRUE,        /* is_bitmask */
  25407.    FALSE,       /* is_mixed */
  25408.    {
  25409.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  25410.       {0, 0, 0, 0, 0},
  25411.       {0, 0, 0, 0, 0},
  25412.       {0, 0, 0, 0, 0}
  25413.    },
  25414.    {
  25415.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25416.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25417.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25418.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25419.    },
  25420.    UTIL_FORMAT_COLORSPACE_RGB,
  25421.    NULL, /* unpack_rgba_8unorm */
  25422.    NULL, /* pack_rgba_8unorm */
  25423.    NULL, /* fetch_rgba_8unorm */
  25424.    NULL, /* unpack_rgba_float */
  25425.    NULL, /* pack_rgba_float */
  25426.    NULL, /* fetch_rgba_float */
  25427.    NULL, /* unpack_z_32unorm */
  25428.    NULL, /* pack_z_32unorm */
  25429.    NULL, /* unpack_z_float */
  25430.    NULL, /* pack_z_float */
  25431.    NULL, /* unpack_s_8uint */
  25432.    NULL, /* pack_s_8uint */
  25433.    &util_format_r16_sint_unpack_unsigned, /* unpack_rgba_uint */
  25434.    &util_format_r16_sint_pack_unsigned, /* pack_rgba_uint */
  25435.    &util_format_r16_sint_unpack_signed, /* unpack_rgba_sint */
  25436.    &util_format_r16_sint_pack_signed,  /* pack_rgba_sint */
  25437.    NULL,  /* fetch_rgba_uint */
  25438.    &util_format_r16_sint_fetch_signed  /* fetch_rgba_sint */
  25439. };
  25440.  
  25441. const struct util_format_description
  25442. util_format_r16g16_sint_description = {
  25443.    PIPE_FORMAT_R16G16_SINT,
  25444.    "PIPE_FORMAT_R16G16_SINT",
  25445.    "r16g16_sint",
  25446.    {1, 1, 32},  /* block */
  25447.    UTIL_FORMAT_LAYOUT_PLAIN,
  25448.    2,   /* nr_channels */
  25449.    TRUE,        /* is_array */
  25450.    TRUE,        /* is_bitmask */
  25451.    FALSE,       /* is_mixed */
  25452.    {
  25453.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  25454.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = g */
  25455.       {0, 0, 0, 0, 0},
  25456.       {0, 0, 0, 0, 0}
  25457.    },
  25458.    {
  25459.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25460.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25461.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25462.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25463.    },
  25464.    UTIL_FORMAT_COLORSPACE_RGB,
  25465.    NULL, /* unpack_rgba_8unorm */
  25466.    NULL, /* pack_rgba_8unorm */
  25467.    NULL, /* fetch_rgba_8unorm */
  25468.    NULL, /* unpack_rgba_float */
  25469.    NULL, /* pack_rgba_float */
  25470.    NULL, /* fetch_rgba_float */
  25471.    NULL, /* unpack_z_32unorm */
  25472.    NULL, /* pack_z_32unorm */
  25473.    NULL, /* unpack_z_float */
  25474.    NULL, /* pack_z_float */
  25475.    NULL, /* unpack_s_8uint */
  25476.    NULL, /* pack_s_8uint */
  25477.    &util_format_r16g16_sint_unpack_unsigned, /* unpack_rgba_uint */
  25478.    &util_format_r16g16_sint_pack_unsigned, /* pack_rgba_uint */
  25479.    &util_format_r16g16_sint_unpack_signed, /* unpack_rgba_sint */
  25480.    &util_format_r16g16_sint_pack_signed,  /* pack_rgba_sint */
  25481.    NULL,  /* fetch_rgba_uint */
  25482.    &util_format_r16g16_sint_fetch_signed  /* fetch_rgba_sint */
  25483. };
  25484.  
  25485. const struct util_format_description
  25486. util_format_r16g16b16_sint_description = {
  25487.    PIPE_FORMAT_R16G16B16_SINT,
  25488.    "PIPE_FORMAT_R16G16B16_SINT",
  25489.    "r16g16b16_sint",
  25490.    {1, 1, 48},  /* block */
  25491.    UTIL_FORMAT_LAYOUT_PLAIN,
  25492.    3,   /* nr_channels */
  25493.    TRUE,        /* is_array */
  25494.    FALSE,       /* is_bitmask */
  25495.    FALSE,       /* is_mixed */
  25496.    {
  25497.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  25498.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = g */
  25499.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32},   /* z = b */
  25500.       {0, 0, 0, 0, 0}
  25501.    },
  25502.    {
  25503.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25504.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25505.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25506.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25507.    },
  25508.    UTIL_FORMAT_COLORSPACE_RGB,
  25509.    NULL, /* unpack_rgba_8unorm */
  25510.    NULL, /* pack_rgba_8unorm */
  25511.    NULL, /* fetch_rgba_8unorm */
  25512.    NULL, /* unpack_rgba_float */
  25513.    NULL, /* pack_rgba_float */
  25514.    NULL, /* fetch_rgba_float */
  25515.    NULL, /* unpack_z_32unorm */
  25516.    NULL, /* pack_z_32unorm */
  25517.    NULL, /* unpack_z_float */
  25518.    NULL, /* pack_z_float */
  25519.    NULL, /* unpack_s_8uint */
  25520.    NULL, /* pack_s_8uint */
  25521.    &util_format_r16g16b16_sint_unpack_unsigned, /* unpack_rgba_uint */
  25522.    &util_format_r16g16b16_sint_pack_unsigned, /* pack_rgba_uint */
  25523.    &util_format_r16g16b16_sint_unpack_signed, /* unpack_rgba_sint */
  25524.    &util_format_r16g16b16_sint_pack_signed,  /* pack_rgba_sint */
  25525.    NULL,  /* fetch_rgba_uint */
  25526.    &util_format_r16g16b16_sint_fetch_signed  /* fetch_rgba_sint */
  25527. };
  25528.  
  25529. const struct util_format_description
  25530. util_format_r16g16b16a16_sint_description = {
  25531.    PIPE_FORMAT_R16G16B16A16_SINT,
  25532.    "PIPE_FORMAT_R16G16B16A16_SINT",
  25533.    "r16g16b16a16_sint",
  25534.    {1, 1, 64},  /* block */
  25535.    UTIL_FORMAT_LAYOUT_PLAIN,
  25536.    4,   /* nr_channels */
  25537.    TRUE,        /* is_array */
  25538.    FALSE,       /* is_bitmask */
  25539.    FALSE,       /* is_mixed */
  25540.    {
  25541.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  25542.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = g */
  25543.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32},   /* z = b */
  25544.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 48}    /* w = a */
  25545.    },
  25546.    {
  25547.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25548.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25549.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25550.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25551.    },
  25552.    UTIL_FORMAT_COLORSPACE_RGB,
  25553.    NULL, /* unpack_rgba_8unorm */
  25554.    NULL, /* pack_rgba_8unorm */
  25555.    NULL, /* fetch_rgba_8unorm */
  25556.    NULL, /* unpack_rgba_float */
  25557.    NULL, /* pack_rgba_float */
  25558.    NULL, /* fetch_rgba_float */
  25559.    NULL, /* unpack_z_32unorm */
  25560.    NULL, /* pack_z_32unorm */
  25561.    NULL, /* unpack_z_float */
  25562.    NULL, /* pack_z_float */
  25563.    NULL, /* unpack_s_8uint */
  25564.    NULL, /* pack_s_8uint */
  25565.    &util_format_r16g16b16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
  25566.    &util_format_r16g16b16a16_sint_pack_unsigned, /* pack_rgba_uint */
  25567.    &util_format_r16g16b16a16_sint_unpack_signed, /* unpack_rgba_sint */
  25568.    &util_format_r16g16b16a16_sint_pack_signed,  /* pack_rgba_sint */
  25569.    NULL,  /* fetch_rgba_uint */
  25570.    &util_format_r16g16b16a16_sint_fetch_signed  /* fetch_rgba_sint */
  25571. };
  25572.  
  25573. const struct util_format_description
  25574. util_format_r32_uint_description = {
  25575.    PIPE_FORMAT_R32_UINT,
  25576.    "PIPE_FORMAT_R32_UINT",
  25577.    "r32_uint",
  25578.    {1, 1, 32},  /* block */
  25579.    UTIL_FORMAT_LAYOUT_PLAIN,
  25580.    1,   /* nr_channels */
  25581.    TRUE,        /* is_array */
  25582.    TRUE,        /* is_bitmask */
  25583.    FALSE,       /* is_mixed */
  25584.    {
  25585.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  25586.       {0, 0, 0, 0, 0},
  25587.       {0, 0, 0, 0, 0},
  25588.       {0, 0, 0, 0, 0}
  25589.    },
  25590.    {
  25591.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25592.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25593.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25594.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25595.    },
  25596.    UTIL_FORMAT_COLORSPACE_RGB,
  25597.    NULL, /* unpack_rgba_8unorm */
  25598.    NULL, /* pack_rgba_8unorm */
  25599.    NULL, /* fetch_rgba_8unorm */
  25600.    NULL, /* unpack_rgba_float */
  25601.    NULL, /* pack_rgba_float */
  25602.    NULL, /* fetch_rgba_float */
  25603.    NULL, /* unpack_z_32unorm */
  25604.    NULL, /* pack_z_32unorm */
  25605.    NULL, /* unpack_z_float */
  25606.    NULL, /* pack_z_float */
  25607.    NULL, /* unpack_s_8uint */
  25608.    NULL, /* pack_s_8uint */
  25609.    &util_format_r32_uint_unpack_unsigned, /* unpack_rgba_uint */
  25610.    &util_format_r32_uint_pack_unsigned, /* pack_rgba_uint */
  25611.    &util_format_r32_uint_unpack_signed, /* unpack_rgba_sint */
  25612.    &util_format_r32_uint_pack_signed,  /* pack_rgba_sint */
  25613.    &util_format_r32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25614.    NULL  /* fetch_rgba_sint */
  25615. };
  25616.  
  25617. const struct util_format_description
  25618. util_format_r32g32_uint_description = {
  25619.    PIPE_FORMAT_R32G32_UINT,
  25620.    "PIPE_FORMAT_R32G32_UINT",
  25621.    "r32g32_uint",
  25622.    {1, 1, 64},  /* block */
  25623.    UTIL_FORMAT_LAYOUT_PLAIN,
  25624.    2,   /* nr_channels */
  25625.    TRUE,        /* is_array */
  25626.    FALSE,       /* is_bitmask */
  25627.    FALSE,       /* is_mixed */
  25628.    {
  25629.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  25630.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
  25631.       {0, 0, 0, 0, 0},
  25632.       {0, 0, 0, 0, 0}
  25633.    },
  25634.    {
  25635.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25636.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25637.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25638.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25639.    },
  25640.    UTIL_FORMAT_COLORSPACE_RGB,
  25641.    NULL, /* unpack_rgba_8unorm */
  25642.    NULL, /* pack_rgba_8unorm */
  25643.    NULL, /* fetch_rgba_8unorm */
  25644.    NULL, /* unpack_rgba_float */
  25645.    NULL, /* pack_rgba_float */
  25646.    NULL, /* fetch_rgba_float */
  25647.    NULL, /* unpack_z_32unorm */
  25648.    NULL, /* pack_z_32unorm */
  25649.    NULL, /* unpack_z_float */
  25650.    NULL, /* pack_z_float */
  25651.    NULL, /* unpack_s_8uint */
  25652.    NULL, /* pack_s_8uint */
  25653.    &util_format_r32g32_uint_unpack_unsigned, /* unpack_rgba_uint */
  25654.    &util_format_r32g32_uint_pack_unsigned, /* pack_rgba_uint */
  25655.    &util_format_r32g32_uint_unpack_signed, /* unpack_rgba_sint */
  25656.    &util_format_r32g32_uint_pack_signed,  /* pack_rgba_sint */
  25657.    &util_format_r32g32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25658.    NULL  /* fetch_rgba_sint */
  25659. };
  25660.  
  25661. const struct util_format_description
  25662. util_format_r32g32b32_uint_description = {
  25663.    PIPE_FORMAT_R32G32B32_UINT,
  25664.    "PIPE_FORMAT_R32G32B32_UINT",
  25665.    "r32g32b32_uint",
  25666.    {1, 1, 96},  /* block */
  25667.    UTIL_FORMAT_LAYOUT_PLAIN,
  25668.    3,   /* nr_channels */
  25669.    TRUE,        /* is_array */
  25670.    FALSE,       /* is_bitmask */
  25671.    FALSE,       /* is_mixed */
  25672.    {
  25673.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  25674.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
  25675.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
  25676.       {0, 0, 0, 0, 0}
  25677.    },
  25678.    {
  25679.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25680.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25681.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25682.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25683.    },
  25684.    UTIL_FORMAT_COLORSPACE_RGB,
  25685.    NULL, /* unpack_rgba_8unorm */
  25686.    NULL, /* pack_rgba_8unorm */
  25687.    NULL, /* fetch_rgba_8unorm */
  25688.    NULL, /* unpack_rgba_float */
  25689.    NULL, /* pack_rgba_float */
  25690.    NULL, /* fetch_rgba_float */
  25691.    NULL, /* unpack_z_32unorm */
  25692.    NULL, /* pack_z_32unorm */
  25693.    NULL, /* unpack_z_float */
  25694.    NULL, /* pack_z_float */
  25695.    NULL, /* unpack_s_8uint */
  25696.    NULL, /* pack_s_8uint */
  25697.    &util_format_r32g32b32_uint_unpack_unsigned, /* unpack_rgba_uint */
  25698.    &util_format_r32g32b32_uint_pack_unsigned, /* pack_rgba_uint */
  25699.    &util_format_r32g32b32_uint_unpack_signed, /* unpack_rgba_sint */
  25700.    &util_format_r32g32b32_uint_pack_signed,  /* pack_rgba_sint */
  25701.    &util_format_r32g32b32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25702.    NULL  /* fetch_rgba_sint */
  25703. };
  25704.  
  25705. const struct util_format_description
  25706. util_format_r32g32b32a32_uint_description = {
  25707.    PIPE_FORMAT_R32G32B32A32_UINT,
  25708.    "PIPE_FORMAT_R32G32B32A32_UINT",
  25709.    "r32g32b32a32_uint",
  25710.    {1, 1, 128}, /* block */
  25711.    UTIL_FORMAT_LAYOUT_PLAIN,
  25712.    4,   /* nr_channels */
  25713.    TRUE,        /* is_array */
  25714.    FALSE,       /* is_bitmask */
  25715.    FALSE,       /* is_mixed */
  25716.    {
  25717.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  25718.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
  25719.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
  25720.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 96}  /* w = a */
  25721.    },
  25722.    {
  25723.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25724.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25725.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25726.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25727.    },
  25728.    UTIL_FORMAT_COLORSPACE_RGB,
  25729.    NULL, /* unpack_rgba_8unorm */
  25730.    NULL, /* pack_rgba_8unorm */
  25731.    NULL, /* fetch_rgba_8unorm */
  25732.    NULL, /* unpack_rgba_float */
  25733.    NULL, /* pack_rgba_float */
  25734.    NULL, /* fetch_rgba_float */
  25735.    NULL, /* unpack_z_32unorm */
  25736.    NULL, /* pack_z_32unorm */
  25737.    NULL, /* unpack_z_float */
  25738.    NULL, /* pack_z_float */
  25739.    NULL, /* unpack_s_8uint */
  25740.    NULL, /* pack_s_8uint */
  25741.    &util_format_r32g32b32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
  25742.    &util_format_r32g32b32a32_uint_pack_unsigned, /* pack_rgba_uint */
  25743.    &util_format_r32g32b32a32_uint_unpack_signed, /* unpack_rgba_sint */
  25744.    &util_format_r32g32b32a32_uint_pack_signed,  /* pack_rgba_sint */
  25745.    &util_format_r32g32b32a32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25746.    NULL  /* fetch_rgba_sint */
  25747. };
  25748.  
  25749. const struct util_format_description
  25750. util_format_r32_sint_description = {
  25751.    PIPE_FORMAT_R32_SINT,
  25752.    "PIPE_FORMAT_R32_SINT",
  25753.    "r32_sint",
  25754.    {1, 1, 32},  /* block */
  25755.    UTIL_FORMAT_LAYOUT_PLAIN,
  25756.    1,   /* nr_channels */
  25757.    TRUE,        /* is_array */
  25758.    TRUE,        /* is_bitmask */
  25759.    FALSE,       /* is_mixed */
  25760.    {
  25761.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  25762.       {0, 0, 0, 0, 0},
  25763.       {0, 0, 0, 0, 0},
  25764.       {0, 0, 0, 0, 0}
  25765.    },
  25766.    {
  25767.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25768.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25769.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25770.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25771.    },
  25772.    UTIL_FORMAT_COLORSPACE_RGB,
  25773.    NULL, /* unpack_rgba_8unorm */
  25774.    NULL, /* pack_rgba_8unorm */
  25775.    NULL, /* fetch_rgba_8unorm */
  25776.    NULL, /* unpack_rgba_float */
  25777.    NULL, /* pack_rgba_float */
  25778.    NULL, /* fetch_rgba_float */
  25779.    NULL, /* unpack_z_32unorm */
  25780.    NULL, /* pack_z_32unorm */
  25781.    NULL, /* unpack_z_float */
  25782.    NULL, /* pack_z_float */
  25783.    NULL, /* unpack_s_8uint */
  25784.    NULL, /* pack_s_8uint */
  25785.    &util_format_r32_sint_unpack_unsigned, /* unpack_rgba_uint */
  25786.    &util_format_r32_sint_pack_unsigned, /* pack_rgba_uint */
  25787.    &util_format_r32_sint_unpack_signed, /* unpack_rgba_sint */
  25788.    &util_format_r32_sint_pack_signed,  /* pack_rgba_sint */
  25789.    NULL,  /* fetch_rgba_uint */
  25790.    &util_format_r32_sint_fetch_signed  /* fetch_rgba_sint */
  25791. };
  25792.  
  25793. const struct util_format_description
  25794. util_format_r32g32_sint_description = {
  25795.    PIPE_FORMAT_R32G32_SINT,
  25796.    "PIPE_FORMAT_R32G32_SINT",
  25797.    "r32g32_sint",
  25798.    {1, 1, 64},  /* block */
  25799.    UTIL_FORMAT_LAYOUT_PLAIN,
  25800.    2,   /* nr_channels */
  25801.    TRUE,        /* is_array */
  25802.    FALSE,       /* is_bitmask */
  25803.    FALSE,       /* is_mixed */
  25804.    {
  25805.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  25806.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = g */
  25807.       {0, 0, 0, 0, 0},
  25808.       {0, 0, 0, 0, 0}
  25809.    },
  25810.    {
  25811.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25812.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25813.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25814.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25815.    },
  25816.    UTIL_FORMAT_COLORSPACE_RGB,
  25817.    NULL, /* unpack_rgba_8unorm */
  25818.    NULL, /* pack_rgba_8unorm */
  25819.    NULL, /* fetch_rgba_8unorm */
  25820.    NULL, /* unpack_rgba_float */
  25821.    NULL, /* pack_rgba_float */
  25822.    NULL, /* fetch_rgba_float */
  25823.    NULL, /* unpack_z_32unorm */
  25824.    NULL, /* pack_z_32unorm */
  25825.    NULL, /* unpack_z_float */
  25826.    NULL, /* pack_z_float */
  25827.    NULL, /* unpack_s_8uint */
  25828.    NULL, /* pack_s_8uint */
  25829.    &util_format_r32g32_sint_unpack_unsigned, /* unpack_rgba_uint */
  25830.    &util_format_r32g32_sint_pack_unsigned, /* pack_rgba_uint */
  25831.    &util_format_r32g32_sint_unpack_signed, /* unpack_rgba_sint */
  25832.    &util_format_r32g32_sint_pack_signed,  /* pack_rgba_sint */
  25833.    NULL,  /* fetch_rgba_uint */
  25834.    &util_format_r32g32_sint_fetch_signed  /* fetch_rgba_sint */
  25835. };
  25836.  
  25837. const struct util_format_description
  25838. util_format_r32g32b32_sint_description = {
  25839.    PIPE_FORMAT_R32G32B32_SINT,
  25840.    "PIPE_FORMAT_R32G32B32_SINT",
  25841.    "r32g32b32_sint",
  25842.    {1, 1, 96},  /* block */
  25843.    UTIL_FORMAT_LAYOUT_PLAIN,
  25844.    3,   /* nr_channels */
  25845.    TRUE,        /* is_array */
  25846.    FALSE,       /* is_bitmask */
  25847.    FALSE,       /* is_mixed */
  25848.    {
  25849.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  25850.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = g */
  25851.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64},   /* z = b */
  25852.       {0, 0, 0, 0, 0}
  25853.    },
  25854.    {
  25855.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25856.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25857.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25858.       UTIL_FORMAT_SWIZZLE_1     /* a */
  25859.    },
  25860.    UTIL_FORMAT_COLORSPACE_RGB,
  25861.    NULL, /* unpack_rgba_8unorm */
  25862.    NULL, /* pack_rgba_8unorm */
  25863.    NULL, /* fetch_rgba_8unorm */
  25864.    NULL, /* unpack_rgba_float */
  25865.    NULL, /* pack_rgba_float */
  25866.    NULL, /* fetch_rgba_float */
  25867.    NULL, /* unpack_z_32unorm */
  25868.    NULL, /* pack_z_32unorm */
  25869.    NULL, /* unpack_z_float */
  25870.    NULL, /* pack_z_float */
  25871.    NULL, /* unpack_s_8uint */
  25872.    NULL, /* pack_s_8uint */
  25873.    &util_format_r32g32b32_sint_unpack_unsigned, /* unpack_rgba_uint */
  25874.    &util_format_r32g32b32_sint_pack_unsigned, /* pack_rgba_uint */
  25875.    &util_format_r32g32b32_sint_unpack_signed, /* unpack_rgba_sint */
  25876.    &util_format_r32g32b32_sint_pack_signed,  /* pack_rgba_sint */
  25877.    NULL,  /* fetch_rgba_uint */
  25878.    &util_format_r32g32b32_sint_fetch_signed  /* fetch_rgba_sint */
  25879. };
  25880.  
  25881. const struct util_format_description
  25882. util_format_r32g32b32a32_sint_description = {
  25883.    PIPE_FORMAT_R32G32B32A32_SINT,
  25884.    "PIPE_FORMAT_R32G32B32A32_SINT",
  25885.    "r32g32b32a32_sint",
  25886.    {1, 1, 128}, /* block */
  25887.    UTIL_FORMAT_LAYOUT_PLAIN,
  25888.    4,   /* nr_channels */
  25889.    TRUE,        /* is_array */
  25890.    FALSE,       /* is_bitmask */
  25891.    FALSE,       /* is_mixed */
  25892.    {
  25893.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  25894.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = g */
  25895.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64},   /* z = b */
  25896.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 96}    /* w = a */
  25897.    },
  25898.    {
  25899.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25900.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  25901.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  25902.       UTIL_FORMAT_SWIZZLE_W     /* a */
  25903.    },
  25904.    UTIL_FORMAT_COLORSPACE_RGB,
  25905.    NULL, /* unpack_rgba_8unorm */
  25906.    NULL, /* pack_rgba_8unorm */
  25907.    NULL, /* fetch_rgba_8unorm */
  25908.    NULL, /* unpack_rgba_float */
  25909.    NULL, /* pack_rgba_float */
  25910.    NULL, /* fetch_rgba_float */
  25911.    NULL, /* unpack_z_32unorm */
  25912.    NULL, /* pack_z_32unorm */
  25913.    NULL, /* unpack_z_float */
  25914.    NULL, /* pack_z_float */
  25915.    NULL, /* unpack_s_8uint */
  25916.    NULL, /* pack_s_8uint */
  25917.    &util_format_r32g32b32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
  25918.    &util_format_r32g32b32a32_sint_pack_unsigned, /* pack_rgba_uint */
  25919.    &util_format_r32g32b32a32_sint_unpack_signed, /* unpack_rgba_sint */
  25920.    &util_format_r32g32b32a32_sint_pack_signed,  /* pack_rgba_sint */
  25921.    NULL,  /* fetch_rgba_uint */
  25922.    &util_format_r32g32b32a32_sint_fetch_signed  /* fetch_rgba_sint */
  25923. };
  25924.  
  25925. const struct util_format_description
  25926. util_format_a8_uint_description = {
  25927.    PIPE_FORMAT_A8_UINT,
  25928.    "PIPE_FORMAT_A8_UINT",
  25929.    "a8_uint",
  25930.    {1, 1, 8},   /* block */
  25931.    UTIL_FORMAT_LAYOUT_PLAIN,
  25932.    1,   /* nr_channels */
  25933.    TRUE,        /* is_array */
  25934.    TRUE,        /* is_bitmask */
  25935.    FALSE,       /* is_mixed */
  25936.    {
  25937.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = a */
  25938.       {0, 0, 0, 0, 0},
  25939.       {0, 0, 0, 0, 0},
  25940.       {0, 0, 0, 0, 0}
  25941.    },
  25942.    {
  25943.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  25944.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  25945.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  25946.       UTIL_FORMAT_SWIZZLE_X     /* a */
  25947.    },
  25948.    UTIL_FORMAT_COLORSPACE_RGB,
  25949.    NULL, /* unpack_rgba_8unorm */
  25950.    NULL, /* pack_rgba_8unorm */
  25951.    NULL, /* fetch_rgba_8unorm */
  25952.    NULL, /* unpack_rgba_float */
  25953.    NULL, /* pack_rgba_float */
  25954.    NULL, /* fetch_rgba_float */
  25955.    NULL, /* unpack_z_32unorm */
  25956.    NULL, /* pack_z_32unorm */
  25957.    NULL, /* unpack_z_float */
  25958.    NULL, /* pack_z_float */
  25959.    NULL, /* unpack_s_8uint */
  25960.    NULL, /* pack_s_8uint */
  25961.    &util_format_a8_uint_unpack_unsigned, /* unpack_rgba_uint */
  25962.    &util_format_a8_uint_pack_unsigned, /* pack_rgba_uint */
  25963.    &util_format_a8_uint_unpack_signed, /* unpack_rgba_sint */
  25964.    &util_format_a8_uint_pack_signed,  /* pack_rgba_sint */
  25965.    &util_format_a8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  25966.    NULL  /* fetch_rgba_sint */
  25967. };
  25968.  
  25969. const struct util_format_description
  25970. util_format_i8_uint_description = {
  25971.    PIPE_FORMAT_I8_UINT,
  25972.    "PIPE_FORMAT_I8_UINT",
  25973.    "i8_uint",
  25974.    {1, 1, 8},   /* block */
  25975.    UTIL_FORMAT_LAYOUT_PLAIN,
  25976.    1,   /* nr_channels */
  25977.    TRUE,        /* is_array */
  25978.    TRUE,        /* is_bitmask */
  25979.    FALSE,       /* is_mixed */
  25980.    {
  25981.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = rgba */
  25982.       {0, 0, 0, 0, 0},
  25983.       {0, 0, 0, 0, 0},
  25984.       {0, 0, 0, 0, 0}
  25985.    },
  25986.    {
  25987.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  25988.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  25989.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  25990.       UTIL_FORMAT_SWIZZLE_X     /* a */
  25991.    },
  25992.    UTIL_FORMAT_COLORSPACE_RGB,
  25993.    NULL, /* unpack_rgba_8unorm */
  25994.    NULL, /* pack_rgba_8unorm */
  25995.    NULL, /* fetch_rgba_8unorm */
  25996.    NULL, /* unpack_rgba_float */
  25997.    NULL, /* pack_rgba_float */
  25998.    NULL, /* fetch_rgba_float */
  25999.    NULL, /* unpack_z_32unorm */
  26000.    NULL, /* pack_z_32unorm */
  26001.    NULL, /* unpack_z_float */
  26002.    NULL, /* pack_z_float */
  26003.    NULL, /* unpack_s_8uint */
  26004.    NULL, /* pack_s_8uint */
  26005.    &util_format_i8_uint_unpack_unsigned, /* unpack_rgba_uint */
  26006.    &util_format_i8_uint_pack_unsigned, /* pack_rgba_uint */
  26007.    &util_format_i8_uint_unpack_signed, /* unpack_rgba_sint */
  26008.    &util_format_i8_uint_pack_signed,  /* pack_rgba_sint */
  26009.    &util_format_i8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26010.    NULL  /* fetch_rgba_sint */
  26011. };
  26012.  
  26013. const struct util_format_description
  26014. util_format_l8_uint_description = {
  26015.    PIPE_FORMAT_L8_UINT,
  26016.    "PIPE_FORMAT_L8_UINT",
  26017.    "l8_uint",
  26018.    {1, 1, 8},   /* block */
  26019.    UTIL_FORMAT_LAYOUT_PLAIN,
  26020.    1,   /* nr_channels */
  26021.    TRUE,        /* is_array */
  26022.    TRUE,        /* is_bitmask */
  26023.    FALSE,       /* is_mixed */
  26024.    {
  26025.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = rgb */
  26026.       {0, 0, 0, 0, 0},
  26027.       {0, 0, 0, 0, 0},
  26028.       {0, 0, 0, 0, 0}
  26029.    },
  26030.    {
  26031.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26032.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26033.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26034.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26035.    },
  26036.    UTIL_FORMAT_COLORSPACE_RGB,
  26037.    NULL, /* unpack_rgba_8unorm */
  26038.    NULL, /* pack_rgba_8unorm */
  26039.    NULL, /* fetch_rgba_8unorm */
  26040.    NULL, /* unpack_rgba_float */
  26041.    NULL, /* pack_rgba_float */
  26042.    NULL, /* fetch_rgba_float */
  26043.    NULL, /* unpack_z_32unorm */
  26044.    NULL, /* pack_z_32unorm */
  26045.    NULL, /* unpack_z_float */
  26046.    NULL, /* pack_z_float */
  26047.    NULL, /* unpack_s_8uint */
  26048.    NULL, /* pack_s_8uint */
  26049.    &util_format_l8_uint_unpack_unsigned, /* unpack_rgba_uint */
  26050.    &util_format_l8_uint_pack_unsigned, /* pack_rgba_uint */
  26051.    &util_format_l8_uint_unpack_signed, /* unpack_rgba_sint */
  26052.    &util_format_l8_uint_pack_signed,  /* pack_rgba_sint */
  26053.    &util_format_l8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26054.    NULL  /* fetch_rgba_sint */
  26055. };
  26056.  
  26057. const struct util_format_description
  26058. util_format_l8a8_uint_description = {
  26059.    PIPE_FORMAT_L8A8_UINT,
  26060.    "PIPE_FORMAT_L8A8_UINT",
  26061.    "l8a8_uint",
  26062.    {1, 1, 16},  /* block */
  26063.    UTIL_FORMAT_LAYOUT_PLAIN,
  26064.    2,   /* nr_channels */
  26065.    TRUE,        /* is_array */
  26066.    TRUE,        /* is_bitmask */
  26067.    FALSE,       /* is_mixed */
  26068.    {
  26069.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = rgb */
  26070.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = a */
  26071.       {0, 0, 0, 0, 0},
  26072.       {0, 0, 0, 0, 0}
  26073.    },
  26074.    {
  26075.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26076.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26077.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26078.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26079.    },
  26080.    UTIL_FORMAT_COLORSPACE_RGB,
  26081.    NULL, /* unpack_rgba_8unorm */
  26082.    NULL, /* pack_rgba_8unorm */
  26083.    NULL, /* fetch_rgba_8unorm */
  26084.    NULL, /* unpack_rgba_float */
  26085.    NULL, /* pack_rgba_float */
  26086.    NULL, /* fetch_rgba_float */
  26087.    NULL, /* unpack_z_32unorm */
  26088.    NULL, /* pack_z_32unorm */
  26089.    NULL, /* unpack_z_float */
  26090.    NULL, /* pack_z_float */
  26091.    NULL, /* unpack_s_8uint */
  26092.    NULL, /* pack_s_8uint */
  26093.    &util_format_l8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
  26094.    &util_format_l8a8_uint_pack_unsigned, /* pack_rgba_uint */
  26095.    &util_format_l8a8_uint_unpack_signed, /* unpack_rgba_sint */
  26096.    &util_format_l8a8_uint_pack_signed,  /* pack_rgba_sint */
  26097.    &util_format_l8a8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26098.    NULL  /* fetch_rgba_sint */
  26099. };
  26100.  
  26101. const struct util_format_description
  26102. util_format_a8_sint_description = {
  26103.    PIPE_FORMAT_A8_SINT,
  26104.    "PIPE_FORMAT_A8_SINT",
  26105.    "a8_sint",
  26106.    {1, 1, 8},   /* block */
  26107.    UTIL_FORMAT_LAYOUT_PLAIN,
  26108.    1,   /* nr_channels */
  26109.    TRUE,        /* is_array */
  26110.    TRUE,        /* is_bitmask */
  26111.    FALSE,       /* is_mixed */
  26112.    {
  26113.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = a */
  26114.       {0, 0, 0, 0, 0},
  26115.       {0, 0, 0, 0, 0},
  26116.       {0, 0, 0, 0, 0}
  26117.    },
  26118.    {
  26119.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  26120.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  26121.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  26122.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26123.    },
  26124.    UTIL_FORMAT_COLORSPACE_RGB,
  26125.    NULL, /* unpack_rgba_8unorm */
  26126.    NULL, /* pack_rgba_8unorm */
  26127.    NULL, /* fetch_rgba_8unorm */
  26128.    NULL, /* unpack_rgba_float */
  26129.    NULL, /* pack_rgba_float */
  26130.    NULL, /* fetch_rgba_float */
  26131.    NULL, /* unpack_z_32unorm */
  26132.    NULL, /* pack_z_32unorm */
  26133.    NULL, /* unpack_z_float */
  26134.    NULL, /* pack_z_float */
  26135.    NULL, /* unpack_s_8uint */
  26136.    NULL, /* pack_s_8uint */
  26137.    &util_format_a8_sint_unpack_unsigned, /* unpack_rgba_uint */
  26138.    &util_format_a8_sint_pack_unsigned, /* pack_rgba_uint */
  26139.    &util_format_a8_sint_unpack_signed, /* unpack_rgba_sint */
  26140.    &util_format_a8_sint_pack_signed,  /* pack_rgba_sint */
  26141.    NULL,  /* fetch_rgba_uint */
  26142.    &util_format_a8_sint_fetch_signed  /* fetch_rgba_sint */
  26143. };
  26144.  
  26145. const struct util_format_description
  26146. util_format_i8_sint_description = {
  26147.    PIPE_FORMAT_I8_SINT,
  26148.    "PIPE_FORMAT_I8_SINT",
  26149.    "i8_sint",
  26150.    {1, 1, 8},   /* block */
  26151.    UTIL_FORMAT_LAYOUT_PLAIN,
  26152.    1,   /* nr_channels */
  26153.    TRUE,        /* is_array */
  26154.    TRUE,        /* is_bitmask */
  26155.    FALSE,       /* is_mixed */
  26156.    {
  26157.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = rgba */
  26158.       {0, 0, 0, 0, 0},
  26159.       {0, 0, 0, 0, 0},
  26160.       {0, 0, 0, 0, 0}
  26161.    },
  26162.    {
  26163.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26164.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26165.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26166.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26167.    },
  26168.    UTIL_FORMAT_COLORSPACE_RGB,
  26169.    NULL, /* unpack_rgba_8unorm */
  26170.    NULL, /* pack_rgba_8unorm */
  26171.    NULL, /* fetch_rgba_8unorm */
  26172.    NULL, /* unpack_rgba_float */
  26173.    NULL, /* pack_rgba_float */
  26174.    NULL, /* fetch_rgba_float */
  26175.    NULL, /* unpack_z_32unorm */
  26176.    NULL, /* pack_z_32unorm */
  26177.    NULL, /* unpack_z_float */
  26178.    NULL, /* pack_z_float */
  26179.    NULL, /* unpack_s_8uint */
  26180.    NULL, /* pack_s_8uint */
  26181.    &util_format_i8_sint_unpack_unsigned, /* unpack_rgba_uint */
  26182.    &util_format_i8_sint_pack_unsigned, /* pack_rgba_uint */
  26183.    &util_format_i8_sint_unpack_signed, /* unpack_rgba_sint */
  26184.    &util_format_i8_sint_pack_signed,  /* pack_rgba_sint */
  26185.    NULL,  /* fetch_rgba_uint */
  26186.    &util_format_i8_sint_fetch_signed  /* fetch_rgba_sint */
  26187. };
  26188.  
  26189. const struct util_format_description
  26190. util_format_l8_sint_description = {
  26191.    PIPE_FORMAT_L8_SINT,
  26192.    "PIPE_FORMAT_L8_SINT",
  26193.    "l8_sint",
  26194.    {1, 1, 8},   /* block */
  26195.    UTIL_FORMAT_LAYOUT_PLAIN,
  26196.    1,   /* nr_channels */
  26197.    TRUE,        /* is_array */
  26198.    TRUE,        /* is_bitmask */
  26199.    FALSE,       /* is_mixed */
  26200.    {
  26201.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = rgb */
  26202.       {0, 0, 0, 0, 0},
  26203.       {0, 0, 0, 0, 0},
  26204.       {0, 0, 0, 0, 0}
  26205.    },
  26206.    {
  26207.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26208.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26209.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26210.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26211.    },
  26212.    UTIL_FORMAT_COLORSPACE_RGB,
  26213.    NULL, /* unpack_rgba_8unorm */
  26214.    NULL, /* pack_rgba_8unorm */
  26215.    NULL, /* fetch_rgba_8unorm */
  26216.    NULL, /* unpack_rgba_float */
  26217.    NULL, /* pack_rgba_float */
  26218.    NULL, /* fetch_rgba_float */
  26219.    NULL, /* unpack_z_32unorm */
  26220.    NULL, /* pack_z_32unorm */
  26221.    NULL, /* unpack_z_float */
  26222.    NULL, /* pack_z_float */
  26223.    NULL, /* unpack_s_8uint */
  26224.    NULL, /* pack_s_8uint */
  26225.    &util_format_l8_sint_unpack_unsigned, /* unpack_rgba_uint */
  26226.    &util_format_l8_sint_pack_unsigned, /* pack_rgba_uint */
  26227.    &util_format_l8_sint_unpack_signed, /* unpack_rgba_sint */
  26228.    &util_format_l8_sint_pack_signed,  /* pack_rgba_sint */
  26229.    NULL,  /* fetch_rgba_uint */
  26230.    &util_format_l8_sint_fetch_signed  /* fetch_rgba_sint */
  26231. };
  26232.  
  26233. const struct util_format_description
  26234. util_format_l8a8_sint_description = {
  26235.    PIPE_FORMAT_L8A8_SINT,
  26236.    "PIPE_FORMAT_L8A8_SINT",
  26237.    "l8a8_sint",
  26238.    {1, 1, 16},  /* block */
  26239.    UTIL_FORMAT_LAYOUT_PLAIN,
  26240.    2,   /* nr_channels */
  26241.    TRUE,        /* is_array */
  26242.    TRUE,        /* is_bitmask */
  26243.    FALSE,       /* is_mixed */
  26244.    {
  26245.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = rgb */
  26246.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = a */
  26247.       {0, 0, 0, 0, 0},
  26248.       {0, 0, 0, 0, 0}
  26249.    },
  26250.    {
  26251.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26252.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26253.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26254.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26255.    },
  26256.    UTIL_FORMAT_COLORSPACE_RGB,
  26257.    NULL, /* unpack_rgba_8unorm */
  26258.    NULL, /* pack_rgba_8unorm */
  26259.    NULL, /* fetch_rgba_8unorm */
  26260.    NULL, /* unpack_rgba_float */
  26261.    NULL, /* pack_rgba_float */
  26262.    NULL, /* fetch_rgba_float */
  26263.    NULL, /* unpack_z_32unorm */
  26264.    NULL, /* pack_z_32unorm */
  26265.    NULL, /* unpack_z_float */
  26266.    NULL, /* pack_z_float */
  26267.    NULL, /* unpack_s_8uint */
  26268.    NULL, /* pack_s_8uint */
  26269.    &util_format_l8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
  26270.    &util_format_l8a8_sint_pack_unsigned, /* pack_rgba_uint */
  26271.    &util_format_l8a8_sint_unpack_signed, /* unpack_rgba_sint */
  26272.    &util_format_l8a8_sint_pack_signed,  /* pack_rgba_sint */
  26273.    NULL,  /* fetch_rgba_uint */
  26274.    &util_format_l8a8_sint_fetch_signed  /* fetch_rgba_sint */
  26275. };
  26276.  
  26277. const struct util_format_description
  26278. util_format_a16_uint_description = {
  26279.    PIPE_FORMAT_A16_UINT,
  26280.    "PIPE_FORMAT_A16_UINT",
  26281.    "a16_uint",
  26282.    {1, 1, 16},  /* block */
  26283.    UTIL_FORMAT_LAYOUT_PLAIN,
  26284.    1,   /* nr_channels */
  26285.    TRUE,        /* is_array */
  26286.    TRUE,        /* is_bitmask */
  26287.    FALSE,       /* is_mixed */
  26288.    {
  26289.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = a */
  26290.       {0, 0, 0, 0, 0},
  26291.       {0, 0, 0, 0, 0},
  26292.       {0, 0, 0, 0, 0}
  26293.    },
  26294.    {
  26295.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  26296.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  26297.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  26298.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26299.    },
  26300.    UTIL_FORMAT_COLORSPACE_RGB,
  26301.    NULL, /* unpack_rgba_8unorm */
  26302.    NULL, /* pack_rgba_8unorm */
  26303.    NULL, /* fetch_rgba_8unorm */
  26304.    NULL, /* unpack_rgba_float */
  26305.    NULL, /* pack_rgba_float */
  26306.    NULL, /* fetch_rgba_float */
  26307.    NULL, /* unpack_z_32unorm */
  26308.    NULL, /* pack_z_32unorm */
  26309.    NULL, /* unpack_z_float */
  26310.    NULL, /* pack_z_float */
  26311.    NULL, /* unpack_s_8uint */
  26312.    NULL, /* pack_s_8uint */
  26313.    &util_format_a16_uint_unpack_unsigned, /* unpack_rgba_uint */
  26314.    &util_format_a16_uint_pack_unsigned, /* pack_rgba_uint */
  26315.    &util_format_a16_uint_unpack_signed, /* unpack_rgba_sint */
  26316.    &util_format_a16_uint_pack_signed,  /* pack_rgba_sint */
  26317.    &util_format_a16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26318.    NULL  /* fetch_rgba_sint */
  26319. };
  26320.  
  26321. const struct util_format_description
  26322. util_format_i16_uint_description = {
  26323.    PIPE_FORMAT_I16_UINT,
  26324.    "PIPE_FORMAT_I16_UINT",
  26325.    "i16_uint",
  26326.    {1, 1, 16},  /* block */
  26327.    UTIL_FORMAT_LAYOUT_PLAIN,
  26328.    1,   /* nr_channels */
  26329.    TRUE,        /* is_array */
  26330.    TRUE,        /* is_bitmask */
  26331.    FALSE,       /* is_mixed */
  26332.    {
  26333.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = rgba */
  26334.       {0, 0, 0, 0, 0},
  26335.       {0, 0, 0, 0, 0},
  26336.       {0, 0, 0, 0, 0}
  26337.    },
  26338.    {
  26339.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26340.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26341.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26342.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26343.    },
  26344.    UTIL_FORMAT_COLORSPACE_RGB,
  26345.    NULL, /* unpack_rgba_8unorm */
  26346.    NULL, /* pack_rgba_8unorm */
  26347.    NULL, /* fetch_rgba_8unorm */
  26348.    NULL, /* unpack_rgba_float */
  26349.    NULL, /* pack_rgba_float */
  26350.    NULL, /* fetch_rgba_float */
  26351.    NULL, /* unpack_z_32unorm */
  26352.    NULL, /* pack_z_32unorm */
  26353.    NULL, /* unpack_z_float */
  26354.    NULL, /* pack_z_float */
  26355.    NULL, /* unpack_s_8uint */
  26356.    NULL, /* pack_s_8uint */
  26357.    &util_format_i16_uint_unpack_unsigned, /* unpack_rgba_uint */
  26358.    &util_format_i16_uint_pack_unsigned, /* pack_rgba_uint */
  26359.    &util_format_i16_uint_unpack_signed, /* unpack_rgba_sint */
  26360.    &util_format_i16_uint_pack_signed,  /* pack_rgba_sint */
  26361.    &util_format_i16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26362.    NULL  /* fetch_rgba_sint */
  26363. };
  26364.  
  26365. const struct util_format_description
  26366. util_format_l16_uint_description = {
  26367.    PIPE_FORMAT_L16_UINT,
  26368.    "PIPE_FORMAT_L16_UINT",
  26369.    "l16_uint",
  26370.    {1, 1, 16},  /* block */
  26371.    UTIL_FORMAT_LAYOUT_PLAIN,
  26372.    1,   /* nr_channels */
  26373.    TRUE,        /* is_array */
  26374.    TRUE,        /* is_bitmask */
  26375.    FALSE,       /* is_mixed */
  26376.    {
  26377.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = rgb */
  26378.       {0, 0, 0, 0, 0},
  26379.       {0, 0, 0, 0, 0},
  26380.       {0, 0, 0, 0, 0}
  26381.    },
  26382.    {
  26383.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26384.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26385.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26386.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26387.    },
  26388.    UTIL_FORMAT_COLORSPACE_RGB,
  26389.    NULL, /* unpack_rgba_8unorm */
  26390.    NULL, /* pack_rgba_8unorm */
  26391.    NULL, /* fetch_rgba_8unorm */
  26392.    NULL, /* unpack_rgba_float */
  26393.    NULL, /* pack_rgba_float */
  26394.    NULL, /* fetch_rgba_float */
  26395.    NULL, /* unpack_z_32unorm */
  26396.    NULL, /* pack_z_32unorm */
  26397.    NULL, /* unpack_z_float */
  26398.    NULL, /* pack_z_float */
  26399.    NULL, /* unpack_s_8uint */
  26400.    NULL, /* pack_s_8uint */
  26401.    &util_format_l16_uint_unpack_unsigned, /* unpack_rgba_uint */
  26402.    &util_format_l16_uint_pack_unsigned, /* pack_rgba_uint */
  26403.    &util_format_l16_uint_unpack_signed, /* unpack_rgba_sint */
  26404.    &util_format_l16_uint_pack_signed,  /* pack_rgba_sint */
  26405.    &util_format_l16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26406.    NULL  /* fetch_rgba_sint */
  26407. };
  26408.  
  26409. const struct util_format_description
  26410. util_format_l16a16_uint_description = {
  26411.    PIPE_FORMAT_L16A16_UINT,
  26412.    "PIPE_FORMAT_L16A16_UINT",
  26413.    "l16a16_uint",
  26414.    {1, 1, 32},  /* block */
  26415.    UTIL_FORMAT_LAYOUT_PLAIN,
  26416.    2,   /* nr_channels */
  26417.    TRUE,        /* is_array */
  26418.    TRUE,        /* is_bitmask */
  26419.    FALSE,       /* is_mixed */
  26420.    {
  26421.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = rgb */
  26422.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */
  26423.       {0, 0, 0, 0, 0},
  26424.       {0, 0, 0, 0, 0}
  26425.    },
  26426.    {
  26427.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26428.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26429.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26430.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26431.    },
  26432.    UTIL_FORMAT_COLORSPACE_RGB,
  26433.    NULL, /* unpack_rgba_8unorm */
  26434.    NULL, /* pack_rgba_8unorm */
  26435.    NULL, /* fetch_rgba_8unorm */
  26436.    NULL, /* unpack_rgba_float */
  26437.    NULL, /* pack_rgba_float */
  26438.    NULL, /* fetch_rgba_float */
  26439.    NULL, /* unpack_z_32unorm */
  26440.    NULL, /* pack_z_32unorm */
  26441.    NULL, /* unpack_z_float */
  26442.    NULL, /* pack_z_float */
  26443.    NULL, /* unpack_s_8uint */
  26444.    NULL, /* pack_s_8uint */
  26445.    &util_format_l16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
  26446.    &util_format_l16a16_uint_pack_unsigned, /* pack_rgba_uint */
  26447.    &util_format_l16a16_uint_unpack_signed, /* unpack_rgba_sint */
  26448.    &util_format_l16a16_uint_pack_signed,  /* pack_rgba_sint */
  26449.    &util_format_l16a16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26450.    NULL  /* fetch_rgba_sint */
  26451. };
  26452.  
  26453. const struct util_format_description
  26454. util_format_a16_sint_description = {
  26455.    PIPE_FORMAT_A16_SINT,
  26456.    "PIPE_FORMAT_A16_SINT",
  26457.    "a16_sint",
  26458.    {1, 1, 16},  /* block */
  26459.    UTIL_FORMAT_LAYOUT_PLAIN,
  26460.    1,   /* nr_channels */
  26461.    TRUE,        /* is_array */
  26462.    TRUE,        /* is_bitmask */
  26463.    FALSE,       /* is_mixed */
  26464.    {
  26465.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = a */
  26466.       {0, 0, 0, 0, 0},
  26467.       {0, 0, 0, 0, 0},
  26468.       {0, 0, 0, 0, 0}
  26469.    },
  26470.    {
  26471.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  26472.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  26473.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  26474.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26475.    },
  26476.    UTIL_FORMAT_COLORSPACE_RGB,
  26477.    NULL, /* unpack_rgba_8unorm */
  26478.    NULL, /* pack_rgba_8unorm */
  26479.    NULL, /* fetch_rgba_8unorm */
  26480.    NULL, /* unpack_rgba_float */
  26481.    NULL, /* pack_rgba_float */
  26482.    NULL, /* fetch_rgba_float */
  26483.    NULL, /* unpack_z_32unorm */
  26484.    NULL, /* pack_z_32unorm */
  26485.    NULL, /* unpack_z_float */
  26486.    NULL, /* pack_z_float */
  26487.    NULL, /* unpack_s_8uint */
  26488.    NULL, /* pack_s_8uint */
  26489.    &util_format_a16_sint_unpack_unsigned, /* unpack_rgba_uint */
  26490.    &util_format_a16_sint_pack_unsigned, /* pack_rgba_uint */
  26491.    &util_format_a16_sint_unpack_signed, /* unpack_rgba_sint */
  26492.    &util_format_a16_sint_pack_signed,  /* pack_rgba_sint */
  26493.    NULL,  /* fetch_rgba_uint */
  26494.    &util_format_a16_sint_fetch_signed  /* fetch_rgba_sint */
  26495. };
  26496.  
  26497. const struct util_format_description
  26498. util_format_i16_sint_description = {
  26499.    PIPE_FORMAT_I16_SINT,
  26500.    "PIPE_FORMAT_I16_SINT",
  26501.    "i16_sint",
  26502.    {1, 1, 16},  /* block */
  26503.    UTIL_FORMAT_LAYOUT_PLAIN,
  26504.    1,   /* nr_channels */
  26505.    TRUE,        /* is_array */
  26506.    TRUE,        /* is_bitmask */
  26507.    FALSE,       /* is_mixed */
  26508.    {
  26509.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = rgba */
  26510.       {0, 0, 0, 0, 0},
  26511.       {0, 0, 0, 0, 0},
  26512.       {0, 0, 0, 0, 0}
  26513.    },
  26514.    {
  26515.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26516.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26517.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26518.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26519.    },
  26520.    UTIL_FORMAT_COLORSPACE_RGB,
  26521.    NULL, /* unpack_rgba_8unorm */
  26522.    NULL, /* pack_rgba_8unorm */
  26523.    NULL, /* fetch_rgba_8unorm */
  26524.    NULL, /* unpack_rgba_float */
  26525.    NULL, /* pack_rgba_float */
  26526.    NULL, /* fetch_rgba_float */
  26527.    NULL, /* unpack_z_32unorm */
  26528.    NULL, /* pack_z_32unorm */
  26529.    NULL, /* unpack_z_float */
  26530.    NULL, /* pack_z_float */
  26531.    NULL, /* unpack_s_8uint */
  26532.    NULL, /* pack_s_8uint */
  26533.    &util_format_i16_sint_unpack_unsigned, /* unpack_rgba_uint */
  26534.    &util_format_i16_sint_pack_unsigned, /* pack_rgba_uint */
  26535.    &util_format_i16_sint_unpack_signed, /* unpack_rgba_sint */
  26536.    &util_format_i16_sint_pack_signed,  /* pack_rgba_sint */
  26537.    NULL,  /* fetch_rgba_uint */
  26538.    &util_format_i16_sint_fetch_signed  /* fetch_rgba_sint */
  26539. };
  26540.  
  26541. const struct util_format_description
  26542. util_format_l16_sint_description = {
  26543.    PIPE_FORMAT_L16_SINT,
  26544.    "PIPE_FORMAT_L16_SINT",
  26545.    "l16_sint",
  26546.    {1, 1, 16},  /* block */
  26547.    UTIL_FORMAT_LAYOUT_PLAIN,
  26548.    1,   /* nr_channels */
  26549.    TRUE,        /* is_array */
  26550.    TRUE,        /* is_bitmask */
  26551.    FALSE,       /* is_mixed */
  26552.    {
  26553.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = rgb */
  26554.       {0, 0, 0, 0, 0},
  26555.       {0, 0, 0, 0, 0},
  26556.       {0, 0, 0, 0, 0}
  26557.    },
  26558.    {
  26559.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26560.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26561.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26562.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26563.    },
  26564.    UTIL_FORMAT_COLORSPACE_RGB,
  26565.    NULL, /* unpack_rgba_8unorm */
  26566.    NULL, /* pack_rgba_8unorm */
  26567.    NULL, /* fetch_rgba_8unorm */
  26568.    NULL, /* unpack_rgba_float */
  26569.    NULL, /* pack_rgba_float */
  26570.    NULL, /* fetch_rgba_float */
  26571.    NULL, /* unpack_z_32unorm */
  26572.    NULL, /* pack_z_32unorm */
  26573.    NULL, /* unpack_z_float */
  26574.    NULL, /* pack_z_float */
  26575.    NULL, /* unpack_s_8uint */
  26576.    NULL, /* pack_s_8uint */
  26577.    &util_format_l16_sint_unpack_unsigned, /* unpack_rgba_uint */
  26578.    &util_format_l16_sint_pack_unsigned, /* pack_rgba_uint */
  26579.    &util_format_l16_sint_unpack_signed, /* unpack_rgba_sint */
  26580.    &util_format_l16_sint_pack_signed,  /* pack_rgba_sint */
  26581.    NULL,  /* fetch_rgba_uint */
  26582.    &util_format_l16_sint_fetch_signed  /* fetch_rgba_sint */
  26583. };
  26584.  
  26585. const struct util_format_description
  26586. util_format_l16a16_sint_description = {
  26587.    PIPE_FORMAT_L16A16_SINT,
  26588.    "PIPE_FORMAT_L16A16_SINT",
  26589.    "l16a16_sint",
  26590.    {1, 1, 32},  /* block */
  26591.    UTIL_FORMAT_LAYOUT_PLAIN,
  26592.    2,   /* nr_channels */
  26593.    TRUE,        /* is_array */
  26594.    TRUE,        /* is_bitmask */
  26595.    FALSE,       /* is_mixed */
  26596.    {
  26597.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = rgb */
  26598.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = a */
  26599.       {0, 0, 0, 0, 0},
  26600.       {0, 0, 0, 0, 0}
  26601.    },
  26602.    {
  26603.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26604.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26605.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26606.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26607.    },
  26608.    UTIL_FORMAT_COLORSPACE_RGB,
  26609.    NULL, /* unpack_rgba_8unorm */
  26610.    NULL, /* pack_rgba_8unorm */
  26611.    NULL, /* fetch_rgba_8unorm */
  26612.    NULL, /* unpack_rgba_float */
  26613.    NULL, /* pack_rgba_float */
  26614.    NULL, /* fetch_rgba_float */
  26615.    NULL, /* unpack_z_32unorm */
  26616.    NULL, /* pack_z_32unorm */
  26617.    NULL, /* unpack_z_float */
  26618.    NULL, /* pack_z_float */
  26619.    NULL, /* unpack_s_8uint */
  26620.    NULL, /* pack_s_8uint */
  26621.    &util_format_l16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
  26622.    &util_format_l16a16_sint_pack_unsigned, /* pack_rgba_uint */
  26623.    &util_format_l16a16_sint_unpack_signed, /* unpack_rgba_sint */
  26624.    &util_format_l16a16_sint_pack_signed,  /* pack_rgba_sint */
  26625.    NULL,  /* fetch_rgba_uint */
  26626.    &util_format_l16a16_sint_fetch_signed  /* fetch_rgba_sint */
  26627. };
  26628.  
  26629. const struct util_format_description
  26630. util_format_a32_uint_description = {
  26631.    PIPE_FORMAT_A32_UINT,
  26632.    "PIPE_FORMAT_A32_UINT",
  26633.    "a32_uint",
  26634.    {1, 1, 32},  /* block */
  26635.    UTIL_FORMAT_LAYOUT_PLAIN,
  26636.    1,   /* nr_channels */
  26637.    TRUE,        /* is_array */
  26638.    TRUE,        /* is_bitmask */
  26639.    FALSE,       /* is_mixed */
  26640.    {
  26641.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = a */
  26642.       {0, 0, 0, 0, 0},
  26643.       {0, 0, 0, 0, 0},
  26644.       {0, 0, 0, 0, 0}
  26645.    },
  26646.    {
  26647.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  26648.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  26649.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  26650.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26651.    },
  26652.    UTIL_FORMAT_COLORSPACE_RGB,
  26653.    NULL, /* unpack_rgba_8unorm */
  26654.    NULL, /* pack_rgba_8unorm */
  26655.    NULL, /* fetch_rgba_8unorm */
  26656.    NULL, /* unpack_rgba_float */
  26657.    NULL, /* pack_rgba_float */
  26658.    NULL, /* fetch_rgba_float */
  26659.    NULL, /* unpack_z_32unorm */
  26660.    NULL, /* pack_z_32unorm */
  26661.    NULL, /* unpack_z_float */
  26662.    NULL, /* pack_z_float */
  26663.    NULL, /* unpack_s_8uint */
  26664.    NULL, /* pack_s_8uint */
  26665.    &util_format_a32_uint_unpack_unsigned, /* unpack_rgba_uint */
  26666.    &util_format_a32_uint_pack_unsigned, /* pack_rgba_uint */
  26667.    &util_format_a32_uint_unpack_signed, /* unpack_rgba_sint */
  26668.    &util_format_a32_uint_pack_signed,  /* pack_rgba_sint */
  26669.    &util_format_a32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26670.    NULL  /* fetch_rgba_sint */
  26671. };
  26672.  
  26673. const struct util_format_description
  26674. util_format_i32_uint_description = {
  26675.    PIPE_FORMAT_I32_UINT,
  26676.    "PIPE_FORMAT_I32_UINT",
  26677.    "i32_uint",
  26678.    {1, 1, 32},  /* block */
  26679.    UTIL_FORMAT_LAYOUT_PLAIN,
  26680.    1,   /* nr_channels */
  26681.    TRUE,        /* is_array */
  26682.    TRUE,        /* is_bitmask */
  26683.    FALSE,       /* is_mixed */
  26684.    {
  26685.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = rgba */
  26686.       {0, 0, 0, 0, 0},
  26687.       {0, 0, 0, 0, 0},
  26688.       {0, 0, 0, 0, 0}
  26689.    },
  26690.    {
  26691.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26692.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26693.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26694.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26695.    },
  26696.    UTIL_FORMAT_COLORSPACE_RGB,
  26697.    NULL, /* unpack_rgba_8unorm */
  26698.    NULL, /* pack_rgba_8unorm */
  26699.    NULL, /* fetch_rgba_8unorm */
  26700.    NULL, /* unpack_rgba_float */
  26701.    NULL, /* pack_rgba_float */
  26702.    NULL, /* fetch_rgba_float */
  26703.    NULL, /* unpack_z_32unorm */
  26704.    NULL, /* pack_z_32unorm */
  26705.    NULL, /* unpack_z_float */
  26706.    NULL, /* pack_z_float */
  26707.    NULL, /* unpack_s_8uint */
  26708.    NULL, /* pack_s_8uint */
  26709.    &util_format_i32_uint_unpack_unsigned, /* unpack_rgba_uint */
  26710.    &util_format_i32_uint_pack_unsigned, /* pack_rgba_uint */
  26711.    &util_format_i32_uint_unpack_signed, /* unpack_rgba_sint */
  26712.    &util_format_i32_uint_pack_signed,  /* pack_rgba_sint */
  26713.    &util_format_i32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26714.    NULL  /* fetch_rgba_sint */
  26715. };
  26716.  
  26717. const struct util_format_description
  26718. util_format_l32_uint_description = {
  26719.    PIPE_FORMAT_L32_UINT,
  26720.    "PIPE_FORMAT_L32_UINT",
  26721.    "l32_uint",
  26722.    {1, 1, 32},  /* block */
  26723.    UTIL_FORMAT_LAYOUT_PLAIN,
  26724.    1,   /* nr_channels */
  26725.    TRUE,        /* is_array */
  26726.    TRUE,        /* is_bitmask */
  26727.    FALSE,       /* is_mixed */
  26728.    {
  26729.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = rgb */
  26730.       {0, 0, 0, 0, 0},
  26731.       {0, 0, 0, 0, 0},
  26732.       {0, 0, 0, 0, 0}
  26733.    },
  26734.    {
  26735.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26736.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26737.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26738.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26739.    },
  26740.    UTIL_FORMAT_COLORSPACE_RGB,
  26741.    NULL, /* unpack_rgba_8unorm */
  26742.    NULL, /* pack_rgba_8unorm */
  26743.    NULL, /* fetch_rgba_8unorm */
  26744.    NULL, /* unpack_rgba_float */
  26745.    NULL, /* pack_rgba_float */
  26746.    NULL, /* fetch_rgba_float */
  26747.    NULL, /* unpack_z_32unorm */
  26748.    NULL, /* pack_z_32unorm */
  26749.    NULL, /* unpack_z_float */
  26750.    NULL, /* pack_z_float */
  26751.    NULL, /* unpack_s_8uint */
  26752.    NULL, /* pack_s_8uint */
  26753.    &util_format_l32_uint_unpack_unsigned, /* unpack_rgba_uint */
  26754.    &util_format_l32_uint_pack_unsigned, /* pack_rgba_uint */
  26755.    &util_format_l32_uint_unpack_signed, /* unpack_rgba_sint */
  26756.    &util_format_l32_uint_pack_signed,  /* pack_rgba_sint */
  26757.    &util_format_l32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26758.    NULL  /* fetch_rgba_sint */
  26759. };
  26760.  
  26761. const struct util_format_description
  26762. util_format_l32a32_uint_description = {
  26763.    PIPE_FORMAT_L32A32_UINT,
  26764.    "PIPE_FORMAT_L32A32_UINT",
  26765.    "l32a32_uint",
  26766.    {1, 1, 64},  /* block */
  26767.    UTIL_FORMAT_LAYOUT_PLAIN,
  26768.    2,   /* nr_channels */
  26769.    TRUE,        /* is_array */
  26770.    FALSE,       /* is_bitmask */
  26771.    FALSE,       /* is_mixed */
  26772.    {
  26773.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = rgb */
  26774.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */
  26775.       {0, 0, 0, 0, 0},
  26776.       {0, 0, 0, 0, 0}
  26777.    },
  26778.    {
  26779.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26780.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26781.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26782.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26783.    },
  26784.    UTIL_FORMAT_COLORSPACE_RGB,
  26785.    NULL, /* unpack_rgba_8unorm */
  26786.    NULL, /* pack_rgba_8unorm */
  26787.    NULL, /* fetch_rgba_8unorm */
  26788.    NULL, /* unpack_rgba_float */
  26789.    NULL, /* pack_rgba_float */
  26790.    NULL, /* fetch_rgba_float */
  26791.    NULL, /* unpack_z_32unorm */
  26792.    NULL, /* pack_z_32unorm */
  26793.    NULL, /* unpack_z_float */
  26794.    NULL, /* pack_z_float */
  26795.    NULL, /* unpack_s_8uint */
  26796.    NULL, /* pack_s_8uint */
  26797.    &util_format_l32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
  26798.    &util_format_l32a32_uint_pack_unsigned, /* pack_rgba_uint */
  26799.    &util_format_l32a32_uint_unpack_signed, /* unpack_rgba_sint */
  26800.    &util_format_l32a32_uint_pack_signed,  /* pack_rgba_sint */
  26801.    &util_format_l32a32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  26802.    NULL  /* fetch_rgba_sint */
  26803. };
  26804.  
  26805. const struct util_format_description
  26806. util_format_a32_sint_description = {
  26807.    PIPE_FORMAT_A32_SINT,
  26808.    "PIPE_FORMAT_A32_SINT",
  26809.    "a32_sint",
  26810.    {1, 1, 32},  /* block */
  26811.    UTIL_FORMAT_LAYOUT_PLAIN,
  26812.    1,   /* nr_channels */
  26813.    TRUE,        /* is_array */
  26814.    TRUE,        /* is_bitmask */
  26815.    FALSE,       /* is_mixed */
  26816.    {
  26817.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = a */
  26818.       {0, 0, 0, 0, 0},
  26819.       {0, 0, 0, 0, 0},
  26820.       {0, 0, 0, 0, 0}
  26821.    },
  26822.    {
  26823.       UTIL_FORMAT_SWIZZLE_0,    /* r */
  26824.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  26825.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  26826.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26827.    },
  26828.    UTIL_FORMAT_COLORSPACE_RGB,
  26829.    NULL, /* unpack_rgba_8unorm */
  26830.    NULL, /* pack_rgba_8unorm */
  26831.    NULL, /* fetch_rgba_8unorm */
  26832.    NULL, /* unpack_rgba_float */
  26833.    NULL, /* pack_rgba_float */
  26834.    NULL, /* fetch_rgba_float */
  26835.    NULL, /* unpack_z_32unorm */
  26836.    NULL, /* pack_z_32unorm */
  26837.    NULL, /* unpack_z_float */
  26838.    NULL, /* pack_z_float */
  26839.    NULL, /* unpack_s_8uint */
  26840.    NULL, /* pack_s_8uint */
  26841.    &util_format_a32_sint_unpack_unsigned, /* unpack_rgba_uint */
  26842.    &util_format_a32_sint_pack_unsigned, /* pack_rgba_uint */
  26843.    &util_format_a32_sint_unpack_signed, /* unpack_rgba_sint */
  26844.    &util_format_a32_sint_pack_signed,  /* pack_rgba_sint */
  26845.    NULL,  /* fetch_rgba_uint */
  26846.    &util_format_a32_sint_fetch_signed  /* fetch_rgba_sint */
  26847. };
  26848.  
  26849. const struct util_format_description
  26850. util_format_i32_sint_description = {
  26851.    PIPE_FORMAT_I32_SINT,
  26852.    "PIPE_FORMAT_I32_SINT",
  26853.    "i32_sint",
  26854.    {1, 1, 32},  /* block */
  26855.    UTIL_FORMAT_LAYOUT_PLAIN,
  26856.    1,   /* nr_channels */
  26857.    TRUE,        /* is_array */
  26858.    TRUE,        /* is_bitmask */
  26859.    FALSE,       /* is_mixed */
  26860.    {
  26861.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = rgba */
  26862.       {0, 0, 0, 0, 0},
  26863.       {0, 0, 0, 0, 0},
  26864.       {0, 0, 0, 0, 0}
  26865.    },
  26866.    {
  26867.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26868.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26869.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26870.       UTIL_FORMAT_SWIZZLE_X     /* a */
  26871.    },
  26872.    UTIL_FORMAT_COLORSPACE_RGB,
  26873.    NULL, /* unpack_rgba_8unorm */
  26874.    NULL, /* pack_rgba_8unorm */
  26875.    NULL, /* fetch_rgba_8unorm */
  26876.    NULL, /* unpack_rgba_float */
  26877.    NULL, /* pack_rgba_float */
  26878.    NULL, /* fetch_rgba_float */
  26879.    NULL, /* unpack_z_32unorm */
  26880.    NULL, /* pack_z_32unorm */
  26881.    NULL, /* unpack_z_float */
  26882.    NULL, /* pack_z_float */
  26883.    NULL, /* unpack_s_8uint */
  26884.    NULL, /* pack_s_8uint */
  26885.    &util_format_i32_sint_unpack_unsigned, /* unpack_rgba_uint */
  26886.    &util_format_i32_sint_pack_unsigned, /* pack_rgba_uint */
  26887.    &util_format_i32_sint_unpack_signed, /* unpack_rgba_sint */
  26888.    &util_format_i32_sint_pack_signed,  /* pack_rgba_sint */
  26889.    NULL,  /* fetch_rgba_uint */
  26890.    &util_format_i32_sint_fetch_signed  /* fetch_rgba_sint */
  26891. };
  26892.  
  26893. const struct util_format_description
  26894. util_format_l32_sint_description = {
  26895.    PIPE_FORMAT_L32_SINT,
  26896.    "PIPE_FORMAT_L32_SINT",
  26897.    "l32_sint",
  26898.    {1, 1, 32},  /* block */
  26899.    UTIL_FORMAT_LAYOUT_PLAIN,
  26900.    1,   /* nr_channels */
  26901.    TRUE,        /* is_array */
  26902.    TRUE,        /* is_bitmask */
  26903.    FALSE,       /* is_mixed */
  26904.    {
  26905.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = rgb */
  26906.       {0, 0, 0, 0, 0},
  26907.       {0, 0, 0, 0, 0},
  26908.       {0, 0, 0, 0, 0}
  26909.    },
  26910.    {
  26911.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26912.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26913.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26914.       UTIL_FORMAT_SWIZZLE_1     /* a */
  26915.    },
  26916.    UTIL_FORMAT_COLORSPACE_RGB,
  26917.    NULL, /* unpack_rgba_8unorm */
  26918.    NULL, /* pack_rgba_8unorm */
  26919.    NULL, /* fetch_rgba_8unorm */
  26920.    NULL, /* unpack_rgba_float */
  26921.    NULL, /* pack_rgba_float */
  26922.    NULL, /* fetch_rgba_float */
  26923.    NULL, /* unpack_z_32unorm */
  26924.    NULL, /* pack_z_32unorm */
  26925.    NULL, /* unpack_z_float */
  26926.    NULL, /* pack_z_float */
  26927.    NULL, /* unpack_s_8uint */
  26928.    NULL, /* pack_s_8uint */
  26929.    &util_format_l32_sint_unpack_unsigned, /* unpack_rgba_uint */
  26930.    &util_format_l32_sint_pack_unsigned, /* pack_rgba_uint */
  26931.    &util_format_l32_sint_unpack_signed, /* unpack_rgba_sint */
  26932.    &util_format_l32_sint_pack_signed,  /* pack_rgba_sint */
  26933.    NULL,  /* fetch_rgba_uint */
  26934.    &util_format_l32_sint_fetch_signed  /* fetch_rgba_sint */
  26935. };
  26936.  
  26937. const struct util_format_description
  26938. util_format_l32a32_sint_description = {
  26939.    PIPE_FORMAT_L32A32_SINT,
  26940.    "PIPE_FORMAT_L32A32_SINT",
  26941.    "l32a32_sint",
  26942.    {1, 1, 64},  /* block */
  26943.    UTIL_FORMAT_LAYOUT_PLAIN,
  26944.    2,   /* nr_channels */
  26945.    TRUE,        /* is_array */
  26946.    FALSE,       /* is_bitmask */
  26947.    FALSE,       /* is_mixed */
  26948.    {
  26949.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = rgb */
  26950.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = a */
  26951.       {0, 0, 0, 0, 0},
  26952.       {0, 0, 0, 0, 0}
  26953.    },
  26954.    {
  26955.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  26956.       UTIL_FORMAT_SWIZZLE_X,    /* g */
  26957.       UTIL_FORMAT_SWIZZLE_X,    /* b */
  26958.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  26959.    },
  26960.    UTIL_FORMAT_COLORSPACE_RGB,
  26961.    NULL, /* unpack_rgba_8unorm */
  26962.    NULL, /* pack_rgba_8unorm */
  26963.    NULL, /* fetch_rgba_8unorm */
  26964.    NULL, /* unpack_rgba_float */
  26965.    NULL, /* pack_rgba_float */
  26966.    NULL, /* fetch_rgba_float */
  26967.    NULL, /* unpack_z_32unorm */
  26968.    NULL, /* pack_z_32unorm */
  26969.    NULL, /* unpack_z_float */
  26970.    NULL, /* pack_z_float */
  26971.    NULL, /* unpack_s_8uint */
  26972.    NULL, /* pack_s_8uint */
  26973.    &util_format_l32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
  26974.    &util_format_l32a32_sint_pack_unsigned, /* pack_rgba_uint */
  26975.    &util_format_l32a32_sint_unpack_signed, /* unpack_rgba_sint */
  26976.    &util_format_l32a32_sint_pack_signed,  /* pack_rgba_sint */
  26977.    NULL,  /* fetch_rgba_uint */
  26978.    &util_format_l32a32_sint_fetch_signed  /* fetch_rgba_sint */
  26979. };
  26980.  
  26981. const struct util_format_description
  26982. util_format_r8g8b8x8_snorm_description = {
  26983.    PIPE_FORMAT_R8G8B8X8_SNORM,
  26984.    "PIPE_FORMAT_R8G8B8X8_SNORM",
  26985.    "r8g8b8x8_snorm",
  26986.    {1, 1, 32},  /* block */
  26987.    UTIL_FORMAT_LAYOUT_PLAIN,
  26988.    4,   /* nr_channels */
  26989.    TRUE,        /* is_array */
  26990.    TRUE,        /* is_bitmask */
  26991.    FALSE,       /* is_mixed */
  26992.    {
  26993.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  26994.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = g */
  26995.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16},    /* z = b */
  26996.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  26997.    },
  26998.    {
  26999.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27000.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27001.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27002.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27003.    },
  27004.    UTIL_FORMAT_COLORSPACE_RGB,
  27005.    &util_format_r8g8b8x8_snorm_unpack_rgba_8unorm,
  27006.    &util_format_r8g8b8x8_snorm_pack_rgba_8unorm,
  27007.    NULL, /* fetch_rgba_8unorm */
  27008.    &util_format_r8g8b8x8_snorm_unpack_rgba_float,
  27009.    &util_format_r8g8b8x8_snorm_pack_rgba_float,
  27010.    &util_format_r8g8b8x8_snorm_fetch_rgba_float,
  27011.    NULL, /* unpack_z_32unorm */
  27012.    NULL, /* pack_z_32unorm */
  27013.    NULL, /* unpack_z_float */
  27014.    NULL, /* pack_z_float */
  27015.    NULL, /* unpack_s_8uint */
  27016.    NULL, /* pack_s_8uint */
  27017.    NULL, /* unpack_rgba_uint */
  27018.    NULL, /* pack_rgba_uint */
  27019.    NULL, /* unpack_rgba_sint */
  27020.    NULL, /* pack_rgba_sint */
  27021.    NULL, /* fetch_rgba_uint */
  27022.    NULL  /* fetch_rgba_sint */
  27023. };
  27024.  
  27025. const struct util_format_description
  27026. util_format_r8g8b8x8_srgb_description = {
  27027.    PIPE_FORMAT_R8G8B8X8_SRGB,
  27028.    "PIPE_FORMAT_R8G8B8X8_SRGB",
  27029.    "r8g8b8x8_srgb",
  27030.    {1, 1, 32},  /* block */
  27031.    UTIL_FORMAT_LAYOUT_PLAIN,
  27032.    4,   /* nr_channels */
  27033.    TRUE,        /* is_array */
  27034.    TRUE,        /* is_bitmask */
  27035.    FALSE,       /* is_mixed */
  27036.    {
  27037.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0},   /* x = r */
  27038.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8},   /* y = g */
  27039.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16},  /* z = b */
  27040.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  27041.    },
  27042.    {
  27043.       UTIL_FORMAT_SWIZZLE_X,    /* sr */
  27044.       UTIL_FORMAT_SWIZZLE_Y,    /* sg */
  27045.       UTIL_FORMAT_SWIZZLE_Z,    /* sb */
  27046.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27047.    },
  27048.    UTIL_FORMAT_COLORSPACE_SRGB,
  27049.    &util_format_r8g8b8x8_srgb_unpack_rgba_8unorm,
  27050.    &util_format_r8g8b8x8_srgb_pack_rgba_8unorm,
  27051.    NULL, /* fetch_rgba_8unorm */
  27052.    &util_format_r8g8b8x8_srgb_unpack_rgba_float,
  27053.    &util_format_r8g8b8x8_srgb_pack_rgba_float,
  27054.    &util_format_r8g8b8x8_srgb_fetch_rgba_float,
  27055.    NULL, /* unpack_z_32unorm */
  27056.    NULL, /* pack_z_32unorm */
  27057.    NULL, /* unpack_z_float */
  27058.    NULL, /* pack_z_float */
  27059.    NULL, /* unpack_s_8uint */
  27060.    NULL, /* pack_s_8uint */
  27061.    NULL, /* unpack_rgba_uint */
  27062.    NULL, /* pack_rgba_uint */
  27063.    NULL, /* unpack_rgba_sint */
  27064.    NULL, /* pack_rgba_sint */
  27065.    NULL, /* fetch_rgba_uint */
  27066.    NULL  /* fetch_rgba_sint */
  27067. };
  27068.  
  27069. const struct util_format_description
  27070. util_format_r8g8b8x8_uint_description = {
  27071.    PIPE_FORMAT_R8G8B8X8_UINT,
  27072.    "PIPE_FORMAT_R8G8B8X8_UINT",
  27073.    "r8g8b8x8_uint",
  27074.    {1, 1, 32},  /* block */
  27075.    UTIL_FORMAT_LAYOUT_PLAIN,
  27076.    4,   /* nr_channels */
  27077.    TRUE,        /* is_array */
  27078.    TRUE,        /* is_bitmask */
  27079.    FALSE,       /* is_mixed */
  27080.    {
  27081.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  27082.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = g */
  27083.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16},  /* z = b */
  27084.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  27085.    },
  27086.    {
  27087.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27088.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27089.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27090.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27091.    },
  27092.    UTIL_FORMAT_COLORSPACE_RGB,
  27093.    NULL, /* unpack_rgba_8unorm */
  27094.    NULL, /* pack_rgba_8unorm */
  27095.    NULL, /* fetch_rgba_8unorm */
  27096.    NULL, /* unpack_rgba_float */
  27097.    NULL, /* pack_rgba_float */
  27098.    NULL, /* fetch_rgba_float */
  27099.    NULL, /* unpack_z_32unorm */
  27100.    NULL, /* pack_z_32unorm */
  27101.    NULL, /* unpack_z_float */
  27102.    NULL, /* pack_z_float */
  27103.    NULL, /* unpack_s_8uint */
  27104.    NULL, /* pack_s_8uint */
  27105.    &util_format_r8g8b8x8_uint_unpack_unsigned, /* unpack_rgba_uint */
  27106.    &util_format_r8g8b8x8_uint_pack_unsigned, /* pack_rgba_uint */
  27107.    &util_format_r8g8b8x8_uint_unpack_signed, /* unpack_rgba_sint */
  27108.    &util_format_r8g8b8x8_uint_pack_signed,  /* pack_rgba_sint */
  27109.    &util_format_r8g8b8x8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27110.    NULL  /* fetch_rgba_sint */
  27111. };
  27112.  
  27113. const struct util_format_description
  27114. util_format_r8g8b8x8_sint_description = {
  27115.    PIPE_FORMAT_R8G8B8X8_SINT,
  27116.    "PIPE_FORMAT_R8G8B8X8_SINT",
  27117.    "r8g8b8x8_sint",
  27118.    {1, 1, 32},  /* block */
  27119.    UTIL_FORMAT_LAYOUT_PLAIN,
  27120.    4,   /* nr_channels */
  27121.    TRUE,        /* is_array */
  27122.    TRUE,        /* is_bitmask */
  27123.    FALSE,       /* is_mixed */
  27124.    {
  27125.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  27126.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = g */
  27127.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16},    /* z = b */
  27128.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}      /* w = x */
  27129.    },
  27130.    {
  27131.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27132.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27133.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27134.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27135.    },
  27136.    UTIL_FORMAT_COLORSPACE_RGB,
  27137.    NULL, /* unpack_rgba_8unorm */
  27138.    NULL, /* pack_rgba_8unorm */
  27139.    NULL, /* fetch_rgba_8unorm */
  27140.    NULL, /* unpack_rgba_float */
  27141.    NULL, /* pack_rgba_float */
  27142.    NULL, /* fetch_rgba_float */
  27143.    NULL, /* unpack_z_32unorm */
  27144.    NULL, /* pack_z_32unorm */
  27145.    NULL, /* unpack_z_float */
  27146.    NULL, /* pack_z_float */
  27147.    NULL, /* unpack_s_8uint */
  27148.    NULL, /* pack_s_8uint */
  27149.    &util_format_r8g8b8x8_sint_unpack_unsigned, /* unpack_rgba_uint */
  27150.    &util_format_r8g8b8x8_sint_pack_unsigned, /* pack_rgba_uint */
  27151.    &util_format_r8g8b8x8_sint_unpack_signed, /* unpack_rgba_sint */
  27152.    &util_format_r8g8b8x8_sint_pack_signed,  /* pack_rgba_sint */
  27153.    NULL,  /* fetch_rgba_uint */
  27154.    &util_format_r8g8b8x8_sint_fetch_signed  /* fetch_rgba_sint */
  27155. };
  27156.  
  27157. const struct util_format_description
  27158. util_format_r16g16b16x16_unorm_description = {
  27159.    PIPE_FORMAT_R16G16B16X16_UNORM,
  27160.    "PIPE_FORMAT_R16G16B16X16_UNORM",
  27161.    "r16g16b16x16_unorm",
  27162.    {1, 1, 64},  /* block */
  27163.    UTIL_FORMAT_LAYOUT_PLAIN,
  27164.    4,   /* nr_channels */
  27165.    TRUE,        /* is_array */
  27166.    FALSE,       /* is_bitmask */
  27167.    FALSE,       /* is_mixed */
  27168.    {
  27169.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  27170.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */
  27171.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */
  27172.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48}     /* w = x */
  27173.    },
  27174.    {
  27175.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27176.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27177.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27178.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27179.    },
  27180.    UTIL_FORMAT_COLORSPACE_RGB,
  27181.    &util_format_r16g16b16x16_unorm_unpack_rgba_8unorm,
  27182.    &util_format_r16g16b16x16_unorm_pack_rgba_8unorm,
  27183.    NULL, /* fetch_rgba_8unorm */
  27184.    &util_format_r16g16b16x16_unorm_unpack_rgba_float,
  27185.    &util_format_r16g16b16x16_unorm_pack_rgba_float,
  27186.    &util_format_r16g16b16x16_unorm_fetch_rgba_float,
  27187.    NULL, /* unpack_z_32unorm */
  27188.    NULL, /* pack_z_32unorm */
  27189.    NULL, /* unpack_z_float */
  27190.    NULL, /* pack_z_float */
  27191.    NULL, /* unpack_s_8uint */
  27192.    NULL, /* pack_s_8uint */
  27193.    NULL, /* unpack_rgba_uint */
  27194.    NULL, /* pack_rgba_uint */
  27195.    NULL, /* unpack_rgba_sint */
  27196.    NULL, /* pack_rgba_sint */
  27197.    NULL, /* fetch_rgba_uint */
  27198.    NULL  /* fetch_rgba_sint */
  27199. };
  27200.  
  27201. const struct util_format_description
  27202. util_format_r16g16b16x16_snorm_description = {
  27203.    PIPE_FORMAT_R16G16B16X16_SNORM,
  27204.    "PIPE_FORMAT_R16G16B16X16_SNORM",
  27205.    "r16g16b16x16_snorm",
  27206.    {1, 1, 64},  /* block */
  27207.    UTIL_FORMAT_LAYOUT_PLAIN,
  27208.    4,   /* nr_channels */
  27209.    TRUE,        /* is_array */
  27210.    FALSE,       /* is_bitmask */
  27211.    FALSE,       /* is_mixed */
  27212.    {
  27213.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  27214.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = g */
  27215.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32},   /* z = b */
  27216.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48}     /* w = x */
  27217.    },
  27218.    {
  27219.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27220.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27221.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27222.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27223.    },
  27224.    UTIL_FORMAT_COLORSPACE_RGB,
  27225.    &util_format_r16g16b16x16_snorm_unpack_rgba_8unorm,
  27226.    &util_format_r16g16b16x16_snorm_pack_rgba_8unorm,
  27227.    NULL, /* fetch_rgba_8unorm */
  27228.    &util_format_r16g16b16x16_snorm_unpack_rgba_float,
  27229.    &util_format_r16g16b16x16_snorm_pack_rgba_float,
  27230.    &util_format_r16g16b16x16_snorm_fetch_rgba_float,
  27231.    NULL, /* unpack_z_32unorm */
  27232.    NULL, /* pack_z_32unorm */
  27233.    NULL, /* unpack_z_float */
  27234.    NULL, /* pack_z_float */
  27235.    NULL, /* unpack_s_8uint */
  27236.    NULL, /* pack_s_8uint */
  27237.    NULL, /* unpack_rgba_uint */
  27238.    NULL, /* pack_rgba_uint */
  27239.    NULL, /* unpack_rgba_sint */
  27240.    NULL, /* pack_rgba_sint */
  27241.    NULL, /* fetch_rgba_uint */
  27242.    NULL  /* fetch_rgba_sint */
  27243. };
  27244.  
  27245. const struct util_format_description
  27246. util_format_r16g16b16x16_float_description = {
  27247.    PIPE_FORMAT_R16G16B16X16_FLOAT,
  27248.    "PIPE_FORMAT_R16G16B16X16_FLOAT",
  27249.    "r16g16b16x16_float",
  27250.    {1, 1, 64},  /* block */
  27251.    UTIL_FORMAT_LAYOUT_PLAIN,
  27252.    4,   /* nr_channels */
  27253.    TRUE,        /* is_array */
  27254.    FALSE,       /* is_bitmask */
  27255.    FALSE,       /* is_mixed */
  27256.    {
  27257.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  27258.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = g */
  27259.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32},   /* z = b */
  27260.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48}     /* w = x */
  27261.    },
  27262.    {
  27263.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27264.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27265.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27266.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27267.    },
  27268.    UTIL_FORMAT_COLORSPACE_RGB,
  27269.    &util_format_r16g16b16x16_float_unpack_rgba_8unorm,
  27270.    &util_format_r16g16b16x16_float_pack_rgba_8unorm,
  27271.    NULL, /* fetch_rgba_8unorm */
  27272.    &util_format_r16g16b16x16_float_unpack_rgba_float,
  27273.    &util_format_r16g16b16x16_float_pack_rgba_float,
  27274.    &util_format_r16g16b16x16_float_fetch_rgba_float,
  27275.    NULL, /* unpack_z_32unorm */
  27276.    NULL, /* pack_z_32unorm */
  27277.    NULL, /* unpack_z_float */
  27278.    NULL, /* pack_z_float */
  27279.    NULL, /* unpack_s_8uint */
  27280.    NULL, /* pack_s_8uint */
  27281.    NULL, /* unpack_rgba_uint */
  27282.    NULL, /* pack_rgba_uint */
  27283.    NULL, /* unpack_rgba_sint */
  27284.    NULL, /* pack_rgba_sint */
  27285.    NULL, /* fetch_rgba_uint */
  27286.    NULL  /* fetch_rgba_sint */
  27287. };
  27288.  
  27289. const struct util_format_description
  27290. util_format_r16g16b16x16_uint_description = {
  27291.    PIPE_FORMAT_R16G16B16X16_UINT,
  27292.    "PIPE_FORMAT_R16G16B16X16_UINT",
  27293.    "r16g16b16x16_uint",
  27294.    {1, 1, 64},  /* block */
  27295.    UTIL_FORMAT_LAYOUT_PLAIN,
  27296.    4,   /* nr_channels */
  27297.    TRUE,        /* is_array */
  27298.    FALSE,       /* is_bitmask */
  27299.    FALSE,       /* is_mixed */
  27300.    {
  27301.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  27302.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */
  27303.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */
  27304.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48}     /* w = x */
  27305.    },
  27306.    {
  27307.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27308.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27309.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27310.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27311.    },
  27312.    UTIL_FORMAT_COLORSPACE_RGB,
  27313.    NULL, /* unpack_rgba_8unorm */
  27314.    NULL, /* pack_rgba_8unorm */
  27315.    NULL, /* fetch_rgba_8unorm */
  27316.    NULL, /* unpack_rgba_float */
  27317.    NULL, /* pack_rgba_float */
  27318.    NULL, /* fetch_rgba_float */
  27319.    NULL, /* unpack_z_32unorm */
  27320.    NULL, /* pack_z_32unorm */
  27321.    NULL, /* unpack_z_float */
  27322.    NULL, /* pack_z_float */
  27323.    NULL, /* unpack_s_8uint */
  27324.    NULL, /* pack_s_8uint */
  27325.    &util_format_r16g16b16x16_uint_unpack_unsigned, /* unpack_rgba_uint */
  27326.    &util_format_r16g16b16x16_uint_pack_unsigned, /* pack_rgba_uint */
  27327.    &util_format_r16g16b16x16_uint_unpack_signed, /* unpack_rgba_sint */
  27328.    &util_format_r16g16b16x16_uint_pack_signed,  /* pack_rgba_sint */
  27329.    &util_format_r16g16b16x16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27330.    NULL  /* fetch_rgba_sint */
  27331. };
  27332.  
  27333. const struct util_format_description
  27334. util_format_r16g16b16x16_sint_description = {
  27335.    PIPE_FORMAT_R16G16B16X16_SINT,
  27336.    "PIPE_FORMAT_R16G16B16X16_SINT",
  27337.    "r16g16b16x16_sint",
  27338.    {1, 1, 64},  /* block */
  27339.    UTIL_FORMAT_LAYOUT_PLAIN,
  27340.    4,   /* nr_channels */
  27341.    TRUE,        /* is_array */
  27342.    FALSE,       /* is_bitmask */
  27343.    FALSE,       /* is_mixed */
  27344.    {
  27345.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  27346.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = g */
  27347.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32},   /* z = b */
  27348.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48}     /* w = x */
  27349.    },
  27350.    {
  27351.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27352.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27353.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27354.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27355.    },
  27356.    UTIL_FORMAT_COLORSPACE_RGB,
  27357.    NULL, /* unpack_rgba_8unorm */
  27358.    NULL, /* pack_rgba_8unorm */
  27359.    NULL, /* fetch_rgba_8unorm */
  27360.    NULL, /* unpack_rgba_float */
  27361.    NULL, /* pack_rgba_float */
  27362.    NULL, /* fetch_rgba_float */
  27363.    NULL, /* unpack_z_32unorm */
  27364.    NULL, /* pack_z_32unorm */
  27365.    NULL, /* unpack_z_float */
  27366.    NULL, /* pack_z_float */
  27367.    NULL, /* unpack_s_8uint */
  27368.    NULL, /* pack_s_8uint */
  27369.    &util_format_r16g16b16x16_sint_unpack_unsigned, /* unpack_rgba_uint */
  27370.    &util_format_r16g16b16x16_sint_pack_unsigned, /* pack_rgba_uint */
  27371.    &util_format_r16g16b16x16_sint_unpack_signed, /* unpack_rgba_sint */
  27372.    &util_format_r16g16b16x16_sint_pack_signed,  /* pack_rgba_sint */
  27373.    NULL,  /* fetch_rgba_uint */
  27374.    &util_format_r16g16b16x16_sint_fetch_signed  /* fetch_rgba_sint */
  27375. };
  27376.  
  27377. const struct util_format_description
  27378. util_format_r32g32b32x32_float_description = {
  27379.    PIPE_FORMAT_R32G32B32X32_FLOAT,
  27380.    "PIPE_FORMAT_R32G32B32X32_FLOAT",
  27381.    "r32g32b32x32_float",
  27382.    {1, 1, 128}, /* block */
  27383.    UTIL_FORMAT_LAYOUT_PLAIN,
  27384.    4,   /* nr_channels */
  27385.    TRUE,        /* is_array */
  27386.    FALSE,       /* is_bitmask */
  27387.    FALSE,       /* is_mixed */
  27388.    {
  27389.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  27390.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = g */
  27391.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64},   /* z = b */
  27392.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96}     /* w = x */
  27393.    },
  27394.    {
  27395.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27396.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27397.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27398.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27399.    },
  27400.    UTIL_FORMAT_COLORSPACE_RGB,
  27401.    &util_format_r32g32b32x32_float_unpack_rgba_8unorm,
  27402.    &util_format_r32g32b32x32_float_pack_rgba_8unorm,
  27403.    NULL, /* fetch_rgba_8unorm */
  27404.    &util_format_r32g32b32x32_float_unpack_rgba_float,
  27405.    &util_format_r32g32b32x32_float_pack_rgba_float,
  27406.    &util_format_r32g32b32x32_float_fetch_rgba_float,
  27407.    NULL, /* unpack_z_32unorm */
  27408.    NULL, /* pack_z_32unorm */
  27409.    NULL, /* unpack_z_float */
  27410.    NULL, /* pack_z_float */
  27411.    NULL, /* unpack_s_8uint */
  27412.    NULL, /* pack_s_8uint */
  27413.    NULL, /* unpack_rgba_uint */
  27414.    NULL, /* pack_rgba_uint */
  27415.    NULL, /* unpack_rgba_sint */
  27416.    NULL, /* pack_rgba_sint */
  27417.    NULL, /* fetch_rgba_uint */
  27418.    NULL  /* fetch_rgba_sint */
  27419. };
  27420.  
  27421. const struct util_format_description
  27422. util_format_r32g32b32x32_uint_description = {
  27423.    PIPE_FORMAT_R32G32B32X32_UINT,
  27424.    "PIPE_FORMAT_R32G32B32X32_UINT",
  27425.    "r32g32b32x32_uint",
  27426.    {1, 1, 128}, /* block */
  27427.    UTIL_FORMAT_LAYOUT_PLAIN,
  27428.    4,   /* nr_channels */
  27429.    TRUE,        /* is_array */
  27430.    FALSE,       /* is_bitmask */
  27431.    FALSE,       /* is_mixed */
  27432.    {
  27433.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  27434.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */
  27435.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */
  27436.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96}     /* w = x */
  27437.    },
  27438.    {
  27439.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27440.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27441.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27442.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27443.    },
  27444.    UTIL_FORMAT_COLORSPACE_RGB,
  27445.    NULL, /* unpack_rgba_8unorm */
  27446.    NULL, /* pack_rgba_8unorm */
  27447.    NULL, /* fetch_rgba_8unorm */
  27448.    NULL, /* unpack_rgba_float */
  27449.    NULL, /* pack_rgba_float */
  27450.    NULL, /* fetch_rgba_float */
  27451.    NULL, /* unpack_z_32unorm */
  27452.    NULL, /* pack_z_32unorm */
  27453.    NULL, /* unpack_z_float */
  27454.    NULL, /* pack_z_float */
  27455.    NULL, /* unpack_s_8uint */
  27456.    NULL, /* pack_s_8uint */
  27457.    &util_format_r32g32b32x32_uint_unpack_unsigned, /* unpack_rgba_uint */
  27458.    &util_format_r32g32b32x32_uint_pack_unsigned, /* pack_rgba_uint */
  27459.    &util_format_r32g32b32x32_uint_unpack_signed, /* unpack_rgba_sint */
  27460.    &util_format_r32g32b32x32_uint_pack_signed,  /* pack_rgba_sint */
  27461.    &util_format_r32g32b32x32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27462.    NULL  /* fetch_rgba_sint */
  27463. };
  27464.  
  27465. const struct util_format_description
  27466. util_format_r32g32b32x32_sint_description = {
  27467.    PIPE_FORMAT_R32G32B32X32_SINT,
  27468.    "PIPE_FORMAT_R32G32B32X32_SINT",
  27469.    "r32g32b32x32_sint",
  27470.    {1, 1, 128}, /* block */
  27471.    UTIL_FORMAT_LAYOUT_PLAIN,
  27472.    4,   /* nr_channels */
  27473.    TRUE,        /* is_array */
  27474.    FALSE,       /* is_bitmask */
  27475.    FALSE,       /* is_mixed */
  27476.    {
  27477.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  27478.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = g */
  27479.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64},   /* z = b */
  27480.       {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96}     /* w = x */
  27481.    },
  27482.    {
  27483.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27484.       UTIL_FORMAT_SWIZZLE_Y,    /* g */
  27485.       UTIL_FORMAT_SWIZZLE_Z,    /* b */
  27486.       UTIL_FORMAT_SWIZZLE_1     /* a */
  27487.    },
  27488.    UTIL_FORMAT_COLORSPACE_RGB,
  27489.    NULL, /* unpack_rgba_8unorm */
  27490.    NULL, /* pack_rgba_8unorm */
  27491.    NULL, /* fetch_rgba_8unorm */
  27492.    NULL, /* unpack_rgba_float */
  27493.    NULL, /* pack_rgba_float */
  27494.    NULL, /* fetch_rgba_float */
  27495.    NULL, /* unpack_z_32unorm */
  27496.    NULL, /* pack_z_32unorm */
  27497.    NULL, /* unpack_z_float */
  27498.    NULL, /* pack_z_float */
  27499.    NULL, /* unpack_s_8uint */
  27500.    NULL, /* pack_s_8uint */
  27501.    &util_format_r32g32b32x32_sint_unpack_unsigned, /* unpack_rgba_uint */
  27502.    &util_format_r32g32b32x32_sint_pack_unsigned, /* pack_rgba_uint */
  27503.    &util_format_r32g32b32x32_sint_unpack_signed, /* unpack_rgba_sint */
  27504.    &util_format_r32g32b32x32_sint_pack_signed,  /* pack_rgba_sint */
  27505.    NULL,  /* fetch_rgba_uint */
  27506.    &util_format_r32g32b32x32_sint_fetch_signed  /* fetch_rgba_sint */
  27507. };
  27508.  
  27509. const struct util_format_description
  27510. util_format_r8a8_snorm_description = {
  27511.    PIPE_FORMAT_R8A8_SNORM,
  27512.    "PIPE_FORMAT_R8A8_SNORM",
  27513.    "r8a8_snorm",
  27514.    {1, 1, 16},  /* block */
  27515.    UTIL_FORMAT_LAYOUT_PLAIN,
  27516.    2,   /* nr_channels */
  27517.    TRUE,        /* is_array */
  27518.    TRUE,        /* is_bitmask */
  27519.    FALSE,       /* is_mixed */
  27520.    {
  27521.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0},     /* x = r */
  27522.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8},     /* y = a */
  27523.       {0, 0, 0, 0, 0},
  27524.       {0, 0, 0, 0, 0}
  27525.    },
  27526.    {
  27527.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27528.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27529.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27530.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27531.    },
  27532.    UTIL_FORMAT_COLORSPACE_RGB,
  27533.    &util_format_r8a8_snorm_unpack_rgba_8unorm,
  27534.    &util_format_r8a8_snorm_pack_rgba_8unorm,
  27535.    NULL, /* fetch_rgba_8unorm */
  27536.    &util_format_r8a8_snorm_unpack_rgba_float,
  27537.    &util_format_r8a8_snorm_pack_rgba_float,
  27538.    &util_format_r8a8_snorm_fetch_rgba_float,
  27539.    NULL, /* unpack_z_32unorm */
  27540.    NULL, /* pack_z_32unorm */
  27541.    NULL, /* unpack_z_float */
  27542.    NULL, /* pack_z_float */
  27543.    NULL, /* unpack_s_8uint */
  27544.    NULL, /* pack_s_8uint */
  27545.    NULL, /* unpack_rgba_uint */
  27546.    NULL, /* pack_rgba_uint */
  27547.    NULL, /* unpack_rgba_sint */
  27548.    NULL, /* pack_rgba_sint */
  27549.    NULL, /* fetch_rgba_uint */
  27550.    NULL  /* fetch_rgba_sint */
  27551. };
  27552.  
  27553. const struct util_format_description
  27554. util_format_r16a16_unorm_description = {
  27555.    PIPE_FORMAT_R16A16_UNORM,
  27556.    "PIPE_FORMAT_R16A16_UNORM",
  27557.    "r16a16_unorm",
  27558.    {1, 1, 32},  /* block */
  27559.    UTIL_FORMAT_LAYOUT_PLAIN,
  27560.    2,   /* nr_channels */
  27561.    TRUE,        /* is_array */
  27562.    TRUE,        /* is_bitmask */
  27563.    FALSE,       /* is_mixed */
  27564.    {
  27565.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0},  /* x = r */
  27566.       {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */
  27567.       {0, 0, 0, 0, 0},
  27568.       {0, 0, 0, 0, 0}
  27569.    },
  27570.    {
  27571.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27572.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27573.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27574.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27575.    },
  27576.    UTIL_FORMAT_COLORSPACE_RGB,
  27577.    &util_format_r16a16_unorm_unpack_rgba_8unorm,
  27578.    &util_format_r16a16_unorm_pack_rgba_8unorm,
  27579.    NULL, /* fetch_rgba_8unorm */
  27580.    &util_format_r16a16_unorm_unpack_rgba_float,
  27581.    &util_format_r16a16_unorm_pack_rgba_float,
  27582.    &util_format_r16a16_unorm_fetch_rgba_float,
  27583.    NULL, /* unpack_z_32unorm */
  27584.    NULL, /* pack_z_32unorm */
  27585.    NULL, /* unpack_z_float */
  27586.    NULL, /* pack_z_float */
  27587.    NULL, /* unpack_s_8uint */
  27588.    NULL, /* pack_s_8uint */
  27589.    NULL, /* unpack_rgba_uint */
  27590.    NULL, /* pack_rgba_uint */
  27591.    NULL, /* unpack_rgba_sint */
  27592.    NULL, /* pack_rgba_sint */
  27593.    NULL, /* fetch_rgba_uint */
  27594.    NULL  /* fetch_rgba_sint */
  27595. };
  27596.  
  27597. const struct util_format_description
  27598. util_format_r16a16_snorm_description = {
  27599.    PIPE_FORMAT_R16A16_SNORM,
  27600.    "PIPE_FORMAT_R16A16_SNORM",
  27601.    "r16a16_snorm",
  27602.    {1, 1, 32},  /* block */
  27603.    UTIL_FORMAT_LAYOUT_PLAIN,
  27604.    2,   /* nr_channels */
  27605.    TRUE,        /* is_array */
  27606.    TRUE,        /* is_bitmask */
  27607.    FALSE,       /* is_mixed */
  27608.    {
  27609.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0},    /* x = r */
  27610.       {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16},   /* y = a */
  27611.       {0, 0, 0, 0, 0},
  27612.       {0, 0, 0, 0, 0}
  27613.    },
  27614.    {
  27615.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27616.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27617.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27618.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27619.    },
  27620.    UTIL_FORMAT_COLORSPACE_RGB,
  27621.    &util_format_r16a16_snorm_unpack_rgba_8unorm,
  27622.    &util_format_r16a16_snorm_pack_rgba_8unorm,
  27623.    NULL, /* fetch_rgba_8unorm */
  27624.    &util_format_r16a16_snorm_unpack_rgba_float,
  27625.    &util_format_r16a16_snorm_pack_rgba_float,
  27626.    &util_format_r16a16_snorm_fetch_rgba_float,
  27627.    NULL, /* unpack_z_32unorm */
  27628.    NULL, /* pack_z_32unorm */
  27629.    NULL, /* unpack_z_float */
  27630.    NULL, /* pack_z_float */
  27631.    NULL, /* unpack_s_8uint */
  27632.    NULL, /* pack_s_8uint */
  27633.    NULL, /* unpack_rgba_uint */
  27634.    NULL, /* pack_rgba_uint */
  27635.    NULL, /* unpack_rgba_sint */
  27636.    NULL, /* pack_rgba_sint */
  27637.    NULL, /* fetch_rgba_uint */
  27638.    NULL  /* fetch_rgba_sint */
  27639. };
  27640.  
  27641. const struct util_format_description
  27642. util_format_r16a16_float_description = {
  27643.    PIPE_FORMAT_R16A16_FLOAT,
  27644.    "PIPE_FORMAT_R16A16_FLOAT",
  27645.    "r16a16_float",
  27646.    {1, 1, 32},  /* block */
  27647.    UTIL_FORMAT_LAYOUT_PLAIN,
  27648.    2,   /* nr_channels */
  27649.    TRUE,        /* is_array */
  27650.    FALSE,       /* is_bitmask */
  27651.    FALSE,       /* is_mixed */
  27652.    {
  27653.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0},    /* x = r */
  27654.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16},   /* y = a */
  27655.       {0, 0, 0, 0, 0},
  27656.       {0, 0, 0, 0, 0}
  27657.    },
  27658.    {
  27659.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27660.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27661.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27662.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27663.    },
  27664.    UTIL_FORMAT_COLORSPACE_RGB,
  27665.    &util_format_r16a16_float_unpack_rgba_8unorm,
  27666.    &util_format_r16a16_float_pack_rgba_8unorm,
  27667.    NULL, /* fetch_rgba_8unorm */
  27668.    &util_format_r16a16_float_unpack_rgba_float,
  27669.    &util_format_r16a16_float_pack_rgba_float,
  27670.    &util_format_r16a16_float_fetch_rgba_float,
  27671.    NULL, /* unpack_z_32unorm */
  27672.    NULL, /* pack_z_32unorm */
  27673.    NULL, /* unpack_z_float */
  27674.    NULL, /* pack_z_float */
  27675.    NULL, /* unpack_s_8uint */
  27676.    NULL, /* pack_s_8uint */
  27677.    NULL, /* unpack_rgba_uint */
  27678.    NULL, /* pack_rgba_uint */
  27679.    NULL, /* unpack_rgba_sint */
  27680.    NULL, /* pack_rgba_sint */
  27681.    NULL, /* fetch_rgba_uint */
  27682.    NULL  /* fetch_rgba_sint */
  27683. };
  27684.  
  27685. const struct util_format_description
  27686. util_format_r32a32_float_description = {
  27687.    PIPE_FORMAT_R32A32_FLOAT,
  27688.    "PIPE_FORMAT_R32A32_FLOAT",
  27689.    "r32a32_float",
  27690.    {1, 1, 64},  /* block */
  27691.    UTIL_FORMAT_LAYOUT_PLAIN,
  27692.    2,   /* nr_channels */
  27693.    TRUE,        /* is_array */
  27694.    FALSE,       /* is_bitmask */
  27695.    FALSE,       /* is_mixed */
  27696.    {
  27697.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0},    /* x = r */
  27698.       {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32},   /* y = a */
  27699.       {0, 0, 0, 0, 0},
  27700.       {0, 0, 0, 0, 0}
  27701.    },
  27702.    {
  27703.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27704.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27705.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27706.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27707.    },
  27708.    UTIL_FORMAT_COLORSPACE_RGB,
  27709.    &util_format_r32a32_float_unpack_rgba_8unorm,
  27710.    &util_format_r32a32_float_pack_rgba_8unorm,
  27711.    NULL, /* fetch_rgba_8unorm */
  27712.    &util_format_r32a32_float_unpack_rgba_float,
  27713.    &util_format_r32a32_float_pack_rgba_float,
  27714.    &util_format_r32a32_float_fetch_rgba_float,
  27715.    NULL, /* unpack_z_32unorm */
  27716.    NULL, /* pack_z_32unorm */
  27717.    NULL, /* unpack_z_float */
  27718.    NULL, /* pack_z_float */
  27719.    NULL, /* unpack_s_8uint */
  27720.    NULL, /* pack_s_8uint */
  27721.    NULL, /* unpack_rgba_uint */
  27722.    NULL, /* pack_rgba_uint */
  27723.    NULL, /* unpack_rgba_sint */
  27724.    NULL, /* pack_rgba_sint */
  27725.    NULL, /* fetch_rgba_uint */
  27726.    NULL  /* fetch_rgba_sint */
  27727. };
  27728.  
  27729. const struct util_format_description
  27730. util_format_r8a8_uint_description = {
  27731.    PIPE_FORMAT_R8A8_UINT,
  27732.    "PIPE_FORMAT_R8A8_UINT",
  27733.    "r8a8_uint",
  27734.    {1, 1, 16},  /* block */
  27735.    UTIL_FORMAT_LAYOUT_PLAIN,
  27736.    2,   /* nr_channels */
  27737.    TRUE,        /* is_array */
  27738.    TRUE,        /* is_bitmask */
  27739.    FALSE,       /* is_mixed */
  27740.    {
  27741.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0},   /* x = r */
  27742.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8},   /* y = a */
  27743.       {0, 0, 0, 0, 0},
  27744.       {0, 0, 0, 0, 0}
  27745.    },
  27746.    {
  27747.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27748.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27749.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27750.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27751.    },
  27752.    UTIL_FORMAT_COLORSPACE_RGB,
  27753.    NULL, /* unpack_rgba_8unorm */
  27754.    NULL, /* pack_rgba_8unorm */
  27755.    NULL, /* fetch_rgba_8unorm */
  27756.    NULL, /* unpack_rgba_float */
  27757.    NULL, /* pack_rgba_float */
  27758.    NULL, /* fetch_rgba_float */
  27759.    NULL, /* unpack_z_32unorm */
  27760.    NULL, /* pack_z_32unorm */
  27761.    NULL, /* unpack_z_float */
  27762.    NULL, /* pack_z_float */
  27763.    NULL, /* unpack_s_8uint */
  27764.    NULL, /* pack_s_8uint */
  27765.    &util_format_r8a8_uint_unpack_unsigned, /* unpack_rgba_uint */
  27766.    &util_format_r8a8_uint_pack_unsigned, /* pack_rgba_uint */
  27767.    &util_format_r8a8_uint_unpack_signed, /* unpack_rgba_sint */
  27768.    &util_format_r8a8_uint_pack_signed,  /* pack_rgba_sint */
  27769.    &util_format_r8a8_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27770.    NULL  /* fetch_rgba_sint */
  27771. };
  27772.  
  27773. const struct util_format_description
  27774. util_format_r8a8_sint_description = {
  27775.    PIPE_FORMAT_R8A8_SINT,
  27776.    "PIPE_FORMAT_R8A8_SINT",
  27777.    "r8a8_sint",
  27778.    {1, 1, 16},  /* block */
  27779.    UTIL_FORMAT_LAYOUT_PLAIN,
  27780.    2,   /* nr_channels */
  27781.    TRUE,        /* is_array */
  27782.    TRUE,        /* is_bitmask */
  27783.    FALSE,       /* is_mixed */
  27784.    {
  27785.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0},     /* x = r */
  27786.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8},     /* y = a */
  27787.       {0, 0, 0, 0, 0},
  27788.       {0, 0, 0, 0, 0}
  27789.    },
  27790.    {
  27791.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27792.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27793.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27794.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27795.    },
  27796.    UTIL_FORMAT_COLORSPACE_RGB,
  27797.    NULL, /* unpack_rgba_8unorm */
  27798.    NULL, /* pack_rgba_8unorm */
  27799.    NULL, /* fetch_rgba_8unorm */
  27800.    NULL, /* unpack_rgba_float */
  27801.    NULL, /* pack_rgba_float */
  27802.    NULL, /* fetch_rgba_float */
  27803.    NULL, /* unpack_z_32unorm */
  27804.    NULL, /* pack_z_32unorm */
  27805.    NULL, /* unpack_z_float */
  27806.    NULL, /* pack_z_float */
  27807.    NULL, /* unpack_s_8uint */
  27808.    NULL, /* pack_s_8uint */
  27809.    &util_format_r8a8_sint_unpack_unsigned, /* unpack_rgba_uint */
  27810.    &util_format_r8a8_sint_pack_unsigned, /* pack_rgba_uint */
  27811.    &util_format_r8a8_sint_unpack_signed, /* unpack_rgba_sint */
  27812.    &util_format_r8a8_sint_pack_signed,  /* pack_rgba_sint */
  27813.    NULL,  /* fetch_rgba_uint */
  27814.    &util_format_r8a8_sint_fetch_signed  /* fetch_rgba_sint */
  27815. };
  27816.  
  27817. const struct util_format_description
  27818. util_format_r16a16_uint_description = {
  27819.    PIPE_FORMAT_R16A16_UINT,
  27820.    "PIPE_FORMAT_R16A16_UINT",
  27821.    "r16a16_uint",
  27822.    {1, 1, 32},  /* block */
  27823.    UTIL_FORMAT_LAYOUT_PLAIN,
  27824.    2,   /* nr_channels */
  27825.    TRUE,        /* is_array */
  27826.    TRUE,        /* is_bitmask */
  27827.    FALSE,       /* is_mixed */
  27828.    {
  27829.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0},  /* x = r */
  27830.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */
  27831.       {0, 0, 0, 0, 0},
  27832.       {0, 0, 0, 0, 0}
  27833.    },
  27834.    {
  27835.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27836.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27837.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27838.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27839.    },
  27840.    UTIL_FORMAT_COLORSPACE_RGB,
  27841.    NULL, /* unpack_rgba_8unorm */
  27842.    NULL, /* pack_rgba_8unorm */
  27843.    NULL, /* fetch_rgba_8unorm */
  27844.    NULL, /* unpack_rgba_float */
  27845.    NULL, /* pack_rgba_float */
  27846.    NULL, /* fetch_rgba_float */
  27847.    NULL, /* unpack_z_32unorm */
  27848.    NULL, /* pack_z_32unorm */
  27849.    NULL, /* unpack_z_float */
  27850.    NULL, /* pack_z_float */
  27851.    NULL, /* unpack_s_8uint */
  27852.    NULL, /* pack_s_8uint */
  27853.    &util_format_r16a16_uint_unpack_unsigned, /* unpack_rgba_uint */
  27854.    &util_format_r16a16_uint_pack_unsigned, /* pack_rgba_uint */
  27855.    &util_format_r16a16_uint_unpack_signed, /* unpack_rgba_sint */
  27856.    &util_format_r16a16_uint_pack_signed,  /* pack_rgba_sint */
  27857.    &util_format_r16a16_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27858.    NULL  /* fetch_rgba_sint */
  27859. };
  27860.  
  27861. const struct util_format_description
  27862. util_format_r16a16_sint_description = {
  27863.    PIPE_FORMAT_R16A16_SINT,
  27864.    "PIPE_FORMAT_R16A16_SINT",
  27865.    "r16a16_sint",
  27866.    {1, 1, 32},  /* block */
  27867.    UTIL_FORMAT_LAYOUT_PLAIN,
  27868.    2,   /* nr_channels */
  27869.    TRUE,        /* is_array */
  27870.    TRUE,        /* is_bitmask */
  27871.    FALSE,       /* is_mixed */
  27872.    {
  27873.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0},    /* x = r */
  27874.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16},   /* y = a */
  27875.       {0, 0, 0, 0, 0},
  27876.       {0, 0, 0, 0, 0}
  27877.    },
  27878.    {
  27879.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27880.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27881.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27882.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27883.    },
  27884.    UTIL_FORMAT_COLORSPACE_RGB,
  27885.    NULL, /* unpack_rgba_8unorm */
  27886.    NULL, /* pack_rgba_8unorm */
  27887.    NULL, /* fetch_rgba_8unorm */
  27888.    NULL, /* unpack_rgba_float */
  27889.    NULL, /* pack_rgba_float */
  27890.    NULL, /* fetch_rgba_float */
  27891.    NULL, /* unpack_z_32unorm */
  27892.    NULL, /* pack_z_32unorm */
  27893.    NULL, /* unpack_z_float */
  27894.    NULL, /* pack_z_float */
  27895.    NULL, /* unpack_s_8uint */
  27896.    NULL, /* pack_s_8uint */
  27897.    &util_format_r16a16_sint_unpack_unsigned, /* unpack_rgba_uint */
  27898.    &util_format_r16a16_sint_pack_unsigned, /* pack_rgba_uint */
  27899.    &util_format_r16a16_sint_unpack_signed, /* unpack_rgba_sint */
  27900.    &util_format_r16a16_sint_pack_signed,  /* pack_rgba_sint */
  27901.    NULL,  /* fetch_rgba_uint */
  27902.    &util_format_r16a16_sint_fetch_signed  /* fetch_rgba_sint */
  27903. };
  27904.  
  27905. const struct util_format_description
  27906. util_format_r32a32_uint_description = {
  27907.    PIPE_FORMAT_R32A32_UINT,
  27908.    "PIPE_FORMAT_R32A32_UINT",
  27909.    "r32a32_uint",
  27910.    {1, 1, 64},  /* block */
  27911.    UTIL_FORMAT_LAYOUT_PLAIN,
  27912.    2,   /* nr_channels */
  27913.    TRUE,        /* is_array */
  27914.    FALSE,       /* is_bitmask */
  27915.    FALSE,       /* is_mixed */
  27916.    {
  27917.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0},  /* x = r */
  27918.       {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */
  27919.       {0, 0, 0, 0, 0},
  27920.       {0, 0, 0, 0, 0}
  27921.    },
  27922.    {
  27923.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27924.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27925.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27926.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27927.    },
  27928.    UTIL_FORMAT_COLORSPACE_RGB,
  27929.    NULL, /* unpack_rgba_8unorm */
  27930.    NULL, /* pack_rgba_8unorm */
  27931.    NULL, /* fetch_rgba_8unorm */
  27932.    NULL, /* unpack_rgba_float */
  27933.    NULL, /* pack_rgba_float */
  27934.    NULL, /* fetch_rgba_float */
  27935.    NULL, /* unpack_z_32unorm */
  27936.    NULL, /* pack_z_32unorm */
  27937.    NULL, /* unpack_z_float */
  27938.    NULL, /* pack_z_float */
  27939.    NULL, /* unpack_s_8uint */
  27940.    NULL, /* pack_s_8uint */
  27941.    &util_format_r32a32_uint_unpack_unsigned, /* unpack_rgba_uint */
  27942.    &util_format_r32a32_uint_pack_unsigned, /* pack_rgba_uint */
  27943.    &util_format_r32a32_uint_unpack_signed, /* unpack_rgba_sint */
  27944.    &util_format_r32a32_uint_pack_signed,  /* pack_rgba_sint */
  27945.    &util_format_r32a32_uint_fetch_unsigned,  /* fetch_rgba_uint */
  27946.    NULL  /* fetch_rgba_sint */
  27947. };
  27948.  
  27949. const struct util_format_description
  27950. util_format_r32a32_sint_description = {
  27951.    PIPE_FORMAT_R32A32_SINT,
  27952.    "PIPE_FORMAT_R32A32_SINT",
  27953.    "r32a32_sint",
  27954.    {1, 1, 64},  /* block */
  27955.    UTIL_FORMAT_LAYOUT_PLAIN,
  27956.    2,   /* nr_channels */
  27957.    TRUE,        /* is_array */
  27958.    FALSE,       /* is_bitmask */
  27959.    FALSE,       /* is_mixed */
  27960.    {
  27961.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0},    /* x = r */
  27962.       {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32},   /* y = a */
  27963.       {0, 0, 0, 0, 0},
  27964.       {0, 0, 0, 0, 0}
  27965.    },
  27966.    {
  27967.       UTIL_FORMAT_SWIZZLE_X,    /* r */
  27968.       UTIL_FORMAT_SWIZZLE_0,    /* g */
  27969.       UTIL_FORMAT_SWIZZLE_0,    /* b */
  27970.       UTIL_FORMAT_SWIZZLE_Y     /* a */
  27971.    },
  27972.    UTIL_FORMAT_COLORSPACE_RGB,
  27973.    NULL, /* unpack_rgba_8unorm */
  27974.    NULL, /* pack_rgba_8unorm */
  27975.    NULL, /* fetch_rgba_8unorm */
  27976.    NULL, /* unpack_rgba_float */
  27977.    NULL, /* pack_rgba_float */
  27978.    NULL, /* fetch_rgba_float */
  27979.    NULL, /* unpack_z_32unorm */
  27980.    NULL, /* pack_z_32unorm */
  27981.    NULL, /* unpack_z_float */
  27982.    NULL, /* pack_z_float */
  27983.    NULL, /* unpack_s_8uint */
  27984.    NULL, /* pack_s_8uint */
  27985.    &util_format_r32a32_sint_unpack_unsigned, /* unpack_rgba_uint */
  27986.    &util_format_r32a32_sint_pack_unsigned, /* pack_rgba_uint */
  27987.    &util_format_r32a32_sint_unpack_signed, /* unpack_rgba_sint */
  27988.    &util_format_r32a32_sint_pack_signed,  /* pack_rgba_sint */
  27989.    NULL,  /* fetch_rgba_uint */
  27990.    &util_format_r32a32_sint_fetch_signed  /* fetch_rgba_sint */
  27991. };
  27992.  
  27993. const struct util_format_description *
  27994. util_format_description(enum pipe_format format)
  27995. {
  27996.    if (format >= PIPE_FORMAT_COUNT) {
  27997.       return NULL;
  27998.    }
  27999.  
  28000.    switch (format) {
  28001.    case PIPE_FORMAT_NONE:
  28002.       return &util_format_none_description;
  28003.    case PIPE_FORMAT_B8G8R8A8_UNORM:
  28004.       return &util_format_b8g8r8a8_unorm_description;
  28005.    case PIPE_FORMAT_B8G8R8X8_UNORM:
  28006.       return &util_format_b8g8r8x8_unorm_description;
  28007.    case PIPE_FORMAT_A8R8G8B8_UNORM:
  28008.       return &util_format_a8r8g8b8_unorm_description;
  28009.    case PIPE_FORMAT_X8R8G8B8_UNORM:
  28010.       return &util_format_x8r8g8b8_unorm_description;
  28011.    case PIPE_FORMAT_A8B8G8R8_UNORM:
  28012.       return &util_format_a8b8g8r8_unorm_description;
  28013.    case PIPE_FORMAT_X8B8G8R8_UNORM:
  28014.       return &util_format_x8b8g8r8_unorm_description;
  28015.    case PIPE_FORMAT_R8G8B8X8_UNORM:
  28016.       return &util_format_r8g8b8x8_unorm_description;
  28017.    case PIPE_FORMAT_L8_UNORM:
  28018.       return &util_format_l8_unorm_description;
  28019.    case PIPE_FORMAT_A8_UNORM:
  28020.       return &util_format_a8_unorm_description;
  28021.    case PIPE_FORMAT_I8_UNORM:
  28022.       return &util_format_i8_unorm_description;
  28023.    case PIPE_FORMAT_L4A4_UNORM:
  28024.       return &util_format_l4a4_unorm_description;
  28025.    case PIPE_FORMAT_L8A8_UNORM:
  28026.       return &util_format_l8a8_unorm_description;
  28027.    case PIPE_FORMAT_L16_UNORM:
  28028.       return &util_format_l16_unorm_description;
  28029.    case PIPE_FORMAT_A16_UNORM:
  28030.       return &util_format_a16_unorm_description;
  28031.    case PIPE_FORMAT_I16_UNORM:
  28032.       return &util_format_i16_unorm_description;
  28033.    case PIPE_FORMAT_L16A16_UNORM:
  28034.       return &util_format_l16a16_unorm_description;
  28035.    case PIPE_FORMAT_A8_SNORM:
  28036.       return &util_format_a8_snorm_description;
  28037.    case PIPE_FORMAT_L8_SNORM:
  28038.       return &util_format_l8_snorm_description;
  28039.    case PIPE_FORMAT_L8A8_SNORM:
  28040.       return &util_format_l8a8_snorm_description;
  28041.    case PIPE_FORMAT_I8_SNORM:
  28042.       return &util_format_i8_snorm_description;
  28043.    case PIPE_FORMAT_A16_SNORM:
  28044.       return &util_format_a16_snorm_description;
  28045.    case PIPE_FORMAT_L16_SNORM:
  28046.       return &util_format_l16_snorm_description;
  28047.    case PIPE_FORMAT_L16A16_SNORM:
  28048.       return &util_format_l16a16_snorm_description;
  28049.    case PIPE_FORMAT_I16_SNORM:
  28050.       return &util_format_i16_snorm_description;
  28051.    case PIPE_FORMAT_A16_FLOAT:
  28052.       return &util_format_a16_float_description;
  28053.    case PIPE_FORMAT_L16_FLOAT:
  28054.       return &util_format_l16_float_description;
  28055.    case PIPE_FORMAT_L16A16_FLOAT:
  28056.       return &util_format_l16a16_float_description;
  28057.    case PIPE_FORMAT_I16_FLOAT:
  28058.       return &util_format_i16_float_description;
  28059.    case PIPE_FORMAT_A32_FLOAT:
  28060.       return &util_format_a32_float_description;
  28061.    case PIPE_FORMAT_L32_FLOAT:
  28062.       return &util_format_l32_float_description;
  28063.    case PIPE_FORMAT_L32A32_FLOAT:
  28064.       return &util_format_l32a32_float_description;
  28065.    case PIPE_FORMAT_I32_FLOAT:
  28066.       return &util_format_i32_float_description;
  28067.    case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
  28068.       return &util_format_r8sg8sb8ux8u_norm_description;
  28069.    case PIPE_FORMAT_R5SG5SB6U_NORM:
  28070.       return &util_format_r5sg5sb6u_norm_description;
  28071.    case PIPE_FORMAT_S8_UINT:
  28072.       return &util_format_s8_uint_description;
  28073.    case PIPE_FORMAT_Z16_UNORM:
  28074.       return &util_format_z16_unorm_description;
  28075.    case PIPE_FORMAT_Z32_UNORM:
  28076.       return &util_format_z32_unorm_description;
  28077.    case PIPE_FORMAT_Z32_FLOAT:
  28078.       return &util_format_z32_float_description;
  28079.    case PIPE_FORMAT_Z24_UNORM_S8_UINT:
  28080.       return &util_format_z24_unorm_s8_uint_description;
  28081.    case PIPE_FORMAT_S8_UINT_Z24_UNORM:
  28082.       return &util_format_s8_uint_z24_unorm_description;
  28083.    case PIPE_FORMAT_X24S8_UINT:
  28084.       return &util_format_x24s8_uint_description;
  28085.    case PIPE_FORMAT_S8X24_UINT:
  28086.       return &util_format_s8x24_uint_description;
  28087.    case PIPE_FORMAT_Z24X8_UNORM:
  28088.       return &util_format_z24x8_unorm_description;
  28089.    case PIPE_FORMAT_X8Z24_UNORM:
  28090.       return &util_format_x8z24_unorm_description;
  28091.    case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
  28092.       return &util_format_z32_float_s8x24_uint_description;
  28093.    case PIPE_FORMAT_X32_S8X24_UINT:
  28094.       return &util_format_x32_s8x24_uint_description;
  28095.    case PIPE_FORMAT_UYVY:
  28096.       return &util_format_uyvy_description;
  28097.    case PIPE_FORMAT_YUYV:
  28098.       return &util_format_yuyv_description;
  28099.    case PIPE_FORMAT_R8G8_B8G8_UNORM:
  28100.       return &util_format_r8g8_b8g8_unorm_description;
  28101.    case PIPE_FORMAT_G8R8_G8B8_UNORM:
  28102.       return &util_format_g8r8_g8b8_unorm_description;
  28103.    case PIPE_FORMAT_G8R8_B8R8_UNORM:
  28104.       return &util_format_g8r8_b8r8_unorm_description;
  28105.    case PIPE_FORMAT_R8G8_R8B8_UNORM:
  28106.       return &util_format_r8g8_r8b8_unorm_description;
  28107.    case PIPE_FORMAT_R11G11B10_FLOAT:
  28108.       return &util_format_r11g11b10_float_description;
  28109.    case PIPE_FORMAT_R9G9B9E5_FLOAT:
  28110.       return &util_format_r9g9b9e5_float_description;
  28111.    case PIPE_FORMAT_R1_UNORM:
  28112.       return &util_format_r1_unorm_description;
  28113.    case PIPE_FORMAT_R8G8Bx_SNORM:
  28114.       return &util_format_r8g8bx_snorm_description;
  28115.    case PIPE_FORMAT_R64_FLOAT:
  28116.       return &util_format_r64_float_description;
  28117.    case PIPE_FORMAT_R64G64_FLOAT:
  28118.       return &util_format_r64g64_float_description;
  28119.    case PIPE_FORMAT_R64G64B64_FLOAT:
  28120.       return &util_format_r64g64b64_float_description;
  28121.    case PIPE_FORMAT_R64G64B64A64_FLOAT:
  28122.       return &util_format_r64g64b64a64_float_description;
  28123.    case PIPE_FORMAT_R32_FLOAT:
  28124.       return &util_format_r32_float_description;
  28125.    case PIPE_FORMAT_R32G32_FLOAT:
  28126.       return &util_format_r32g32_float_description;
  28127.    case PIPE_FORMAT_R32G32B32_FLOAT:
  28128.       return &util_format_r32g32b32_float_description;
  28129.    case PIPE_FORMAT_R32G32B32A32_FLOAT:
  28130.       return &util_format_r32g32b32a32_float_description;
  28131.    case PIPE_FORMAT_R32_UNORM:
  28132.       return &util_format_r32_unorm_description;
  28133.    case PIPE_FORMAT_R32G32_UNORM:
  28134.       return &util_format_r32g32_unorm_description;
  28135.    case PIPE_FORMAT_R32G32B32_UNORM:
  28136.       return &util_format_r32g32b32_unorm_description;
  28137.    case PIPE_FORMAT_R32G32B32A32_UNORM:
  28138.       return &util_format_r32g32b32a32_unorm_description;
  28139.    case PIPE_FORMAT_R32_USCALED:
  28140.       return &util_format_r32_uscaled_description;
  28141.    case PIPE_FORMAT_R32G32_USCALED:
  28142.       return &util_format_r32g32_uscaled_description;
  28143.    case PIPE_FORMAT_R32G32B32_USCALED:
  28144.       return &util_format_r32g32b32_uscaled_description;
  28145.    case PIPE_FORMAT_R32G32B32A32_USCALED:
  28146.       return &util_format_r32g32b32a32_uscaled_description;
  28147.    case PIPE_FORMAT_R32_SNORM:
  28148.       return &util_format_r32_snorm_description;
  28149.    case PIPE_FORMAT_R32G32_SNORM:
  28150.       return &util_format_r32g32_snorm_description;
  28151.    case PIPE_FORMAT_R32G32B32_SNORM:
  28152.       return &util_format_r32g32b32_snorm_description;
  28153.    case PIPE_FORMAT_R32G32B32A32_SNORM:
  28154.       return &util_format_r32g32b32a32_snorm_description;
  28155.    case PIPE_FORMAT_R32_SSCALED:
  28156.       return &util_format_r32_sscaled_description;
  28157.    case PIPE_FORMAT_R32G32_SSCALED:
  28158.       return &util_format_r32g32_sscaled_description;
  28159.    case PIPE_FORMAT_R32G32B32_SSCALED:
  28160.       return &util_format_r32g32b32_sscaled_description;
  28161.    case PIPE_FORMAT_R32G32B32A32_SSCALED:
  28162.       return &util_format_r32g32b32a32_sscaled_description;
  28163.    case PIPE_FORMAT_R16_FLOAT:
  28164.       return &util_format_r16_float_description;
  28165.    case PIPE_FORMAT_R16G16_FLOAT:
  28166.       return &util_format_r16g16_float_description;
  28167.    case PIPE_FORMAT_R16G16B16_FLOAT:
  28168.       return &util_format_r16g16b16_float_description;
  28169.    case PIPE_FORMAT_R16G16B16A16_FLOAT:
  28170.       return &util_format_r16g16b16a16_float_description;
  28171.    case PIPE_FORMAT_R16_UNORM:
  28172.       return &util_format_r16_unorm_description;
  28173.    case PIPE_FORMAT_R16G16_UNORM:
  28174.       return &util_format_r16g16_unorm_description;
  28175.    case PIPE_FORMAT_R16G16B16_UNORM:
  28176.       return &util_format_r16g16b16_unorm_description;
  28177.    case PIPE_FORMAT_R16G16B16A16_UNORM:
  28178.       return &util_format_r16g16b16a16_unorm_description;
  28179.    case PIPE_FORMAT_R16_USCALED:
  28180.       return &util_format_r16_uscaled_description;
  28181.    case PIPE_FORMAT_R16G16_USCALED:
  28182.       return &util_format_r16g16_uscaled_description;
  28183.    case PIPE_FORMAT_R16G16B16_USCALED:
  28184.       return &util_format_r16g16b16_uscaled_description;
  28185.    case PIPE_FORMAT_R16G16B16A16_USCALED:
  28186.       return &util_format_r16g16b16a16_uscaled_description;
  28187.    case PIPE_FORMAT_R16_SNORM:
  28188.       return &util_format_r16_snorm_description;
  28189.    case PIPE_FORMAT_R16G16_SNORM:
  28190.       return &util_format_r16g16_snorm_description;
  28191.    case PIPE_FORMAT_R16G16B16_SNORM:
  28192.       return &util_format_r16g16b16_snorm_description;
  28193.    case PIPE_FORMAT_R16G16B16A16_SNORM:
  28194.       return &util_format_r16g16b16a16_snorm_description;
  28195.    case PIPE_FORMAT_R16_SSCALED:
  28196.       return &util_format_r16_sscaled_description;
  28197.    case PIPE_FORMAT_R16G16_SSCALED:
  28198.       return &util_format_r16g16_sscaled_description;
  28199.    case PIPE_FORMAT_R16G16B16_SSCALED:
  28200.       return &util_format_r16g16b16_sscaled_description;
  28201.    case PIPE_FORMAT_R16G16B16A16_SSCALED:
  28202.       return &util_format_r16g16b16a16_sscaled_description;
  28203.    case PIPE_FORMAT_R8_UNORM:
  28204.       return &util_format_r8_unorm_description;
  28205.    case PIPE_FORMAT_R8G8_UNORM:
  28206.       return &util_format_r8g8_unorm_description;
  28207.    case PIPE_FORMAT_R8G8B8_UNORM:
  28208.       return &util_format_r8g8b8_unorm_description;
  28209.    case PIPE_FORMAT_R8G8B8A8_UNORM:
  28210.       return &util_format_r8g8b8a8_unorm_description;
  28211.    case PIPE_FORMAT_R8_USCALED:
  28212.       return &util_format_r8_uscaled_description;
  28213.    case PIPE_FORMAT_R8G8_USCALED:
  28214.       return &util_format_r8g8_uscaled_description;
  28215.    case PIPE_FORMAT_R8G8B8_USCALED:
  28216.       return &util_format_r8g8b8_uscaled_description;
  28217.    case PIPE_FORMAT_R8G8B8A8_USCALED:
  28218.       return &util_format_r8g8b8a8_uscaled_description;
  28219.    case PIPE_FORMAT_R8_SNORM:
  28220.       return &util_format_r8_snorm_description;
  28221.    case PIPE_FORMAT_R8G8_SNORM:
  28222.       return &util_format_r8g8_snorm_description;
  28223.    case PIPE_FORMAT_R8G8B8_SNORM:
  28224.       return &util_format_r8g8b8_snorm_description;
  28225.    case PIPE_FORMAT_R8G8B8A8_SNORM:
  28226.       return &util_format_r8g8b8a8_snorm_description;
  28227.    case PIPE_FORMAT_R8_SSCALED:
  28228.       return &util_format_r8_sscaled_description;
  28229.    case PIPE_FORMAT_R8G8_SSCALED:
  28230.       return &util_format_r8g8_sscaled_description;
  28231.    case PIPE_FORMAT_R8G8B8_SSCALED:
  28232.       return &util_format_r8g8b8_sscaled_description;
  28233.    case PIPE_FORMAT_R8G8B8A8_SSCALED:
  28234.       return &util_format_r8g8b8a8_sscaled_description;
  28235.    case PIPE_FORMAT_R32_FIXED:
  28236.       return &util_format_r32_fixed_description;
  28237.    case PIPE_FORMAT_R32G32_FIXED:
  28238.       return &util_format_r32g32_fixed_description;
  28239.    case PIPE_FORMAT_R32G32B32_FIXED:
  28240.       return &util_format_r32g32b32_fixed_description;
  28241.    case PIPE_FORMAT_R32G32B32A32_FIXED:
  28242.       return &util_format_r32g32b32a32_fixed_description;
  28243.    case PIPE_FORMAT_R10G10B10X2_USCALED:
  28244.       return &util_format_r10g10b10x2_uscaled_description;
  28245.    case PIPE_FORMAT_R10G10B10X2_SNORM:
  28246.       return &util_format_r10g10b10x2_snorm_description;
  28247.    case PIPE_FORMAT_YV12:
  28248.       return &util_format_yv12_description;
  28249.    case PIPE_FORMAT_YV16:
  28250.       return &util_format_yv16_description;
  28251.    case PIPE_FORMAT_IYUV:
  28252.       return &util_format_iyuv_description;
  28253.    case PIPE_FORMAT_NV12:
  28254.       return &util_format_nv12_description;
  28255.    case PIPE_FORMAT_NV21:
  28256.       return &util_format_nv21_description;
  28257.    case PIPE_FORMAT_R4A4_UNORM:
  28258.       return &util_format_r4a4_unorm_description;
  28259.    case PIPE_FORMAT_A4R4_UNORM:
  28260.       return &util_format_a4r4_unorm_description;
  28261.    case PIPE_FORMAT_R8A8_UNORM:
  28262.       return &util_format_r8a8_unorm_description;
  28263.    case PIPE_FORMAT_A8R8_UNORM:
  28264.       return &util_format_a8r8_unorm_description;
  28265.    case PIPE_FORMAT_R8_UINT:
  28266.       return &util_format_r8_uint_description;
  28267.    case PIPE_FORMAT_R8G8_UINT:
  28268.       return &util_format_r8g8_uint_description;
  28269.    case PIPE_FORMAT_R8G8B8_UINT:
  28270.       return &util_format_r8g8b8_uint_description;
  28271.    case PIPE_FORMAT_R8G8B8A8_UINT:
  28272.       return &util_format_r8g8b8a8_uint_description;
  28273.    case PIPE_FORMAT_R8_SINT:
  28274.       return &util_format_r8_sint_description;
  28275.    case PIPE_FORMAT_R8G8_SINT:
  28276.       return &util_format_r8g8_sint_description;
  28277.    case PIPE_FORMAT_R8G8B8_SINT:
  28278.       return &util_format_r8g8b8_sint_description;
  28279.    case PIPE_FORMAT_R8G8B8A8_SINT:
  28280.       return &util_format_r8g8b8a8_sint_description;
  28281.    case PIPE_FORMAT_R16_UINT:
  28282.       return &util_format_r16_uint_description;
  28283.    case PIPE_FORMAT_R16G16_UINT:
  28284.       return &util_format_r16g16_uint_description;
  28285.    case PIPE_FORMAT_R16G16B16_UINT:
  28286.       return &util_format_r16g16b16_uint_description;
  28287.    case PIPE_FORMAT_R16G16B16A16_UINT:
  28288.       return &util_format_r16g16b16a16_uint_description;
  28289.    case PIPE_FORMAT_R16_SINT:
  28290.       return &util_format_r16_sint_description;
  28291.    case PIPE_FORMAT_R16G16_SINT:
  28292.       return &util_format_r16g16_sint_description;
  28293.    case PIPE_FORMAT_R16G16B16_SINT:
  28294.       return &util_format_r16g16b16_sint_description;
  28295.    case PIPE_FORMAT_R16G16B16A16_SINT:
  28296.       return &util_format_r16g16b16a16_sint_description;
  28297.    case PIPE_FORMAT_R32_UINT:
  28298.       return &util_format_r32_uint_description;
  28299.    case PIPE_FORMAT_R32G32_UINT:
  28300.       return &util_format_r32g32_uint_description;
  28301.    case PIPE_FORMAT_R32G32B32_UINT:
  28302.       return &util_format_r32g32b32_uint_description;
  28303.    case PIPE_FORMAT_R32G32B32A32_UINT:
  28304.       return &util_format_r32g32b32a32_uint_description;
  28305.    case PIPE_FORMAT_R32_SINT:
  28306.       return &util_format_r32_sint_description;
  28307.    case PIPE_FORMAT_R32G32_SINT:
  28308.       return &util_format_r32g32_sint_description;
  28309.    case PIPE_FORMAT_R32G32B32_SINT:
  28310.       return &util_format_r32g32b32_sint_description;
  28311.    case PIPE_FORMAT_R32G32B32A32_SINT:
  28312.       return &util_format_r32g32b32a32_sint_description;
  28313.    case PIPE_FORMAT_A8_UINT:
  28314.       return &util_format_a8_uint_description;
  28315.    case PIPE_FORMAT_I8_UINT:
  28316.       return &util_format_i8_uint_description;
  28317.    case PIPE_FORMAT_L8_UINT:
  28318.       return &util_format_l8_uint_description;
  28319.    case PIPE_FORMAT_L8A8_UINT:
  28320.       return &util_format_l8a8_uint_description;
  28321.    case PIPE_FORMAT_A8_SINT:
  28322.       return &util_format_a8_sint_description;
  28323.    case PIPE_FORMAT_I8_SINT:
  28324.       return &util_format_i8_sint_description;
  28325.    case PIPE_FORMAT_L8_SINT:
  28326.       return &util_format_l8_sint_description;
  28327.    case PIPE_FORMAT_L8A8_SINT:
  28328.       return &util_format_l8a8_sint_description;
  28329.    case PIPE_FORMAT_A16_UINT:
  28330.       return &util_format_a16_uint_description;
  28331.    case PIPE_FORMAT_I16_UINT:
  28332.       return &util_format_i16_uint_description;
  28333.    case PIPE_FORMAT_L16_UINT:
  28334.       return &util_format_l16_uint_description;
  28335.    case PIPE_FORMAT_L16A16_UINT:
  28336.       return &util_format_l16a16_uint_description;
  28337.    case PIPE_FORMAT_A16_SINT:
  28338.       return &util_format_a16_sint_description;
  28339.    case PIPE_FORMAT_I16_SINT:
  28340.       return &util_format_i16_sint_description;
  28341.    case PIPE_FORMAT_L16_SINT:
  28342.       return &util_format_l16_sint_description;
  28343.    case PIPE_FORMAT_L16A16_SINT:
  28344.       return &util_format_l16a16_sint_description;
  28345.    case PIPE_FORMAT_A32_UINT:
  28346.       return &util_format_a32_uint_description;
  28347.    case PIPE_FORMAT_I32_UINT:
  28348.       return &util_format_i32_uint_description;
  28349.    case PIPE_FORMAT_L32_UINT:
  28350.       return &util_format_l32_uint_description;
  28351.    case PIPE_FORMAT_L32A32_UINT:
  28352.       return &util_format_l32a32_uint_description;
  28353.    case PIPE_FORMAT_A32_SINT:
  28354.       return &util_format_a32_sint_description;
  28355.    case PIPE_FORMAT_I32_SINT:
  28356.       return &util_format_i32_sint_description;
  28357.    case PIPE_FORMAT_L32_SINT:
  28358.       return &util_format_l32_sint_description;
  28359.    case PIPE_FORMAT_L32A32_SINT:
  28360.       return &util_format_l32a32_sint_description;
  28361.    case PIPE_FORMAT_R8G8B8X8_SNORM:
  28362.       return &util_format_r8g8b8x8_snorm_description;
  28363.    case PIPE_FORMAT_R8G8B8X8_SRGB:
  28364.       return &util_format_r8g8b8x8_srgb_description;
  28365.    case PIPE_FORMAT_R8G8B8X8_UINT:
  28366.       return &util_format_r8g8b8x8_uint_description;
  28367.    case PIPE_FORMAT_R8G8B8X8_SINT:
  28368.       return &util_format_r8g8b8x8_sint_description;
  28369.    case PIPE_FORMAT_R16G16B16X16_UNORM:
  28370.       return &util_format_r16g16b16x16_unorm_description;
  28371.    case PIPE_FORMAT_R16G16B16X16_SNORM:
  28372.       return &util_format_r16g16b16x16_snorm_description;
  28373.    case PIPE_FORMAT_R16G16B16X16_FLOAT:
  28374.       return &util_format_r16g16b16x16_float_description;
  28375.    case PIPE_FORMAT_R16G16B16X16_UINT:
  28376.       return &util_format_r16g16b16x16_uint_description;
  28377.    case PIPE_FORMAT_R16G16B16X16_SINT:
  28378.       return &util_format_r16g16b16x16_sint_description;
  28379.    case PIPE_FORMAT_R32G32B32X32_FLOAT:
  28380.       return &util_format_r32g32b32x32_float_description;
  28381.    case PIPE_FORMAT_R32G32B32X32_UINT:
  28382.       return &util_format_r32g32b32x32_uint_description;
  28383.    case PIPE_FORMAT_R32G32B32X32_SINT:
  28384.       return &util_format_r32g32b32x32_sint_description;
  28385.    case PIPE_FORMAT_R8A8_SNORM:
  28386.       return &util_format_r8a8_snorm_description;
  28387.    case PIPE_FORMAT_R16A16_UNORM:
  28388.       return &util_format_r16a16_unorm_description;
  28389.    case PIPE_FORMAT_R16A16_SNORM:
  28390.       return &util_format_r16a16_snorm_description;
  28391.    case PIPE_FORMAT_R16A16_FLOAT:
  28392.       return &util_format_r16a16_float_description;
  28393.    case PIPE_FORMAT_R32A32_FLOAT:
  28394.       return &util_format_r32a32_float_description;
  28395.    case PIPE_FORMAT_R8A8_UINT:
  28396.       return &util_format_r8a8_uint_description;
  28397.    case PIPE_FORMAT_R8A8_SINT:
  28398.       return &util_format_r8a8_sint_description;
  28399.    case PIPE_FORMAT_R16A16_UINT:
  28400.       return &util_format_r16a16_uint_description;
  28401.    case PIPE_FORMAT_R16A16_SINT:
  28402.       return &util_format_r16a16_sint_description;
  28403.    case PIPE_FORMAT_R32A32_UINT:
  28404.       return &util_format_r32a32_uint_description;
  28405.    case PIPE_FORMAT_R32A32_SINT:
  28406.       return &util_format_r32a32_sint_description;
  28407.    default:
  28408.       return NULL;
  28409.    }
  28410. }
  28411.  
  28412.