From d01f462c53f079e79b10617798abc56582e5124f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 2 Mar 2015 17:31:39 +1000 Subject: [PATCH] gallium: drop unneeded format code we don't need the accessor methods in virgl so far, only the description tables, so drop all the extra stuff for now. this introduces the python from mesa to generate our cut down table --- configure.ac | 1 + src/gallium/auxiliary/Makefile.am | 13 +- src/gallium/auxiliary/Makefile.sources | 8 - src/gallium/auxiliary/util/u_format.c | 328 +- src/gallium/auxiliary/util/u_format.csv | 398 + src/gallium/auxiliary/util/u_format.h | 182 - src/gallium/auxiliary/util/u_format_other.c | 472 - src/gallium/auxiliary/util/u_format_other.h | 134 - src/gallium/auxiliary/util/u_format_pack.py | 699 + src/gallium/auxiliary/util/u_format_parse.py | 365 + .../auxiliary/util/u_format_r11g11b10f.h | 232 - src/gallium/auxiliary/util/u_format_rgb9e5.h | 164 - src/gallium/auxiliary/util/u_format_rgtc.c | 171 - src/gallium/auxiliary/util/u_format_rgtc.h | 114 - src/gallium/auxiliary/util/u_format_s3tc.c | 701 - src/gallium/auxiliary/util/u_format_srgb.c | 178 - src/gallium/auxiliary/util/u_format_srgb.h | 147 - src/gallium/auxiliary/util/u_format_table.c | 33985 ---------------- src/gallium/auxiliary/util/u_format_table.py | 167 + src/gallium/auxiliary/util/u_format_yuv.c | 1193 - src/gallium/auxiliary/util/u_format_yuv.h | 364 - src/gallium/auxiliary/util/u_format_zs.c | 973 - src/gallium/auxiliary/util/u_format_zs.h | 212 - src/gallium/auxiliary/util/u_pack_color.h | 564 - src/gallium/auxiliary/util/u_surface.c | 223 - 25 files changed, 1634 insertions(+), 40354 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_format.csv delete mode 100644 src/gallium/auxiliary/util/u_format_other.c delete mode 100644 src/gallium/auxiliary/util/u_format_other.h create mode 100644 src/gallium/auxiliary/util/u_format_pack.py create mode 100755 src/gallium/auxiliary/util/u_format_parse.py delete mode 100644 src/gallium/auxiliary/util/u_format_r11g11b10f.h delete mode 100644 src/gallium/auxiliary/util/u_format_rgb9e5.h delete mode 100644 src/gallium/auxiliary/util/u_format_rgtc.c delete mode 100644 src/gallium/auxiliary/util/u_format_rgtc.h delete mode 100644 src/gallium/auxiliary/util/u_format_srgb.c delete mode 100644 src/gallium/auxiliary/util/u_format_srgb.h delete mode 100644 src/gallium/auxiliary/util/u_format_table.c create mode 100755 src/gallium/auxiliary/util/u_format_table.py delete mode 100644 src/gallium/auxiliary/util/u_format_yuv.c delete mode 100644 src/gallium/auxiliary/util/u_format_yuv.h delete mode 100644 src/gallium/auxiliary/util/u_format_zs.c delete mode 100644 src/gallium/auxiliary/util/u_format_zs.h diff --git a/configure.ac b/configure.ac index c9c9f2a..54da06d 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_SYS_LARGEFILE +AC_CHECK_PROGS([PYTHON2], [python2 python]) AX_CODE_COVERAGE DEFINES="-D_GNU_SOURCE" diff --git a/src/gallium/auxiliary/Makefile.am b/src/gallium/auxiliary/Makefile.am index 20c97e4..0a1ec9a 100644 --- a/src/gallium/auxiliary/Makefile.am +++ b/src/gallium/auxiliary/Makefile.am @@ -27,16 +27,6 @@ libgallium_la_SOURCES = \ util/u_double_list.h \ util/u_dual_blend.h \ util/u_format.h \ - util/u_format_etc.h \ - util/u_format_latc.h \ - util/u_format_other.h \ - util/u_format_r11g11b10f.h \ - util/u_format_rgb9e5.h \ - util/u_format_rgtc.h \ - util/u_format_s3tc.h \ - util/u_format_srgb.h \ - util/u_format_yuv.h \ - util/u_format_zs.h \ util/u_half.h \ util/u_hash_table.h \ util/u_inlines.h \ @@ -74,5 +64,8 @@ libgallium_la_SOURCES = \ os/os_time.h \ os/os_thread.h +util/u_format_table.c: $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format_pack.py $(srcdir)/util/u_format_parse.py $(srcdir)/util/u_format.csv + $(AM_V_at)$(MKDIR_P) util + $(AM_V_GEN) $(PYTHON2) $(srcdir)/util/u_format_table.py $(srcdir)/util/u_format.csv > $@ -include $(top_srcdir)/git.mk diff --git a/src/gallium/auxiliary/Makefile.sources b/src/gallium/auxiliary/Makefile.sources index faff0b0..754c59c 100644 --- a/src/gallium/auxiliary/Makefile.sources +++ b/src/gallium/auxiliary/Makefile.sources @@ -20,15 +20,7 @@ C_SOURCES := \ util/u_debug.c \ util/u_debug_describe.c \ util/u_format.c \ - util/u_format_srgb.c \ util/u_format_table.c \ - util/u_format_etc.c \ - util/u_format_rgtc.c \ - util/u_format_latc.c \ - util/u_format_s3tc.c \ - util/u_format_yuv.c \ - util/u_format_zs.c \ - util/u_format_other.c \ util/u_hash_table.c \ util/u_texture.c \ util/u_bitmask.c \ diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index c1ce408..659189f 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -40,6 +40,7 @@ #include "pipe/p_defines.h" +boolean util_format_s3tc_enabled = FALSE; boolean util_format_is_float(enum pipe_format format) @@ -272,172 +273,6 @@ util_get_depth_format_mrd(const struct util_format_description *desc) return mrd; } - -void -util_format_read_4f(enum pipe_format format, - float *dst, unsigned dst_stride, - const void *src, unsigned src_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - const uint8_t *src_row; - float *dst_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); - dst_row = dst; - - format_desc->unpack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h); -} - - -void -util_format_write_4f(enum pipe_format format, - const float *src, unsigned src_stride, - void *dst, unsigned dst_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - uint8_t *dst_row; - const float *src_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); - src_row = src; - - format_desc->pack_rgba_float(dst_row, dst_stride, src_row, src_stride, w, h); -} - - -void -util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - const uint8_t *src_row; - uint8_t *dst_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); - dst_row = dst; - - format_desc->unpack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h); -} - - -void -util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - uint8_t *dst_row; - const uint8_t *src_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); - src_row = src; - - format_desc->pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, w, h); -} - -void -util_format_read_4ui(enum pipe_format format, - unsigned *dst, unsigned dst_stride, - const void *src, unsigned src_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - const uint8_t *src_row; - uint32_t *dst_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); - dst_row = dst; - - format_desc->unpack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h); -} - -void -util_format_write_4ui(enum pipe_format format, - const unsigned int *src, unsigned src_stride, - void *dst, unsigned dst_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - uint8_t *dst_row; - const uint32_t *src_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); - src_row = src; - - format_desc->pack_rgba_uint(dst_row, dst_stride, src_row, src_stride, w, h); -} - -void -util_format_read_4i(enum pipe_format format, - int *dst, unsigned dst_stride, - const void *src, unsigned src_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - const uint8_t *src_row; - int32_t *dst_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8); - dst_row = dst; - - format_desc->unpack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h); -} - -void -util_format_write_4i(enum pipe_format format, - const int *src, unsigned src_stride, - void *dst, unsigned dst_stride, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - const struct util_format_description *format_desc; - uint8_t *dst_row; - const int32_t *src_row; - - format_desc = util_format_description(format); - - assert(x % format_desc->block.width == 0); - assert(y % format_desc->block.height == 0); - - dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8); - src_row = src; - - format_desc->pack_rgba_sint(dst_row, dst_stride, src_row, src_stride, w, h); -} - boolean util_is_format_compatible(const struct util_format_description *src_desc, const struct util_format_description *dst_desc) @@ -559,167 +394,6 @@ util_format_fits_8unorm(const struct util_format_description *format_desc) } -boolean -util_format_translate(enum pipe_format dst_format, - void *dst, unsigned dst_stride, - unsigned dst_x, unsigned dst_y, - enum pipe_format src_format, - const void *src, unsigned src_stride, - unsigned src_x, unsigned src_y, - unsigned width, unsigned height) -{ - const struct util_format_description *dst_format_desc; - const struct util_format_description *src_format_desc; - uint8_t *dst_row; - const uint8_t *src_row; - unsigned x_step, y_step; - unsigned dst_step; - unsigned src_step; - - dst_format_desc = util_format_description(dst_format); - src_format_desc = util_format_description(src_format); - - if (util_is_format_compatible(src_format_desc, dst_format_desc)) { - /* - * Trivial case. - */ - - util_copy_rect(dst, dst_format, dst_stride, dst_x, dst_y, - width, height, src, (int)src_stride, - src_x, src_y); - return TRUE; - } - - assert(dst_x % dst_format_desc->block.width == 0); - assert(dst_y % dst_format_desc->block.height == 0); - assert(src_x % src_format_desc->block.width == 0); - assert(src_y % src_format_desc->block.height == 0); - - dst_row = (uint8_t *)dst + dst_y*dst_stride + dst_x*(dst_format_desc->block.bits/8); - src_row = (const uint8_t *)src + src_y*src_stride + src_x*(src_format_desc->block.bits/8); - - /* - * This works because all pixel formats have pixel blocks with power of two - * sizes. - */ - - y_step = MAX2(dst_format_desc->block.height, src_format_desc->block.height); - x_step = MAX2(dst_format_desc->block.width, src_format_desc->block.width); - assert(y_step % dst_format_desc->block.height == 0); - assert(y_step % src_format_desc->block.height == 0); - - dst_step = y_step / dst_format_desc->block.height * dst_stride; - src_step = y_step / src_format_desc->block.height * src_stride; - - /* - * TODO: double formats will loose precision - * TODO: Add a special case for formats that are mere swizzles of each other - */ - - if (src_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS || - dst_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) { - float *tmp_z = NULL; - uint8_t *tmp_s = NULL; - - assert(x_step == 1); - assert(y_step == 1); - - if (src_format_desc->unpack_z_float && - dst_format_desc->pack_z_float) { - tmp_z = MALLOC(width * sizeof *tmp_z); - } - - if (src_format_desc->unpack_s_8uint && - dst_format_desc->pack_s_8uint) { - tmp_s = MALLOC(width * sizeof *tmp_s); - } - - while (height--) { - if (tmp_z) { - src_format_desc->unpack_z_float(tmp_z, 0, src_row, src_stride, width, 1); - dst_format_desc->pack_z_float(dst_row, dst_stride, tmp_z, 0, width, 1); - } - - if (tmp_s) { - src_format_desc->unpack_s_8uint(tmp_s, 0, src_row, src_stride, width, 1); - dst_format_desc->pack_s_8uint(dst_row, dst_stride, tmp_s, 0, width, 1); - } - - dst_row += dst_step; - src_row += src_step; - } - - FREE(tmp_s); - - FREE(tmp_z); - - return TRUE; - } - - if (util_format_fits_8unorm(src_format_desc) || - util_format_fits_8unorm(dst_format_desc)) { - unsigned tmp_stride; - uint8_t *tmp_row; - - if (!src_format_desc->unpack_rgba_8unorm || - !dst_format_desc->pack_rgba_8unorm) { - return FALSE; - } - - tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row; - tmp_row = MALLOC(y_step * tmp_stride); - if (!tmp_row) - return FALSE; - - while (height >= y_step) { - src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, y_step); - dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step); - - dst_row += dst_step; - src_row += src_step; - height -= y_step; - } - - if (height) { - src_format_desc->unpack_rgba_8unorm(tmp_row, tmp_stride, src_row, src_stride, width, height); - dst_format_desc->pack_rgba_8unorm(dst_row, dst_stride, tmp_row, tmp_stride, width, height); - } - - FREE(tmp_row); - } - else { - unsigned tmp_stride; - float *tmp_row; - - if (!src_format_desc->unpack_rgba_float || - !dst_format_desc->pack_rgba_float) { - return FALSE; - } - - tmp_stride = MAX2(width, x_step) * 4 * sizeof *tmp_row; - tmp_row = MALLOC(y_step * tmp_stride); - if (!tmp_row) - return FALSE; - - while (height >= y_step) { - src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, y_step); - dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, y_step); - - dst_row += dst_step; - src_row += src_step; - height -= y_step; - } - - if (height) { - src_format_desc->unpack_rgba_float(tmp_row, tmp_stride, src_row, src_stride, width, height); - dst_format_desc->pack_rgba_float(dst_row, dst_stride, tmp_row, tmp_stride, width, height); - } - - FREE(tmp_row); - } - return TRUE; -} - void util_format_compose_swizzles(const unsigned char swz1[4], const unsigned char swz2[4], unsigned char dst[4]) diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv new file mode 100644 index 0000000..a71aaf1 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format.csv @@ -0,0 +1,398 @@ +########################################################################### +# +# Copyright 2009-2010 VMware, Inc. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +########################################################################### + +# This CSV file has the input data for u_format.h's struct +# util_format_description. +# +# Each format entry contains: +# - name, per enum pipe_format +# - layout, per enum util_format_layout, in shortened lower caps +# - pixel block's width +# - pixel block's height +# - channel encoding (only meaningful for plain layout), containing for each +# channel the following information: +# - type, one of +# - 'x': void +# - 'u': unsigned +# - 's': signed +# - 'h': fixed +# - 'f': FLOAT +# - optionally followed by 'n' if it is normalized +# - optionally followed by 'p' if it is pure +# - number of bits +# - channel swizzle +# - color space: rgb, yub, sz +# - (optional) channel encoding for big-endian targets +# - (optional) channel swizzle for big-endian targets +# +# See also: +# - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9) +# - http://msdn.microsoft.com/en-us/library/bb205073.aspx#mapping_texture_formats (D3D9 -> D3D10) +# - http://msdn.microsoft.com/en-us/library/bb173059.aspx (D3D10) +# +# Note that GL doesn't really specify the layout of internal formats. See +# OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized +# internal formats to base in- ternal formats, and desired component +# resolutions for each sized internal format." + +# None +# Described as regular uint_8 bytes, i.e. PIPE_FORMAT_R8_USCALED +PIPE_FORMAT_NONE , plain, 1, 1, u8 , , , , x001, rgb + +# Typical rendertarget formats +PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb +PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb +# PIPE_FORMAT_R8G8B8A8_UNORM is below +PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , xyz1, rgb +PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb, x1 , un5 , un5 , un5 , yzw1 +PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx +PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx +PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb, x4 , un4 , un4 , un4 , yzw1 +PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb, un5 , un6 , un5 , , xyz1 +PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx +PIPE_FORMAT_B10G10R10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb, un2 , un10, un10, un10, yzwx +PIPE_FORMAT_B2G3R3_UNORM , plain, 1, 1, un2 , un3 , un3 , , zyx1, rgb, un3 , un3 , un2 , , xyz1 + +# Luminance/Intensity/Alpha formats +PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb +PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb +PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb +PIPE_FORMAT_L4A4_UNORM , plain, 1, 1, un4 , un4 , , , xxxy, rgb, un4 , un4 , , , yyyx +PIPE_FORMAT_L8A8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb +PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb +PIPE_FORMAT_A16_UNORM , plain, 1, 1, un16, , , , 000x, rgb +PIPE_FORMAT_I16_UNORM , plain, 1, 1, un16, , , , xxxx, rgb +PIPE_FORMAT_L16A16_UNORM , plain, 1, 1, un16, un16, , , xxxy, rgb +PIPE_FORMAT_A8_SNORM , plain, 1, 1, sn8 , , , , 000x, rgb +PIPE_FORMAT_L8_SNORM , plain, 1, 1, sn8 , , , , xxx1, rgb +PIPE_FORMAT_L8A8_SNORM , plain, 1, 1, sn8 , sn8 , , , xxxy, rgb +PIPE_FORMAT_I8_SNORM , plain, 1, 1, sn8 , , , , xxxx, rgb +PIPE_FORMAT_A16_SNORM , plain, 1, 1, sn16, , , , 000x, rgb +PIPE_FORMAT_L16_SNORM , plain, 1, 1, sn16, , , , xxx1, rgb +PIPE_FORMAT_L16A16_SNORM , plain, 1, 1, sn16, sn16, , , xxxy, rgb +PIPE_FORMAT_I16_SNORM , plain, 1, 1, sn16, , , , xxxx, rgb +PIPE_FORMAT_A16_FLOAT , plain, 1, 1, f16 , , , , 000x, rgb +PIPE_FORMAT_L16_FLOAT , plain, 1, 1, f16 , , , , xxx1, rgb +PIPE_FORMAT_L16A16_FLOAT , plain, 1, 1, f16 , f16 , , , xxxy, rgb +PIPE_FORMAT_I16_FLOAT , plain, 1, 1, f16 , , , , xxxx, rgb +PIPE_FORMAT_A32_FLOAT , plain, 1, 1, f32 , , , , 000x, rgb +PIPE_FORMAT_L32_FLOAT , plain, 1, 1, f32 , , , , xxx1, rgb +PIPE_FORMAT_L32A32_FLOAT , plain, 1, 1, f32 , f32 , , , xxxy, rgb +PIPE_FORMAT_I32_FLOAT , plain, 1, 1, f32 , , , , xxxx, rgb + +# SRGB formats +PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb +PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb +PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb +PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb +PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb + +# Mixed-sign formats (typically used for bump map textures) +PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb +PIPE_FORMAT_R10SG10SB10SA2U_NORM , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb, un2 , sn10, sn10, sn10, wzyx +PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb, un6 , sn5 , sn5 , , zyx1 + +# Depth-stencil formats +PIPE_FORMAT_S8_UINT , plain, 1, 1, up8 , , , , _x__, zs +PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs +PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs +PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs +PIPE_FORMAT_Z24_UNORM_S8_UINT , plain, 1, 1, un24, up8 , , , xy__, zs, up8 , un24, , , yx__ +PIPE_FORMAT_S8_UINT_Z24_UNORM , plain, 1, 1, up8 , un24, , , yx__, zs, un24, up8 , , , xy__ +PIPE_FORMAT_X24S8_UINT , plain, 1, 1, x24 , up8 , , , _y__, zs, up8 , x24 , , , _x__ +PIPE_FORMAT_S8X24_UINT , plain, 1, 1, up8 , x24 , , , _x__, zs, x24 , up8 , , , _y__ +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs, x8 , un24, , , y___ +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs, un24, x8 , , , x___ +PIPE_FORMAT_Z32_FLOAT_S8X24_UINT , plain, 1, 1, f32 , up8 , x24, , xy__, zs, f32 , x24 , up8, , xz__ +PIPE_FORMAT_X32_S8X24_UINT , plain, 1, 1, x32 , up8 , x24, , _y__, zs, x32 , x24 , up8, , _z__ + +# YUV formats +# http://www.fourcc.org/yuv.php#UYVY +PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz1, yuv +# http://www.fourcc.org/yuv.php#YUYV (a.k.a http://www.fourcc.org/yuv.php#YUY2) +PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv +# same subsampling but with rgb channels +PIPE_FORMAT_R8G8_B8G8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_G8R8_B8R8_UNORM , subsampled, 2, 1, x32 , , , , yxz1, rgb +PIPE_FORMAT_R8G8_R8B8_UNORM , subsampled, 2, 1, x32 , , , , yxz1, rgb + +# some special formats not fitting anywhere else +PIPE_FORMAT_R11G11B10_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_R9G9B9E5_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb +PIPE_FORMAT_R1_UNORM , other, 8, 1, x8 , , , , x001, rgb +# A.k.a. D3DFMT_CxV8U8 +PIPE_FORMAT_R8G8Bx_SNORM , other, 1, 1, sn8 , sn8 , , , xyz1, rgb + +# Compressed formats +# - http://en.wikipedia.org/wiki/S3_Texture_Compression +# - http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt +# - http://www.opengl.org/registry/specs/ARB/texture_compression_rgtc.txt +# - http://www.opengl.org/registry/specs/EXT/texture_compression_latc.txt +# - http://www.opengl.org/registry/specs/ARB/texture_compression_bptc.txt +# - http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt +# - http://msdn.microsoft.com/en-us/library/bb694531.aspx +PIPE_FORMAT_DXT1_RGB , s3tc, 4, 4, x64 , , , , xyz1, rgb +PIPE_FORMAT_DXT1_RGBA , s3tc, 4, 4, x64 , , , , xyzw, rgb +PIPE_FORMAT_DXT3_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT5_RGBA , s3tc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT1_SRGB , s3tc, 4, 4, x64 , , , , xyz1, srgb +PIPE_FORMAT_DXT1_SRGBA , s3tc, 4, 4, x64 , , , , xyzw, srgb +PIPE_FORMAT_DXT3_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_DXT5_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb + +PIPE_FORMAT_RGTC1_UNORM , rgtc, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_RGTC1_SNORM , rgtc, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_RGTC2_UNORM , rgtc, 4, 4, x128, , , , xy01, rgb +PIPE_FORMAT_RGTC2_SNORM , rgtc, 4, 4, x128, , , , xy01, rgb + +PIPE_FORMAT_LATC1_UNORM , rgtc, 4, 4, x64, , , , xxx1, rgb +PIPE_FORMAT_LATC1_SNORM , rgtc, 4, 4, x64, , , , xxx1, rgb +PIPE_FORMAT_LATC2_UNORM , rgtc, 4, 4, x128, , , , xxxy, rgb +PIPE_FORMAT_LATC2_SNORM , rgtc, 4, 4, x128, , , , xxxy, rgb + +PIPE_FORMAT_ETC1_RGB8 , etc, 4, 4, x64, , , , xyz1, rgb + +PIPE_FORMAT_BPTC_RGBA_UNORM , bptc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_BPTC_SRGBA , bptc, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_BPTC_RGB_FLOAT , bptc, 4, 4, x128, , , , xyz1, rgb +PIPE_FORMAT_BPTC_RGB_UFLOAT , bptc, 4, 4, x128, , , , xyz1, rgb + +# Straightforward D3D10-like formats (also used for +# vertex buffer element description) +# +# See also: +# - src/gallium/auxiliary/translate/translate_generic.c +# - src/mesa/state_tracker/st_draw.c +PIPE_FORMAT_R64_FLOAT , plain, 1, 1, f64 , , , , x001, rgb +PIPE_FORMAT_R64G64_FLOAT , plain, 1, 1, f64 , f64 , , , xy01, rgb +PIPE_FORMAT_R64G64B64_FLOAT , plain, 1, 1, f64 , f64 , f64 , , xyz1, rgb +PIPE_FORMAT_R64G64B64A64_FLOAT , plain, 1, 1, f64 , f64 , f64 , f64 , xyzw, rgb +PIPE_FORMAT_R32_FLOAT , plain, 1, 1, f32 , , , , x001, rgb +PIPE_FORMAT_R32G32_FLOAT , plain, 1, 1, f32 , f32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_FLOAT , plain, 1, 1, f32 , f32 , f32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_FLOAT , plain, 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb +PIPE_FORMAT_R32_UNORM , plain, 1, 1, un32, , , , x001, rgb +PIPE_FORMAT_R32G32_UNORM , plain, 1, 1, un32, un32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_UNORM , plain, 1, 1, un32, un32, un32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_UNORM , plain, 1, 1, un32, un32, un32, un32, xyzw, rgb +PIPE_FORMAT_R32_USCALED , plain, 1, 1, u32 , , , , x001, rgb +PIPE_FORMAT_R32G32_USCALED , plain, 1, 1, u32 , u32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_USCALED , plain, 1, 1, u32 , u32 , u32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_USCALED , plain, 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb +PIPE_FORMAT_R32_SNORM , plain, 1, 1, sn32, , , , x001, rgb +PIPE_FORMAT_R32G32_SNORM , plain, 1, 1, sn32, sn32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_SNORM , plain, 1, 1, sn32, sn32, sn32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_SNORM , plain, 1, 1, sn32, sn32, sn32, sn32, xyzw, rgb +PIPE_FORMAT_R32_SSCALED , plain, 1, 1, s32 , , , , x001, rgb +PIPE_FORMAT_R32G32_SSCALED , plain, 1, 1, s32 , s32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_SSCALED , plain, 1, 1, s32 , s32 , s32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_SSCALED , plain, 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb +PIPE_FORMAT_R16_FLOAT , plain, 1, 1, f16 , , , , x001, rgb +PIPE_FORMAT_R16G16_FLOAT , plain, 1, 1, f16 , f16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_FLOAT , plain, 1, 1, f16 , f16 , f16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_FLOAT , plain, 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb +PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb +PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_UNORM , plain, 1, 1, un16, un16, un16, un16, xyzw, rgb +PIPE_FORMAT_R16_USCALED , plain, 1, 1, u16 , , , , x001, rgb +PIPE_FORMAT_R16G16_USCALED , plain, 1, 1, u16 , u16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_USCALED , plain, 1, 1, u16 , u16 , u16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_USCALED , plain, 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb +PIPE_FORMAT_R16_SNORM , plain, 1, 1, sn16, , , , x001, rgb +PIPE_FORMAT_R16G16_SNORM , plain, 1, 1, sn16, sn16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_SNORM , plain, 1, 1, sn16, sn16, sn16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_SNORM , plain, 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb +PIPE_FORMAT_R16_SSCALED , plain, 1, 1, s16 , , , , x001, rgb +PIPE_FORMAT_R16G16_SSCALED , plain, 1, 1, s16 , s16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb +PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb +PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb +PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb +PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb +PIPE_FORMAT_R8_SNORM , plain, 1, 1, sn8 , , , , x001, rgb +PIPE_FORMAT_R8G8_SNORM , plain, 1, 1, sn8 , sn8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb +PIPE_FORMAT_R8_SSCALED , plain, 1, 1, s8 , , , , x001, rgb +PIPE_FORMAT_R8G8_SSCALED , plain, 1, 1, s8 , s8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_SSCALED , plain, 1, 1, s8 , s8 , s8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb + +# GL-specific vertex buffer element formats +# A.k.a. GL_FIXED +PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, rgb +PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb + +# D3D9-specific vertex buffer element formats +# See also: +# - http://msdn.microsoft.com/en-us/library/bb172533.aspx +# A.k.a. D3DDECLTYPE_UDEC3 +PIPE_FORMAT_R10G10B10X2_USCALED , plain, 1, 1, u10 , u10 , u10 , x2 , xyz1, rgb, x2 , u10 , u10 , u10 , wzy1 +# A.k.a. D3DDECLTYPE_DEC3N +PIPE_FORMAT_R10G10B10X2_SNORM , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb, x2 , sn10, sn10, sn10, wzy1 + +PIPE_FORMAT_YV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv +PIPE_FORMAT_YV16 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv +PIPE_FORMAT_IYUV , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv +PIPE_FORMAT_NV12 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv +PIPE_FORMAT_NV21 , other, 1, 1, x8 , x8 , x8 , x8 , xyzw, yuv + +# Usually used to implement IA44 and AI44 formats in video decoding +PIPE_FORMAT_A4R4_UNORM , plain, 1, 1, un4 , un4 , , , y00x, rgb, un4, un4 , , , x00y +PIPE_FORMAT_R4A4_UNORM , plain, 1, 1, un4 , un4 , , , x00y, rgb, un4, un4 , , , y00x +PIPE_FORMAT_R8A8_UNORM , plain, 1, 1, un8 , un8 , , , x00y, rgb +PIPE_FORMAT_A8R8_UNORM , plain, 1, 1, un8 , un8 , , , y00x, rgb + +# ARB_vertex_type_10_10_10_2_REV +PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb, u2 , u10 , u10 , u10 , wzyx +PIPE_FORMAT_R10G10B10A2_SSCALED , plain, 1, 1, s10 , s10 , s10 , s2 , xyzw, rgb, s2 , s10 , s10 , s10 , wzyx +PIPE_FORMAT_R10G10B10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2 , xyzw, rgb, sn2 , sn10, sn10, sn10, wzyx +PIPE_FORMAT_B10G10R10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , zyxw, rgb, u2 , u10 , u10 , u10 , yzwx +PIPE_FORMAT_B10G10R10A2_SSCALED , plain, 1, 1, s10 , s10 , s10 , s2 , zyxw, rgb, s2 , s10 , s10 , s10 , yzwx +PIPE_FORMAT_B10G10R10A2_SNORM , plain, 1, 1, sn10, sn10, sn10, sn2 , zyxw, rgb, sn2 , sn10, sn10, sn10, yzwx + +PIPE_FORMAT_R8_UINT , plain, 1, 1, up8, , , , x001, rgb +PIPE_FORMAT_R8G8_UINT , plain, 1, 1, up8, up8, , , xy01, rgb +PIPE_FORMAT_R8G8B8_UINT , plain, 1, 1, up8, up8, up8, , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_UINT , plain, 1, 1, up8, up8, up8, up8, xyzw, rgb + +PIPE_FORMAT_R8_SINT , plain, 1, 1, sp8, , , , x001, rgb +PIPE_FORMAT_R8G8_SINT , plain, 1, 1, sp8, sp8, , , xy01, rgb +PIPE_FORMAT_R8G8B8_SINT , plain, 1, 1, sp8, sp8, sp8, , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_SINT , plain, 1, 1, sp8, sp8, sp8, sp8, xyzw, rgb + +PIPE_FORMAT_R16_UINT , plain, 1, 1, up16, , , , x001, rgb +PIPE_FORMAT_R16G16_UINT , plain, 1, 1, up16, up16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_UINT , plain, 1, 1, up16, up16, up16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_UINT , plain, 1, 1, up16, up16, up16, up16, xyzw, rgb + +PIPE_FORMAT_R16_SINT , plain, 1, 1, sp16, , , , x001, rgb +PIPE_FORMAT_R16G16_SINT , plain, 1, 1, sp16, sp16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_SINT , plain, 1, 1, sp16, sp16, sp16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_SINT , plain, 1, 1, sp16, sp16, sp16, sp16, xyzw, rgb + +PIPE_FORMAT_R32_UINT , plain, 1, 1, up32, , , , x001, rgb +PIPE_FORMAT_R32G32_UINT , plain, 1, 1, up32, up32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_UINT , plain, 1, 1, up32, up32, up32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_UINT , plain, 1, 1, up32, up32, up32, up32, xyzw, rgb + +PIPE_FORMAT_R32_SINT , plain, 1, 1, sp32, , , , x001, rgb +PIPE_FORMAT_R32G32_SINT , plain, 1, 1, sp32, sp32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_SINT , plain, 1, 1, sp32, sp32, sp32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_SINT , plain, 1, 1, sp32, sp32, sp32, sp32, xyzw, rgb + +PIPE_FORMAT_A8_UINT , plain, 1, 1, up8, , , , 000x, rgb +PIPE_FORMAT_I8_UINT , plain, 1, 1, up8, , , , xxxx, rgb +PIPE_FORMAT_L8_UINT , plain, 1, 1, up8, , , , xxx1, rgb +PIPE_FORMAT_L8A8_UINT , plain, 1, 1, up8, up8, , , xxxy, rgb + +PIPE_FORMAT_A8_SINT , plain, 1, 1, sp8, , , , 000x, rgb +PIPE_FORMAT_I8_SINT , plain, 1, 1, sp8, , , , xxxx, rgb +PIPE_FORMAT_L8_SINT , plain, 1, 1, sp8, , , , xxx1, rgb +PIPE_FORMAT_L8A8_SINT , plain, 1, 1, sp8, sp8, , , xxxy, rgb + +PIPE_FORMAT_A16_UINT , plain, 1, 1, up16, , , , 000x, rgb +PIPE_FORMAT_I16_UINT , plain, 1, 1, up16, , , , xxxx, rgb +PIPE_FORMAT_L16_UINT , plain, 1, 1, up16, , , , xxx1, rgb +PIPE_FORMAT_L16A16_UINT , plain, 1, 1, up16, up16, , , xxxy, rgb + +PIPE_FORMAT_A16_SINT , plain, 1, 1, sp16, , , , 000x, rgb +PIPE_FORMAT_I16_SINT , plain, 1, 1, sp16, , , , xxxx, rgb +PIPE_FORMAT_L16_SINT , plain, 1, 1, sp16, , , , xxx1, rgb +PIPE_FORMAT_L16A16_SINT , plain, 1, 1, sp16, sp16, , , xxxy, rgb + +PIPE_FORMAT_A32_UINT , plain, 1, 1, up32, , , , 000x, rgb +PIPE_FORMAT_I32_UINT , plain, 1, 1, up32, , , , xxxx, rgb +PIPE_FORMAT_L32_UINT , plain, 1, 1, up32, , , , xxx1, rgb +PIPE_FORMAT_L32A32_UINT , plain, 1, 1, up32, up32, , , xxxy, rgb + +PIPE_FORMAT_A32_SINT , plain, 1, 1, sp32, , , , 000x, rgb +PIPE_FORMAT_I32_SINT , plain, 1, 1, sp32, , , , xxxx, rgb +PIPE_FORMAT_L32_SINT , plain, 1, 1, sp32, , , , xxx1, rgb +PIPE_FORMAT_L32A32_SINT , plain, 1, 1, sp32, sp32, , , xxxy, rgb + +PIPE_FORMAT_B10G10R10A2_UINT , plain, 1, 1, up10, up10, up10, up2, zyxw, rgb, up2 , up10, up10, up10, yzwx + +PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8, sn8, sn8, x8, xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, un8, un8, un8, x8, xyz1, srgb +PIPE_FORMAT_R8G8B8X8_UINT , plain, 1, 1, up8, up8, up8, x8, xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SINT , plain, 1, 1, sp8, sp8, sp8, x8, xyz1, rgb +PIPE_FORMAT_B10G10R10X2_UNORM , plain, 1, 1, un10, un10, un10, x2, zyx1, rgb, x2 , un10, un10, un10, yzw1 +PIPE_FORMAT_R16G16B16X16_UNORM , plain, 1, 1, un16, un16, un16, x16, xyz1, rgb +PIPE_FORMAT_R16G16B16X16_SNORM , plain, 1, 1, sn16, sn16, sn16, x16, xyz1, rgb +PIPE_FORMAT_R16G16B16X16_FLOAT , plain, 1, 1, f16, f16, f16, x16, xyz1, rgb +PIPE_FORMAT_R16G16B16X16_UINT , plain, 1, 1, up16, up16, up16, x16, xyz1, rgb +PIPE_FORMAT_R16G16B16X16_SINT , plain, 1, 1, sp16, sp16, sp16, x16, xyz1, rgb +PIPE_FORMAT_R32G32B32X32_FLOAT , plain, 1, 1, f32, f32, f32, x32, xyz1, rgb +PIPE_FORMAT_R32G32B32X32_UINT , plain, 1, 1, up32, up32, up32, x32, xyz1, rgb +PIPE_FORMAT_R32G32B32X32_SINT , plain, 1, 1, sp32, sp32, sp32, x32, xyz1, rgb + +PIPE_FORMAT_R8A8_SNORM , plain, 1, 1, sn8 , sn8 , , , x00y, rgb +PIPE_FORMAT_R16A16_UNORM , plain, 1, 1, un16 , un16 , , , x00y, rgb +PIPE_FORMAT_R16A16_SNORM , plain, 1, 1, sn16 , sn16 , , , x00y, rgb +PIPE_FORMAT_R16A16_FLOAT , plain, 1, 1, f16 , f16 , , , x00y, rgb +PIPE_FORMAT_R32A32_FLOAT , plain, 1, 1, f32 , f32 , , , x00y, rgb +PIPE_FORMAT_R8A8_UINT , plain, 1, 1, up8 , up8 , , , x00y, rgb +PIPE_FORMAT_R8A8_SINT , plain, 1, 1, sp8 , sp8 , , , x00y, rgb +PIPE_FORMAT_R16A16_UINT , plain, 1, 1, up16 , up16 , , , x00y, rgb +PIPE_FORMAT_R16A16_SINT , plain, 1, 1, sp16 , sp16 , , , x00y, rgb +PIPE_FORMAT_R32A32_UINT , plain, 1, 1, up32 , up32 , , , x00y, rgb +PIPE_FORMAT_R32A32_SINT , plain, 1, 1, sp32 , sp32 , , , x00y, rgb +PIPE_FORMAT_R10G10B10A2_UINT , plain, 1, 1, up10 , up10 , up10, up2 , xyzw, rgb, up2 , up10, up10, up10, wzyx + +PIPE_FORMAT_B5G6R5_SRGB , plain, 1, 1, un5 , un6 , un5 , , zyx1, srgb, un5 , un6 , un5 , , xyz1 + +PIPE_FORMAT_A8L8_UNORM , plain, 1, 1, un8 , un8 , , , yyyx, rgb +PIPE_FORMAT_A8L8_SNORM , plain, 1, 1, sn8 , sn8 , , , yyyx, rgb +PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, un8 , un8 , , , yyyx, srgb +PIPE_FORMAT_A16L16_UNORM , plain, 1, 1, un16, un16, , , yyyx, rgb + +PIPE_FORMAT_G8R8_UNORM , plain, 1, 1, un8 , un8 , , , yx01, rgb +PIPE_FORMAT_G8R8_SNORM , plain, 1, 1, sn8 , sn8 , , , yx01, rgb +PIPE_FORMAT_G16R16_UNORM , plain, 1, 1, un16, un16, , , yx01, rgb +PIPE_FORMAT_G16R16_SNORM , plain, 1, 1, sn16, sn16, , , yx01, rgb + +PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, x8, sn8, sn8, sn8, wzy1, rgb diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 621574c..20f5816 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -228,188 +228,6 @@ struct util_format_description * Colorspace transformation. */ enum util_format_colorspace colorspace; - - /** - * Unpack pixel blocks to R8G8B8A8_UNORM. - * Note: strides are in bytes. - * - * Only defined for non-depth-stencil formats. - */ - void - (*unpack_rgba_8unorm)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Pack pixel blocks from R8G8B8A8_UNORM. - * Note: strides are in bytes. - * - * Only defined for non-depth-stencil formats. - */ - void - (*pack_rgba_8unorm)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Fetch a single pixel (i, j) from a block. - * - * XXX: Only defined for a very few select formats. - */ - void - (*fetch_rgba_8unorm)(uint8_t *dst, - const uint8_t *src, - unsigned i, unsigned j); - - /** - * Unpack pixel blocks to R32G32B32A32_FLOAT. - * Note: strides are in bytes. - * - * Only defined for non-depth-stencil formats. - */ - void - (*unpack_rgba_float)(float *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Pack pixel blocks from R32G32B32A32_FLOAT. - * Note: strides are in bytes. - * - * Only defined for non-depth-stencil formats. - */ - void - (*pack_rgba_float)(uint8_t *dst, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Fetch a single pixel (i, j) from a block. - * - * Only defined for non-depth-stencil and non-integer formats. - */ - void - (*fetch_rgba_float)(float *dst, - const uint8_t *src, - unsigned i, unsigned j); - - /** - * Unpack pixels to Z32_UNORM. - * Note: strides are in bytes. - * - * Only defined for depth formats. - */ - void - (*unpack_z_32unorm)(uint32_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Pack pixels from Z32_FLOAT. - * Note: strides are in bytes. - * - * Only defined for depth formats. - */ - void - (*pack_z_32unorm)(uint8_t *dst, unsigned dst_stride, - const uint32_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Unpack pixels to Z32_FLOAT. - * Note: strides are in bytes. - * - * Only defined for depth formats. - */ - void - (*unpack_z_float)(float *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Pack pixels from Z32_FLOAT. - * Note: strides are in bytes. - * - * Only defined for depth formats. - */ - void - (*pack_z_float)(uint8_t *dst, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Unpack pixels to S8_UINT. - * Note: strides are in bytes. - * - * Only defined for stencil formats. - */ - void - (*unpack_s_8uint)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Pack pixels from S8_UINT. - * Note: strides are in bytes. - * - * Only defined for stencil formats. - */ - void - (*pack_s_8uint)(uint8_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Unpack pixel blocks to R32G32B32A32_UINT. - * Note: strides are in bytes. - * - * Only defined for INT formats. - */ - void - (*unpack_rgba_uint)(uint32_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - void - (*pack_rgba_uint)(uint8_t *dst, unsigned dst_stride, - const uint32_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Unpack pixel blocks to R32G32B32A32_SINT. - * Note: strides are in bytes. - * - * Only defined for INT formats. - */ - void - (*unpack_rgba_sint)(int32_t *dst, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height); - - void - (*pack_rgba_sint)(uint8_t *dst, unsigned dst_stride, - const int32_t *src, unsigned src_stride, - unsigned width, unsigned height); - - /** - * Fetch a single pixel (i, j) from a block. - * - * Only defined for unsigned (pure) integer formats. - */ - void - (*fetch_rgba_uint)(uint32_t *dst, - const uint8_t *src, - unsigned i, unsigned j); - - /** - * Fetch a single pixel (i, j) from a block. - * - * Only defined for signed (pure) integer formats. - */ - void - (*fetch_rgba_sint)(int32_t *dst, - const uint8_t *src, - unsigned i, unsigned j); }; diff --git a/src/gallium/auxiliary/util/u_format_other.c b/src/gallium/auxiliary/util/u_format_other.c deleted file mode 100644 index 85001c1..0000000 --- a/src/gallium/auxiliary/util/u_format_other.c +++ /dev/null @@ -1,472 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -#include "u_math.h" -#include "u_format_other.h" -#include "u_format_rgb9e5.h" -#include "u_format_r11g11b10f.h" - - -void -util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - rgb9e5_to_float3(value, dst); - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_rgb9e5(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - rgb9e5_to_float3(value, dst); - dst[3] = 1; /* a */ -} - - -void -util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - float p[3]; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - rgb9e5_to_float3(value, p); - dst[0] = float_to_ubyte(p[0]); /* r */ - dst[1] = float_to_ubyte(p[1]); /* g */ - dst[2] = float_to_ubyte(p[2]); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - float p[3]; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value; - p[0] = ubyte_to_float(src[0]); - p[1] = ubyte_to_float(src[1]); - p[2] = ubyte_to_float(src[2]); - value = float3_to_rgb9e5(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - r11g11b10f_to_float3(value, dst); - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = float3_to_r11g11b10f(src); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - r11g11b10f_to_float3(value, dst); - dst[3] = 1; /* a */ -} - - -void -util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - float p[3]; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - r11g11b10f_to_float3(value, p); - dst[0] = float_to_ubyte(p[0]); /* r */ - dst[1] = float_to_ubyte(p[1]); /* g */ - dst[2] = float_to_ubyte(p[2]); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - float p[3]; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value; - p[0] = ubyte_to_float(src[0]); - p[1] = ubyte_to_float(src[1]); - p[2] = ubyte_to_float(src[2]); - value = float3_to_r11g11b10f(p); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - -} - - -void -util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - -} - - -void -util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - -} - - -void -util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - -} - - -void -util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ -} - - -/* - * PIPE_FORMAT_R8G8Bx_SNORM - * - * A.k.a. D3DFMT_CxV8U8 - */ - -static uint8_t -r8g8bx_derive(int16_t r, int16_t g) -{ - /* Derive blue from red and green components. - * Apparently, we must always use integers to perform calculations, - * otherwise the results won't match D3D's CxV8U8 definition. - */ - return (uint8_t)sqrtf(0x7f * 0x7f - r * r - g * g) * 0xff / 0x7f; -} - -void -util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint16_t *src = (const uint16_t *)src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *src++; - int16_t r, g; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - r = ((int16_t)(value << 8)) >> 8; - g = ((int16_t)(value << 0)) >> 8; - - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = r8g8bx_derive(r, g) * (1.0f/0xff); /* b */ - dst[3] = 1.0f; /* a */ - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint16_t *src = (const uint16_t *)src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *src++; - int16_t r, g; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - r = ((int16_t)(value << 8)) >> 8; - g = ((int16_t)(value << 0)) >> 8; - - dst[0] = (uint8_t)(((uint16_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint16_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = r8g8bx_derive(r, g); /* b */ - dst[3] = 255; /* a */ - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint16_t *dst = (uint16_t *)dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - - value |= (uint16_t)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint16_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; - - src += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint16_t *dst = (uint16_t *)dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - - value |= src[0] >> 1; - value |= (src[1] >> 1) << 8; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - *dst++ = value; - - src += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r, g; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - - r = ((int16_t)(value << 8)) >> 8; - g = ((int16_t)(value << 0)) >> 8; - - dst[0] = r * (1.0f/0x7f); /* r */ - dst[1] = g * (1.0f/0x7f); /* g */ - dst[2] = r8g8bx_derive(r, g) * (1.0f/0xff); /* b */ - dst[3] = 1.0f; /* a */ -} diff --git a/src/gallium/auxiliary/util/u_format_other.h b/src/gallium/auxiliary/util/u_format_other.h deleted file mode 100644 index 2f6a908..0000000 --- a/src/gallium/auxiliary/util/u_format_other.h +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -#ifndef U_FORMAT_OTHER_H_ -#define U_FORMAT_OTHER_H_ - - -#include "pipe/p_compiler.h" - - -void -util_format_r9g9b9e5_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r9g9b9e5_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r9g9b9e5_float_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_r9g9b9e5_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r9g9b9e5_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - - -void -util_format_r11g11b10_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r11g11b10_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_r11g11b10_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r11g11b10_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - - -void -util_format_r1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_r1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8bx_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8bx_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8bx_snorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_r8g8bx_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8bx_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -#endif /* U_FORMAT_OTHER_H_ */ diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py new file mode 100644 index 0000000..ba19446 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -0,0 +1,699 @@ +#!/usr/bin/env python + +''' +/************************************************************************** + * + * Copyright 2009-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * @file + * Pixel format packing and unpacking functions. + * + * @author Jose Fonseca + */ +''' + + +from u_format_parse import * + + +def inv_swizzles(swizzles): + '''Return an array[4] of inverse swizzle terms''' + '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha''' + inv_swizzle = [None]*4 + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4 and inv_swizzle[swizzle] == None: + inv_swizzle[swizzle] = i + return inv_swizzle + +def print_channels(format, func): + if format.nr_channels() <= 1: + func(format.le_channels, format.le_swizzles) + else: + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + func(format.be_channels, format.be_swizzles) + print '#else' + func(format.le_channels, format.le_swizzles) + print '#endif' + +def generate_format_type(format): + '''Generate a structure that describes the format.''' + + assert format.layout == PLAIN + + def generate_bitfields(channels, swizzles): + for channel in channels: + if channel.type == VOID: + if channel.size: + print ' unsigned %s:%u;' % (channel.name, channel.size) + elif channel.type == UNSIGNED: + print ' unsigned %s:%u;' % (channel.name, channel.size) + elif channel.type in (SIGNED, FIXED): + print ' int %s:%u;' % (channel.name, channel.size) + elif channel.type == FLOAT: + if channel.size == 64: + print ' double %s;' % (channel.name) + elif channel.size == 32: + print ' float %s;' % (channel.name) + else: + print ' unsigned %s:%u;' % (channel.name, channel.size) + else: + assert 0 + + def generate_full_fields(channels, swizzles): + for channel in channels: + assert channel.size % 8 == 0 and is_pot(channel.size) + if channel.type == VOID: + if channel.size: + print ' uint%u_t %s;' % (channel.size, channel.name) + elif channel.type == UNSIGNED: + print ' uint%u_t %s;' % (channel.size, channel.name) + elif channel.type in (SIGNED, FIXED): + print ' int%u_t %s;' % (channel.size, channel.name) + elif channel.type == FLOAT: + if channel.size == 64: + print ' double %s;' % (channel.name) + elif channel.size == 32: + print ' float %s;' % (channel.name) + elif channel.size == 16: + print ' uint16_t %s;' % (channel.name) + else: + assert 0 + else: + assert 0 + + print 'union util_format_%s {' % format.short_name() + + if format.block_size() in (8, 16, 32, 64): + print ' uint%u_t value;' % (format.block_size(),) + + use_bitfields = False + for channel in format.le_channels: + if channel.size % 8 or not is_pot(channel.size): + use_bitfields = True + + print ' struct {' + if use_bitfields: + print_channels(format, generate_bitfields) + else: + print_channels(format, generate_full_fields) + print ' } chan;' + print '};' + print + + +def is_format_supported(format): + '''Determines whether we actually have the plumbing necessary to generate the + to read/write to/from this format.''' + + # FIXME: Ideally we would support any format combination here. + + if format.layout != PLAIN: + return False + + for i in range(4): + channel = format.le_channels[i] + if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED): + return False + if channel.type == FLOAT and channel.size not in (16, 32, 64): + return False + + return True + +def native_type(format): + '''Get the native appropriate for a format.''' + + if format.name == 'PIPE_FORMAT_R11G11B10_FLOAT': + return 'uint32_t' + if format.name == 'PIPE_FORMAT_R9G9B9E5_FLOAT': + return 'uint32_t' + + if format.layout == PLAIN: + if not format.is_array(): + # For arithmetic pixel formats return the integer type that matches the whole pixel + return 'uint%u_t' % format.block_size() + else: + # For array pixel formats return the integer type that matches the color channel + channel = format.array_element() + if channel.type in (UNSIGNED, VOID): + return 'uint%u_t' % channel.size + elif channel.type in (SIGNED, FIXED): + return 'int%u_t' % channel.size + elif channel.type == FLOAT: + if channel.size == 16: + return 'uint16_t' + elif channel.size == 32: + return 'float' + elif channel.size == 64: + return 'double' + else: + assert False + else: + assert False + else: + assert False + + +def intermediate_native_type(bits, sign): + '''Find a native type adequate to hold intermediate results of the request bit size.''' + + bytes = 4 # don't use anything smaller than 32bits + while bytes * 8 < bits: + bytes *= 2 + bits = bytes*8 + + if sign: + return 'int%u_t' % bits + else: + return 'uint%u_t' % bits + + +def get_one_shift(type): + '''Get the number of the bit that matches unity for this type.''' + if type.type == 'FLOAT': + assert False + if not type.norm: + return 0 + if type.type == UNSIGNED: + return type.size + if type.type == SIGNED: + return type.size - 1 + if type.type == FIXED: + return type.size / 2 + assert False + + +def truncate_mantissa(x, bits): + '''Truncate an integer so it can be represented exactly with a floating + point mantissa''' + + assert isinstance(x, (int, long)) + + s = 1 + if x < 0: + s = -1 + x = -x + + # We can represent integers up to mantissa + 1 bits exactly + mask = (1 << (bits + 1)) - 1 + + # Slide the mask until the MSB matches + shift = 0 + while (x >> shift) & ~mask: + shift += 1 + + x &= mask << shift + x *= s + return x + + +def value_to_native(type, value): + '''Get the value of unity for this type.''' + if type.type == FLOAT: + if type.size <= 32 \ + and isinstance(value, (int, long)): + return truncate_mantissa(value, 23) + return value + if type.type == FIXED: + return int(value * (1 << (type.size/2))) + if not type.norm: + return int(value) + if type.type == UNSIGNED: + return int(value * ((1 << type.size) - 1)) + if type.type == SIGNED: + return int(value * ((1 << (type.size - 1)) - 1)) + assert False + + +def native_to_constant(type, value): + '''Get the value of unity for this type.''' + if type.type == FLOAT: + if type.size <= 32: + return "%.1ff" % float(value) + else: + return "%.1f" % float(value) + else: + return str(int(value)) + + +def get_one(type): + '''Get the value of unity for this type.''' + return value_to_native(type, 1) + + +def clamp_expr(src_channel, dst_channel, dst_native_type, value): + '''Generate the expression to clamp the value in the source type to the + destination type range.''' + + if src_channel == dst_channel: + return value + + src_min = src_channel.min() + src_max = src_channel.max() + dst_min = dst_channel.min() + dst_max = dst_channel.max() + + # Translate the destination range to the src native value + dst_min_native = native_to_constant(src_channel, value_to_native(src_channel, dst_min)) + dst_max_native = native_to_constant(src_channel, value_to_native(src_channel, dst_max)) + + if src_min < dst_min and src_max > dst_max: + return 'CLAMP(%s, %s, %s)' % (value, dst_min_native, dst_max_native) + + if src_max > dst_max: + return 'MIN2(%s, %s)' % (value, dst_max_native) + + if src_min < dst_min: + return 'MAX2(%s, %s)' % (value, dst_min_native) + + return value + + +def conversion_expr(src_channel, + dst_channel, dst_native_type, + value, + clamp=True, + src_colorspace = RGB, + dst_colorspace = RGB): + '''Generate the expression to convert a value between two types.''' + + if src_colorspace != dst_colorspace: + if src_colorspace == SRGB: + assert src_channel.type == UNSIGNED + assert src_channel.norm + assert src_channel.size <= 8 + assert src_channel.size >= 4 + assert dst_colorspace == RGB + if src_channel.size < 8: + value = '%s << %x | %s >> %x' % (value, 8 - src_channel.size, value, 2 * src_channel.size - 8) + if dst_channel.type == FLOAT: + return 'util_format_srgb_8unorm_to_linear_float(%s)' % value + else: + assert dst_channel.type == UNSIGNED + assert dst_channel.norm + assert dst_channel.size == 8 + return 'util_format_srgb_to_linear_8unorm(%s)' % value + elif dst_colorspace == SRGB: + assert dst_channel.type == UNSIGNED + assert dst_channel.norm + assert dst_channel.size <= 8 + assert src_colorspace == RGB + if src_channel.type == FLOAT: + value = 'util_format_linear_float_to_srgb_8unorm(%s)' % value + else: + assert src_channel.type == UNSIGNED + assert src_channel.norm + assert src_channel.size == 8 + value = 'util_format_linear_to_srgb_8unorm(%s)' % value + # XXX rounding is all wrong. + if dst_channel.size < 8: + return '%s >> %x' % (value, 8 - dst_channel.size) + else: + return value + elif src_colorspace == ZS: + pass + elif dst_colorspace == ZS: + pass + else: + assert 0 + + if src_channel == dst_channel: + return value + + src_type = src_channel.type + src_size = src_channel.size + src_norm = src_channel.norm + src_pure = src_channel.pure + + # Promote half to float + if src_type == FLOAT and src_size == 16: + value = 'util_half_to_float(%s)' % value + src_size = 32 + + # Special case for float <-> ubytes for more accurate results + # Done before clamping since these functions already take care of that + if src_type == UNSIGNED and src_norm and src_size == 8 and dst_channel.type == FLOAT and dst_channel.size == 32: + return 'ubyte_to_float(%s)' % value + if src_type == FLOAT and src_size == 32 and dst_channel.type == UNSIGNED and dst_channel.norm and dst_channel.size == 8: + return 'float_to_ubyte(%s)' % value + + if clamp: + if dst_channel.type != FLOAT or src_type != FLOAT: + value = clamp_expr(src_channel, dst_channel, dst_native_type, value) + + if src_type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED): + if not src_norm and not dst_channel.norm: + # neither is normalized -- just cast + return '(%s)%s' % (dst_native_type, value) + + src_one = get_one(src_channel) + dst_one = get_one(dst_channel) + + if src_one > dst_one and src_norm and dst_channel.norm: + # We can just bitshift + src_shift = get_one_shift(src_channel) + dst_shift = get_one_shift(dst_channel) + value = '(%s >> %s)' % (value, src_shift - dst_shift) + else: + # We need to rescale using an intermediate type big enough to hold the multiplication of both + tmp_native_type = intermediate_native_type(src_size + dst_channel.size, src_channel.sign and dst_channel.sign) + value = '((%s)%s)' % (tmp_native_type, value) + value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one) + value = '(%s)%s' % (dst_native_type, value) + return value + + # Promote to either float or double + if src_type != FLOAT: + if src_norm or src_type == FIXED: + one = get_one(src_channel) + if src_size <= 23: + value = '(%s * (1.0f/0x%x))' % (value, one) + if dst_channel.size <= 32: + value = '(float)%s' % value + src_size = 32 + else: + # bigger than single precision mantissa, use double + value = '(%s * (1.0/0x%x))' % (value, one) + src_size = 64 + src_norm = False + else: + if src_size <= 23 or dst_channel.size <= 32: + value = '(float)%s' % value + src_size = 32 + else: + # bigger than single precision mantissa, use double + value = '(double)%s' % value + src_size = 64 + src_type = FLOAT + + # Convert double or float to non-float + if dst_channel.type != FLOAT: + if dst_channel.norm or dst_channel.type == FIXED: + dst_one = get_one(dst_channel) + if dst_channel.size <= 23: + value = 'util_iround(%s * 0x%x)' % (value, dst_one) + else: + # bigger than single precision mantissa, use double + value = '(%s * (double)0x%x)' % (value, dst_one) + value = '(%s)%s' % (dst_native_type, value) + else: + # Cast double to float when converting to either half or float + if dst_channel.size <= 32 and src_size > 32: + value = '(float)%s' % value + src_size = 32 + + if dst_channel.size == 16: + value = 'util_float_to_half(%s)' % value + elif dst_channel.size == 64 and src_size < 64: + value = '(double)%s' % value + + return value + + +def generate_unpack_kernel(format, dst_channel, dst_native_type): + + if not is_format_supported(format): + return + + assert format.layout == PLAIN + + src_native_type = native_type(format) + + def unpack_from_bitmask(channels, swizzles): + depth = format.block_size() + print ' uint%u_t value = *(const uint%u_t *)src;' % (depth, depth) + + # Declare the intermediate variables + for i in range(format.nr_channels()): + src_channel = channels[i] + if src_channel.type == UNSIGNED: + print ' uint%u_t %s;' % (depth, src_channel.name) + elif src_channel.type == SIGNED: + print ' int%u_t %s;' % (depth, src_channel.name) + + # Compute the intermediate unshifted values + for i in range(format.nr_channels()): + src_channel = channels[i] + value = 'value' + shift = src_channel.shift + if src_channel.type == UNSIGNED: + if shift: + value = '%s >> %u' % (value, shift) + if shift + src_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) + elif src_channel.type == SIGNED: + if shift + src_channel.size < depth: + # Align the sign bit + lshift = depth - (shift + src_channel.size) + value = '%s << %u' % (value, lshift) + # Cast to signed + value = '(int%u_t)(%s) ' % (depth, value) + if src_channel.size < depth: + # Align the LSB bit + rshift = depth - src_channel.size + value = '(%s) >> %u' % (value, rshift) + else: + value = None + + if value is not None: + print ' %s = %s;' % (src_channel.name, value) + + # Convert, swizzle, and store final values + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + src_channel = channels[swizzle] + src_colorspace = format.colorspace + if src_colorspace == SRGB and i == 3: + # Alpha channel is linear + src_colorspace = RGB + value = src_channel.name + value = conversion_expr(src_channel, + dst_channel, dst_native_type, + value, + src_colorspace = src_colorspace) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + def unpack_from_union(channels, swizzles): + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + src_channel = channels[swizzle] + src_colorspace = format.colorspace + if src_colorspace == SRGB and i == 3: + # Alpha channel is linear + src_colorspace = RGB + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, + dst_channel, dst_native_type, + value, + src_colorspace = src_colorspace) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + if format.is_bitmask(): + print_channels(format, unpack_from_bitmask) + else: + print_channels(format, unpack_from_union) + + +def generate_pack_kernel(format, src_channel, src_native_type): + + if not is_format_supported(format): + return + + dst_native_type = native_type(format) + + assert format.layout == PLAIN + + def pack_into_bitmask(channels, swizzles): + inv_swizzle = inv_swizzles(swizzles) + + depth = format.block_size() + print ' uint%u_t value = 0;' % depth + + for i in range(4): + dst_channel = channels[i] + shift = dst_channel.shift + if inv_swizzle[i] is not None: + value ='src[%u]' % inv_swizzle[i] + dst_colorspace = format.colorspace + if dst_colorspace == SRGB and inv_swizzle[i] == 3: + # Alpha channel is linear + dst_colorspace = RGB + value = conversion_expr(src_channel, + dst_channel, dst_native_type, + value, + dst_colorspace = dst_colorspace) + if dst_channel.type in (UNSIGNED, SIGNED): + if shift + dst_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) + if shift: + value = '(%s) << %u' % (value, shift) + if dst_channel.type == SIGNED: + # Cast to unsigned + value = '(uint%u_t)(%s) ' % (depth, value) + else: + value = None + if value is not None: + print ' value |= %s;' % (value) + + print ' *(uint%u_t *)dst = value;' % depth + + def pack_into_union(channels, swizzles): + inv_swizzle = inv_swizzles(swizzles) + + print ' union util_format_%s pixel;' % format.short_name() + + for i in range(4): + dst_channel = channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue + dst_colorspace = format.colorspace + if dst_colorspace == SRGB and inv_swizzle[i] == 3: + # Alpha channel is linear + dst_colorspace = RGB + value ='src[%u]' % inv_swizzle[i] + value = conversion_expr(src_channel, + dst_channel, dst_native_type, + value, + dst_colorspace = dst_colorspace) + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + + print ' memcpy(dst, &pixel, sizeof pixel);' + + if format.is_bitmask(): + print_channels(format, pack_into_bitmask) + else: + print_channels(format, pack_into_union) + + +def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): + '''Generate the function to unpack pixels from a particular format''' + + name = format.short_name() + + print 'static INLINE void' + print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type) + print '{' + + if is_format_supported(format): + print ' unsigned x, y;' + print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) + print ' %s *dst = dst_row;' % (dst_native_type) + print ' const uint8_t *src = src_row;' + print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) + + generate_unpack_kernel(format, dst_channel, dst_native_type) + + print ' src += %u;' % (format.block_size() / 8,) + print ' dst += 4;' + print ' }' + print ' src_row += src_stride;' + print ' dst_row += dst_stride/sizeof(*dst_row);' + print ' }' + + print '}' + print + + +def generate_format_pack(format, src_channel, src_native_type, src_suffix): + '''Generate the function to pack pixels to a particular format''' + + name = format.short_name() + + print 'static INLINE void' + print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type) + print '{' + + if is_format_supported(format): + print ' unsigned x, y;' + print ' for(y = 0; y < height; y += %u) {' % (format.block_height,) + print ' const %s *src = src_row;' % (src_native_type) + print ' uint8_t *dst = dst_row;' + print ' for(x = 0; x < width; x += %u) {' % (format.block_width,) + + generate_pack_kernel(format, src_channel, src_native_type) + + print ' src += 4;' + print ' dst += %u;' % (format.block_size() / 8,) + print ' }' + print ' dst_row += dst_stride;' + print ' src_row += src_stride/sizeof(*src_row);' + print ' }' + + print '}' + print + + +def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix): + '''Generate the function to unpack pixels from a particular format''' + + name = format.short_name() + + print 'static INLINE void' + print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type) + print '{' + + if is_format_supported(format): + generate_unpack_kernel(format, dst_channel, dst_native_type) + + print '}' + print + + +def is_format_hand_written(format): + return format.layout in ('s3tc', 'rgtc', 'etc', 'bptc', 'subsampled', 'other') or format.colorspace == ZS + + +def generate(formats): + print + print '#include "pipe/p_compiler.h"' + print '#include "u_math.h"' + print '#include "u_half.h"' + print '#include "u_format.h"' + print + diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py new file mode 100755 index 0000000..929017a --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -0,0 +1,365 @@ +#!/usr/bin/env python + +''' +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +''' + + +VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) + +SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) + +PLAIN = 'plain' + +RGB = 'rgb' +SRGB = 'srgb' +YUV = 'yuv' +ZS = 'zs' + + +def is_pot(x): + return (x & (x - 1)) == 0 + + +VERY_LARGE = 99999999999999999999999 + + +class Channel: + '''Describe the channel of a color channel.''' + + def __init__(self, type, norm, pure, size, name = ''): + self.type = type + self.norm = norm + self.pure = pure + self.size = size + self.sign = type in (SIGNED, FIXED, FLOAT) + self.name = name + + def __str__(self): + s = str(self.type) + if self.norm: + s += 'n' + if self.pure: + s += 'p' + s += str(self.size) + return s + + def __eq__(self, other): + return self.type == other.type and self.norm == other.norm and self.pure == other.pure and self.size == other.size + + def max(self): + '''Maximum representable number.''' + if self.type == FLOAT: + return VERY_LARGE + if self.type == FIXED: + return (1 << (self.size/2)) - 1 + if self.norm: + return 1 + if self.type == UNSIGNED: + return (1 << self.size) - 1 + if self.type == SIGNED: + return (1 << (self.size - 1)) - 1 + assert False + + def min(self): + '''Minimum representable number.''' + if self.type == FLOAT: + return -VERY_LARGE + if self.type == FIXED: + return -(1 << (self.size/2)) + if self.type == UNSIGNED: + return 0 + if self.norm: + return -1 + if self.type == SIGNED: + return -(1 << (self.size - 1)) + assert False + + +class Format: + '''Describe a pixel format.''' + + def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace): + self.name = name + self.layout = layout + self.block_width = block_width + self.block_height = block_height + self.le_channels = le_channels + self.le_swizzles = le_swizzles + self.be_channels = be_channels + self.be_swizzles = be_swizzles + self.name = name + self.colorspace = colorspace + + def __str__(self): + return self.name + + def short_name(self): + '''Make up a short norm for a format, suitable to be used as suffix in + function names.''' + + name = self.name + if name.startswith('PIPE_FORMAT_'): + name = name[len('PIPE_FORMAT_'):] + name = name.lower() + return name + + def block_size(self): + size = 0 + for channel in self.le_channels: + size += channel.size + return size + + def nr_channels(self): + nr_channels = 0 + for channel in self.le_channels: + if channel.size: + nr_channels += 1 + return nr_channels + + def array_element(self): + if self.layout != PLAIN: + return None + ref_channel = self.le_channels[0] + if ref_channel.type == VOID: + ref_channel = self.le_channels[1] + for channel in self.le_channels: + if channel.size and (channel.size != ref_channel.size or channel.size % 8): + return None + if channel.type != VOID: + if channel.type != ref_channel.type: + return None + if channel.norm != ref_channel.norm: + return None + if channel.pure != ref_channel.pure: + return None + return ref_channel + + def is_array(self): + return self.array_element() != None + + def is_mixed(self): + if self.layout != PLAIN: + return False + ref_channel = self.le_channels[0] + if ref_channel.type == VOID: + ref_channel = self.le_channels[1] + for channel in self.le_channels[1:]: + if channel.type != VOID: + if channel.type != ref_channel.type: + return True + if channel.norm != ref_channel.norm: + return True + if channel.pure != ref_channel.pure: + return True + return False + + def is_pot(self): + return is_pot(self.block_size()) + + def is_int(self): + if self.layout != PLAIN: + return False + for channel in self.le_channels: + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + return True + + def is_float(self): + if self.layout != PLAIN: + return False + for channel in self.le_channels: + if channel.type not in (VOID, FLOAT): + return False + return True + + def is_bitmask(self): + if self.layout != PLAIN: + return False + if self.block_size() not in (8, 16, 32): + return False + for channel in self.le_channels: + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + return True + + def is_pure_color(self): + if self.layout != PLAIN or self.colorspace == ZS: + return False + pures = [channel.pure + for channel in self.le_channels + if channel.type != VOID] + for x in pures: + assert x == pures[0] + return pures[0] + + def channel_type(self): + types = [channel.type + for channel in self.le_channels + if channel.type != VOID] + for x in types: + assert x == types[0] + return types[0] + + def is_pure_signed(self): + return self.is_pure_color() and self.channel_type() == SIGNED + + def is_pure_unsigned(self): + return self.is_pure_color() and self.channel_type() == UNSIGNED + + def has_channel(self, id): + return self.le_swizzles[id] != SWIZZLE_NONE + + def has_depth(self): + return self.colorspace == ZS and self.has_channel(0) + + def has_stencil(self): + return self.colorspace == ZS and self.has_channel(1) + + def stride(self): + return self.block_size()/8 + + +_type_parse_map = { + '': VOID, + 'x': VOID, + 'u': UNSIGNED, + 's': SIGNED, + 'h': FIXED, + 'f': FLOAT, +} + +_swizzle_parse_map = { + 'x': SWIZZLE_X, + 'y': SWIZZLE_Y, + 'z': SWIZZLE_Z, + 'w': SWIZZLE_W, + '0': SWIZZLE_0, + '1': SWIZZLE_1, + '_': SWIZZLE_NONE, +} + +def _parse_channels(fields, layout, colorspace, swizzles): + if layout == PLAIN: + names = ['']*4 + if colorspace in (RGB, SRGB): + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'rgba'[i] + elif colorspace == ZS: + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'zs'[i] + else: + assert False + for i in range(4): + if names[i] == '': + names[i] = 'x' + else: + names = ['x', 'y', 'z', 'w'] + + channels = [] + for i in range(0, 4): + field = fields[i] + if field: + type = _type_parse_map[field[0]] + if field[1] == 'n': + norm = True + pure = False + size = int(field[2:]) + elif field[1] == 'p': + pure = True + norm = False + size = int(field[2:]) + else: + norm = False + pure = False + size = int(field[1:]) + else: + type = VOID + norm = False + pure = False + size = 0 + channel = Channel(type, norm, pure, size, names[i]) + channels.append(channel) + + return channels + +def parse(filename): + '''Parse the format descrition in CSV format in terms of the + Channel and Format classes above.''' + + stream = open(filename) + formats = [] + for line in stream: + try: + comment = line.index('#') + except ValueError: + pass + else: + line = line[:comment] + line = line.strip() + if not line: + continue + + fields = [field.strip() for field in line.split(',')] + if len (fields) == 10: + fields += fields[4:9] + assert len (fields) == 15 + + name = fields[0] + layout = fields[1] + block_width, block_height = map(int, fields[2:4]) + colorspace = fields[9] + + le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles) + + be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[14]] + be_channels = _parse_channels(fields[10:14], layout, colorspace, be_swizzles) + + le_shift = 0 + for channel in le_channels: + channel.shift = le_shift + le_shift += channel.size + + be_shift = 0 + for channel in be_channels[3::-1]: + channel.shift = be_shift + be_shift += channel.size + + assert le_shift == be_shift + for i in range(4): + assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE) + + format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace) + formats.append(format) + return formats + diff --git a/src/gallium/auxiliary/util/u_format_r11g11b10f.h b/src/gallium/auxiliary/util/u_format_r11g11b10f.h deleted file mode 100644 index 57516c3..0000000 --- a/src/gallium/auxiliary/util/u_format_r11g11b10f.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2011 Marek Olšák - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* Based on code from The OpenGL Programming Guide / 7th Edition, Appendix J. - * Available here: http://www.opengl-redbook.com/appendices/ - * The algorithm in the book contains a bug though, which is fixed in the code - * below. - */ - -#define UF11(e, m) ((e << 6) | (m)) -#define UF11_EXPONENT_BIAS 15 -#define UF11_EXPONENT_BITS 0x1F -#define UF11_EXPONENT_SHIFT 6 -#define UF11_MANTISSA_BITS 0x3F -#define UF11_MANTISSA_SHIFT (23 - UF11_EXPONENT_SHIFT) -#define UF11_MAX_EXPONENT (UF11_EXPONENT_BITS << UF11_EXPONENT_SHIFT) - -#define UF10(e, m) ((e << 5) | (m)) -#define UF10_EXPONENT_BIAS 15 -#define UF10_EXPONENT_BITS 0x1F -#define UF10_EXPONENT_SHIFT 5 -#define UF10_MANTISSA_BITS 0x1F -#define UF10_MANTISSA_SHIFT (23 - UF10_EXPONENT_SHIFT) -#define UF10_MAX_EXPONENT (UF10_EXPONENT_BITS << UF10_EXPONENT_SHIFT) - -#define F32_INFINITY 0x7f800000 - -static INLINE unsigned f32_to_uf11(float val) -{ - union { - float f; - uint32_t ui; - } f32 = {val}; - - uint16_t uf11 = 0; - - /* Decode little-endian 32-bit floating-point value */ - int sign = (f32.ui >> 16) & 0x8000; - /* Map exponent to the range [-127,128] */ - int exponent = ((f32.ui >> 23) & 0xff) - 127; - int mantissa = f32.ui & 0x007fffff; - - if (exponent == 128) { /* Infinity or NaN */ - /* From the GL_EXT_packed_float spec: - * - * "Additionally: negative infinity is converted to zero; positive - * infinity is converted to positive infinity; and both positive and - * negative NaN are converted to positive NaN." - */ - uf11 = UF11_MAX_EXPONENT; - if (mantissa) { - uf11 |= 1; /* NaN */ - } else { - if (sign) - uf11 = 0; /* 0.0 */ - } - } else if (sign) { - return 0; - } else if (val > 65024.0f) { - /* From the GL_EXT_packed_float spec: - * - * "Likewise, finite positive values greater than 65024 (the maximum - * finite representable unsigned 11-bit floating-point value) are - * converted to 65024." - */ - uf11 = UF11(30, 63); - } - else if (exponent > -15) { /* Representable value */ - exponent += UF11_EXPONENT_BIAS; - mantissa >>= UF11_MANTISSA_SHIFT; - uf11 = exponent << UF11_EXPONENT_SHIFT | mantissa; - } - - return uf11; -} - -static INLINE float uf11_to_f32(uint16_t val) -{ - union { - float f; - uint32_t ui; - } f32; - - int exponent = (val & 0x07c0) >> UF11_EXPONENT_SHIFT; - int mantissa = (val & 0x003f); - - f32.f = 0.0; - - if (exponent == 0) { - if (mantissa != 0) { - const float scale = 1.0 / (1 << 20); - f32.f = scale * mantissa; - } - } - else if (exponent == 31) { - f32.ui = F32_INFINITY | mantissa; - } - else { - float scale, decimal; - exponent -= 15; - if (exponent < 0) { - scale = 1.0f / (1 << -exponent); - } - else { - scale = (float) (1 << exponent); - } - decimal = 1.0f + (float) mantissa / 64; - f32.f = scale * decimal; - } - - return f32.f; -} - -static INLINE unsigned f32_to_uf10(float val) -{ - union { - float f; - uint32_t ui; - } f32 = {val}; - - uint16_t uf10 = 0; - - /* Decode little-endian 32-bit floating-point value */ - int sign = (f32.ui >> 16) & 0x8000; - /* Map exponent to the range [-127,128] */ - int exponent = ((f32.ui >> 23) & 0xff) - 127; - int mantissa = f32.ui & 0x007fffff; - - if (exponent == 128) { - /* From the GL_EXT_packed_float spec: - * - * "Additionally: negative infinity is converted to zero; positive - * infinity is converted to positive infinity; and both positive and - * negative NaN are converted to positive NaN." - */ - uf10 = UF10_MAX_EXPONENT; - if (mantissa) { - uf10 |= 1; /* NaN */ - } else { - if (sign) - uf10 = 0; /* 0.0 */ - } - } else if (sign) { - return 0; - } else if (val > 64512.0f) { - /* From the GL_EXT_packed_float spec: - * - * "Likewise, finite positive values greater than 64512 (the maximum - * finite representable unsigned 10-bit floating-point value) are - * converted to 64512." - */ - uf10 = UF10(30, 31); - } - else if (exponent > -15) { /* Representable value */ - exponent += UF10_EXPONENT_BIAS; - mantissa >>= UF10_MANTISSA_SHIFT; - uf10 = exponent << UF10_EXPONENT_SHIFT | mantissa; - } - - return uf10; -} - -static INLINE float uf10_to_f32(uint16_t val) -{ - union { - float f; - uint32_t ui; - } f32; - - int exponent = (val & 0x03e0) >> UF10_EXPONENT_SHIFT; - int mantissa = (val & 0x001f); - - f32.f = 0.0; - - if (exponent == 0) { - if (mantissa != 0) { - const float scale = 1.0 / (1 << 20); - f32.f = scale * mantissa; - } - } - else if (exponent == 31) { - f32.ui = F32_INFINITY | mantissa; - } - else { - float scale, decimal; - exponent -= 15; - if (exponent < 0) { - scale = 1.0f / (1 << -exponent); - } - else { - scale = (float) (1 << exponent); - } - decimal = 1.0f + (float) mantissa / 32; - f32.f = scale * decimal; - } - - return f32.f; -} - -static INLINE unsigned float3_to_r11g11b10f(const float rgb[3]) -{ - return ( f32_to_uf11(rgb[0]) & 0x7ff) | - ((f32_to_uf11(rgb[1]) & 0x7ff) << 11) | - ((f32_to_uf10(rgb[2]) & 0x3ff) << 22); -} - -static INLINE void r11g11b10f_to_float3(unsigned rgb, float retval[3]) -{ - retval[0] = uf11_to_f32( rgb & 0x7ff); - retval[1] = uf11_to_f32((rgb >> 11) & 0x7ff); - retval[2] = uf10_to_f32((rgb >> 22) & 0x3ff); -} diff --git a/src/gallium/auxiliary/util/u_format_rgb9e5.h b/src/gallium/auxiliary/util/u_format_rgb9e5.h deleted file mode 100644 index c2a3f6f..0000000 --- a/src/gallium/auxiliary/util/u_format_rgb9e5.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2011 Marek Olšák - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* Copied from EXT_texture_shared_exponent and edited. */ - -#ifndef RGB9E5_H -#define RGB9E5_H - -#include -#include - -#define RGB9E5_EXPONENT_BITS 5 -#define RGB9E5_MANTISSA_BITS 9 -#define RGB9E5_EXP_BIAS 15 -#define RGB9E5_MAX_VALID_BIASED_EXP 31 - -#define MAX_RGB9E5_EXP (RGB9E5_MAX_VALID_BIASED_EXP - RGB9E5_EXP_BIAS) -#define RGB9E5_MANTISSA_VALUES (1< 0.0) { - if (x >= MAX_RGB9E5) { - return MAX_RGB9E5; - } else { - return x; - } - } else { - /* NaN gets here too since comparisons with NaN always fail! */ - return 0.0; - } -} - -/* Ok, FloorLog2 is not correct for the denorm and zero values, but we - are going to do a max of this value with the minimum rgb9e5 exponent - that will hide these problem cases. */ -static INLINE int rgb9e5_FloorLog2(float x) -{ - float754 f; - - f.value = x; - return (f.field.biasedexponent - 127); -} - -static INLINE unsigned float3_to_rgb9e5(const float rgb[3]) -{ - rgb9e5 retval; - float maxrgb; - int rm, gm, bm; - float rc, gc, bc; - int exp_shared, maxm; - double denom; - - rc = rgb9e5_ClampRange(rgb[0]); - gc = rgb9e5_ClampRange(rgb[1]); - bc = rgb9e5_ClampRange(rgb[2]); - - maxrgb = MAX3(rc, gc, bc); - exp_shared = MAX2(-RGB9E5_EXP_BIAS-1, rgb9e5_FloorLog2(maxrgb)) + 1 + RGB9E5_EXP_BIAS; - assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP); - assert(exp_shared >= 0); - /* This pow function could be replaced by a table. */ - denom = pow(2, exp_shared - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS); - - maxm = (int) floor(maxrgb / denom + 0.5); - if (maxm == MAX_RGB9E5_MANTISSA+1) { - denom *= 2; - exp_shared += 1; - assert(exp_shared <= RGB9E5_MAX_VALID_BIASED_EXP); - } else { - assert(maxm <= MAX_RGB9E5_MANTISSA); - } - - rm = (int) floor(rc / denom + 0.5); - gm = (int) floor(gc / denom + 0.5); - bm = (int) floor(bc / denom + 0.5); - - assert(rm <= MAX_RGB9E5_MANTISSA); - assert(gm <= MAX_RGB9E5_MANTISSA); - assert(bm <= MAX_RGB9E5_MANTISSA); - assert(rm >= 0); - assert(gm >= 0); - assert(bm >= 0); - - retval.field.r = rm; - retval.field.g = gm; - retval.field.b = bm; - retval.field.biasedexponent = exp_shared; - - return retval.raw; -} - -static INLINE void rgb9e5_to_float3(unsigned rgb, float retval[3]) -{ - rgb9e5 v; - int exponent; - float scale; - - v.raw = rgb; - exponent = v.field.biasedexponent - RGB9E5_EXP_BIAS - RGB9E5_MANTISSA_BITS; - scale = (float) pow(2, exponent); - - retval[0] = v.field.r * scale; - retval[1] = v.field.g * scale; - retval[2] = v.field.b * scale; -} - -#endif diff --git a/src/gallium/auxiliary/util/u_format_rgtc.c b/src/gallium/auxiliary/util/u_format_rgtc.c deleted file mode 100644 index 18550e4..0000000 --- a/src/gallium/auxiliary/util/u_format_rgtc.c +++ /dev/null @@ -1,171 +0,0 @@ -/************************************************************************** - * - * Copyright (C) 2011 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include -#include "u_math.h" -#include "u_format.h" -#include "u_format_rgtc.h" -#include "util/rgtc.h" - -void -util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - -void -util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, - unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - -void -util_format_rgtc1_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc1_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc1_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - - -void -util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - -void -util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off) -{ -} - -void -util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_rxtc2_unorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1); -} - -void -util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - - -void -util_format_rgtc2_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - fprintf(stderr,"%s\n", __func__); -} - -void -util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ -} - -void -util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off) -{ -} - -void -util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_rxtc2_snorm_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, width, height, 1); -} - -void -util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ -} - diff --git a/src/gallium/auxiliary/util/u_format_rgtc.h b/src/gallium/auxiliary/util/u_format_rgtc.h deleted file mode 100644 index 67ac472..0000000 --- a/src/gallium/auxiliary/util/u_format_rgtc.h +++ /dev/null @@ -1,114 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Red Hat Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - -#ifndef U_FORMAT_RGTC_H_ -#define U_FORMAT_RGTC_H_ - -void -util_format_rgtc1_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_rgtc1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - - -void -util_format_rgtc1_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_rgtc1_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - -void -util_format_rgtc2_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_rgtc2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rxtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off); - -void -util_format_rgtc2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - -void -util_format_rgtc2_snorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_rgtc2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rxtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height, unsigned chan2off); - -void -util_format_rgtc2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - -#endif diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c index 318643b..18174e1 100644 --- a/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/src/gallium/auxiliary/util/u_format_s3tc.c @@ -29,704 +29,3 @@ #include "u_format_srgb.h" -static void -util_format_dxt1_rgb_fetch_stub(int src_stride, - const uint8_t *src, - int col, int row, - uint8_t *dst) -{ - assert(0); -} - - -static void -util_format_dxt1_rgba_fetch_stub(int src_stride, - const uint8_t *src, - int col, int row, - uint8_t *dst ) -{ - assert(0); -} - - -static void -util_format_dxt3_rgba_fetch_stub(int src_stride, - const uint8_t *src, - int col, int row, - uint8_t *dst ) -{ - assert(0); -} - - -static void -util_format_dxt5_rgba_fetch_stub(int src_stride, - const uint8_t *src, - int col, int row, - uint8_t *dst ) -{ - assert(0); -} - - -static void -util_format_dxtn_pack_stub(int src_comps, - int width, int height, - const uint8_t *src, - enum util_format_dxtn dst_format, - uint8_t *dst, - int dst_stride) -{ - assert(0); -} - - -boolean util_format_s3tc_enabled = FALSE; - -util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = util_format_dxt1_rgb_fetch_stub; -util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = util_format_dxt1_rgba_fetch_stub; -util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = util_format_dxt3_rgba_fetch_stub; -util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = util_format_dxt5_rgba_fetch_stub; - -util_format_dxtn_pack_t util_format_dxtn_pack = util_format_dxtn_pack_stub; - - -void -util_format_s3tc_init(void) -{ -} - - -/* - * Pixel fetch. - */ - -void -util_format_dxt1_rgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - util_format_dxt1_rgb_fetch(0, src, i, j, dst); -} - -void -util_format_dxt1_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - util_format_dxt1_rgba_fetch(0, src, i, j, dst); -} - -void -util_format_dxt3_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - util_format_dxt3_rgba_fetch(0, src, i, j, dst); -} - -void -util_format_dxt5_rgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - util_format_dxt5_rgba_fetch(0, src, i, j, dst); -} - -void -util_format_dxt1_rgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgb_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = 1.0; -} - -void -util_format_dxt1_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgba_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - -void -util_format_dxt3_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt3_rgba_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - -void -util_format_dxt5_rgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt5_rgba_fetch(0, src, i, j, tmp); - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - - -/* - * Block decompression. - */ - -static INLINE void -util_format_dxtn_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height, - util_format_dxtn_fetch_t fetch, - unsigned block_size, boolean srgb) -{ - const unsigned bw = 4, bh = 4, comps = 4; - unsigned x, y, i, j; - for(y = 0; y < height; y += bh) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += bw) { - for(j = 0; j < bh; ++j) { - for(i = 0; i < bw; ++i) { - uint8_t *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*comps; - fetch(0, src, i, j, dst); - if (srgb) { - dst[0] = util_format_srgb_to_linear_8unorm(dst[0]); - dst[1] = util_format_srgb_to_linear_8unorm(dst[1]); - dst[2] = util_format_srgb_to_linear_8unorm(dst[2]); - } - } - } - src += block_size; - } - src_row += src_stride; - } -} - -void -util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgb_fetch, - 8, FALSE); -} - -void -util_format_dxt1_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgba_fetch, - 8, FALSE); -} - -void -util_format_dxt3_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt3_rgba_fetch, - 16, FALSE); -} - -void -util_format_dxt5_rgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt5_rgba_fetch, - 16, FALSE); -} - -static INLINE void -util_format_dxtn_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height, - util_format_dxtn_fetch_t fetch, - unsigned block_size, boolean srgb) -{ - unsigned x, y, i, j; - for(y = 0; y < height; y += 4) { - const uint8_t *src = src_row; - for(x = 0; x < width; x += 4) { - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4; - uint8_t tmp[4]; - fetch(0, src, i, j, tmp); - if (srgb) { - dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); - dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); - dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); - } - else { - dst[0] = ubyte_to_float(tmp[0]); - dst[1] = ubyte_to_float(tmp[1]); - dst[2] = ubyte_to_float(tmp[2]); - } - dst[3] = ubyte_to_float(tmp[3]); - } - } - src += block_size; - } - src_row += src_stride; - } -} - -void -util_format_dxt1_rgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgb_fetch, - 8, FALSE); -} - -void -util_format_dxt1_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgba_fetch, - 8, FALSE); -} - -void -util_format_dxt3_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt3_rgba_fetch, - 16, FALSE); -} - -void -util_format_dxt5_rgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt5_rgba_fetch, - 16, FALSE); -} - - -/* - * Block compression. - */ - -static INLINE void -util_format_dxtn_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height, - enum util_format_dxtn format, - unsigned block_size, boolean srgb) -{ - const unsigned bw = 4, bh = 4, comps = 4; - unsigned x, y, i, j, k; - for(y = 0; y < height; y += bh) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += bw) { - uint8_t tmp[4][4][4]; /* [bh][bw][comps] */ - for(j = 0; j < bh; ++j) { - for(i = 0; i < bw; ++i) { - uint8_t src_tmp; - for(k = 0; k < 3; ++k) { - src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + k]; - if (srgb) { - tmp[j][i][k] = util_format_linear_to_srgb_8unorm(src_tmp); - } - else { - tmp[j][i][k] = src_tmp; - } - } - /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */ - tmp[j][i][3] = src[(y + j)*src_stride/sizeof(*src) + (x+i)*comps + 3]; - } - } - /* even for dxt1_rgb have 4 src comps */ - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0); - dst += block_size; - } - dst_row += dst_stride / sizeof(*dst_row); - } - -} - -void -util_format_dxt1_rgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT1_RGB, - 8, FALSE); -} - -void -util_format_dxt1_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT1_RGBA, - 8, FALSE); -} - -void -util_format_dxt3_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT3_RGBA, - 16, FALSE); -} - -void -util_format_dxt5_rgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT5_RGBA, - 16, FALSE); -} - -static INLINE void -util_format_dxtn_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height, - enum util_format_dxtn format, - unsigned block_size, boolean srgb) -{ - unsigned x, y, i, j, k; - for(y = 0; y < height; y += 4) { - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 4) { - uint8_t tmp[4][4][4]; - for(j = 0; j < 4; ++j) { - for(i = 0; i < 4; ++i) { - float src_tmp; - for(k = 0; k < 3; ++k) { - src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + k]; - if (srgb) { - tmp[j][i][k] = util_format_linear_float_to_srgb_8unorm(src_tmp); - } - else { - tmp[j][i][k] = float_to_ubyte(src_tmp); - } - } - /* for sake of simplicity there's an unneeded 4th component for dxt1_rgb */ - src_tmp = src[(y + j)*src_stride/sizeof(*src) + (x+i)*4 + 3]; - tmp[j][i][3] = float_to_ubyte(src_tmp); - } - } - util_format_dxtn_pack(4, 4, 4, &tmp[0][0][0], format, dst, 0); - dst += block_size; - } - dst_row += 4*dst_stride/sizeof(*dst_row); - } -} - -void -util_format_dxt1_rgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT1_RGB, - 8, FALSE); -} - -void -util_format_dxt1_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT1_RGBA, - 8, FALSE); -} - -void -util_format_dxt3_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT3_RGBA, - 16, FALSE); -} - -void -util_format_dxt5_rgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src, src_stride, - width, height, UTIL_FORMAT_DXT5_RGBA, - 16, FALSE); -} - - -/* - * SRGB variants. - */ - -void -util_format_dxt1_srgb_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgb_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); - dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); - dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); - dst[3] = 255; -} - -void -util_format_dxt1_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); - dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); - dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); - dst[3] = tmp[3]; -} - -void -util_format_dxt3_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt3_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); - dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); - dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); - dst[3] = tmp[3]; -} - -void -util_format_dxt5_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt5_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_to_linear_8unorm(tmp[0]); - dst[1] = util_format_srgb_to_linear_8unorm(tmp[1]); - dst[2] = util_format_srgb_to_linear_8unorm(tmp[2]); - dst[3] = tmp[3]; -} - -void -util_format_dxt1_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgb_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); - dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); - dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); - dst[3] = 1.0f; -} - -void -util_format_dxt1_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt1_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); - dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); - dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - -void -util_format_dxt3_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt3_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); - dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); - dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - -void -util_format_dxt5_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t tmp[4]; - util_format_dxt5_rgba_fetch(0, src, i, j, tmp); - dst[0] = util_format_srgb_8unorm_to_linear_float(tmp[0]); - dst[1] = util_format_srgb_8unorm_to_linear_float(tmp[1]); - dst[2] = util_format_srgb_8unorm_to_linear_float(tmp[2]); - dst[3] = ubyte_to_float(tmp[3]); -} - -void -util_format_dxt1_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgb_fetch, - 8, TRUE); -} - -void -util_format_dxt1_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgba_fetch, - 8, TRUE); -} - -void -util_format_dxt3_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt3_rgba_fetch, - 16, TRUE); -} - -void -util_format_dxt5_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_8unorm(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt5_rgba_fetch, - 16, TRUE); -} - -void -util_format_dxt1_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgb_fetch, - 8, TRUE); -} - -void -util_format_dxt1_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt1_rgba_fetch, - 8, TRUE); -} - -void -util_format_dxt3_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt3_rgba_fetch, - 16, TRUE); -} - -void -util_format_dxt5_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_rgb_unpack_rgba_float(dst_row, dst_stride, - src_row, src_stride, - width, height, - util_format_dxt5_rgba_fetch, - 16, TRUE); -} - -void -util_format_dxt1_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT1_RGB, - 8, TRUE); -} - -void -util_format_dxt1_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT1_RGBA, - 8, TRUE); -} - -void -util_format_dxt3_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT3_RGBA, - 16, TRUE); -} - -void -util_format_dxt5_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_8unorm(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT5_RGBA, - 16, TRUE); -} - -void -util_format_dxt1_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT1_RGB, - 8, TRUE); -} - -void -util_format_dxt1_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT1_RGBA, - 8, TRUE); -} - -void -util_format_dxt3_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT3_RGBA, - 16, TRUE); -} - -void -util_format_dxt5_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_dxtn_pack_rgba_float(dst_row, dst_stride, src_row, src_stride, - width, height, UTIL_FORMAT_DXT5_RGBA, - 16, TRUE); -} - diff --git a/src/gallium/auxiliary/util/u_format_srgb.c b/src/gallium/auxiliary/util/u_format_srgb.c deleted file mode 100644 index 2649089..0000000 --- a/src/gallium/auxiliary/util/u_format_srgb.c +++ /dev/null @@ -1,178 +0,0 @@ -/* This file is autogenerated by u_format_srgb.py. Do not edit directly. */ - -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/** - * @file - * SRGB translation. - * - * @author Brian Paul - * @author Michal Krol - * @author Jose Fonseca - */ - -#include "u_format_srgb.h" - -const float -util_format_srgb_8unorm_to_linear_float_table[256] = { - 0.0000000e+00, 3.0352698e-04, 6.0705397e-04, 9.1058095e-04, - 1.2141079e-03, 1.5176349e-03, 1.8211619e-03, 2.1246889e-03, - 2.4282159e-03, 2.7317429e-03, 3.0352698e-03, 3.3465358e-03, - 3.6765073e-03, 4.0247170e-03, 4.3914420e-03, 4.7769535e-03, - 5.1815167e-03, 5.6053916e-03, 6.0488330e-03, 6.5120908e-03, - 6.9954102e-03, 7.4990320e-03, 8.0231930e-03, 8.5681256e-03, - 9.1340587e-03, 9.7212173e-03, 1.0329823e-02, 1.0960094e-02, - 1.1612245e-02, 1.2286488e-02, 1.2983032e-02, 1.3702083e-02, - 1.4443844e-02, 1.5208514e-02, 1.5996293e-02, 1.6807376e-02, - 1.7641954e-02, 1.8500220e-02, 1.9382361e-02, 2.0288563e-02, - 2.1219010e-02, 2.2173885e-02, 2.3153366e-02, 2.4157632e-02, - 2.5186860e-02, 2.6241222e-02, 2.7320892e-02, 2.8426040e-02, - 2.9556834e-02, 3.0713444e-02, 3.1896033e-02, 3.3104767e-02, - 3.4339807e-02, 3.5601315e-02, 3.6889450e-02, 3.8204372e-02, - 3.9546235e-02, 4.0915197e-02, 4.2311411e-02, 4.3735029e-02, - 4.5186204e-02, 4.6665086e-02, 4.8171824e-02, 4.9706566e-02, - 5.1269458e-02, 5.2860647e-02, 5.4480276e-02, 5.6128490e-02, - 5.7805430e-02, 5.9511238e-02, 6.1246054e-02, 6.3010018e-02, - 6.4803267e-02, 6.6625939e-02, 6.8478170e-02, 7.0360096e-02, - 7.2271851e-02, 7.4213568e-02, 7.6185381e-02, 7.8187422e-02, - 8.0219820e-02, 8.2282707e-02, 8.4376212e-02, 8.6500462e-02, - 8.8655586e-02, 9.0841711e-02, 9.3058963e-02, 9.5307467e-02, - 9.7587347e-02, 9.9898728e-02, 1.0224173e-01, 1.0461648e-01, - 1.0702310e-01, 1.0946171e-01, 1.1193243e-01, 1.1443537e-01, - 1.1697067e-01, 1.1953843e-01, 1.2213877e-01, 1.2477182e-01, - 1.2743768e-01, 1.3013648e-01, 1.3286832e-01, 1.3563333e-01, - 1.3843162e-01, 1.4126329e-01, 1.4412847e-01, 1.4702727e-01, - 1.4995979e-01, 1.5292615e-01, 1.5592646e-01, 1.5896084e-01, - 1.6202938e-01, 1.6513219e-01, 1.6826940e-01, 1.7144110e-01, - 1.7464740e-01, 1.7788842e-01, 1.8116424e-01, 1.8447499e-01, - 1.8782077e-01, 1.9120168e-01, 1.9461783e-01, 1.9806932e-01, - 2.0155625e-01, 2.0507874e-01, 2.0863687e-01, 2.1223076e-01, - 2.1586050e-01, 2.1952620e-01, 2.2322796e-01, 2.2696587e-01, - 2.3074005e-01, 2.3455058e-01, 2.3839757e-01, 2.4228112e-01, - 2.4620133e-01, 2.5015828e-01, 2.5415209e-01, 2.5818285e-01, - 2.6225066e-01, 2.6635560e-01, 2.7049779e-01, 2.7467731e-01, - 2.7889426e-01, 2.8314874e-01, 2.8744084e-01, 2.9177065e-01, - 2.9613827e-01, 3.0054379e-01, 3.0498731e-01, 3.0946892e-01, - 3.1398871e-01, 3.1854678e-01, 3.2314321e-01, 3.2777810e-01, - 3.3245154e-01, 3.3716362e-01, 3.4191442e-01, 3.4670406e-01, - 3.5153260e-01, 3.5640014e-01, 3.6130678e-01, 3.6625260e-01, - 3.7123768e-01, 3.7626212e-01, 3.8132601e-01, 3.8642943e-01, - 3.9157248e-01, 3.9675523e-01, 4.0197778e-01, 4.0724021e-01, - 4.1254261e-01, 4.1788507e-01, 4.2326767e-01, 4.2869050e-01, - 4.3415364e-01, 4.3965717e-01, 4.4520119e-01, 4.5078578e-01, - 4.5641102e-01, 4.6207700e-01, 4.6778380e-01, 4.7353150e-01, - 4.7932018e-01, 4.8514994e-01, 4.9102085e-01, 4.9693300e-01, - 5.0288646e-01, 5.0888132e-01, 5.1491767e-01, 5.2099557e-01, - 5.2711513e-01, 5.3327640e-01, 5.3947949e-01, 5.4572446e-01, - 5.5201140e-01, 5.5834039e-01, 5.6471151e-01, 5.7112483e-01, - 5.7758044e-01, 5.8407842e-01, 5.9061884e-01, 5.9720179e-01, - 6.0382734e-01, 6.1049557e-01, 6.1720656e-01, 6.2396039e-01, - 6.3075714e-01, 6.3759687e-01, 6.4447968e-01, 6.5140564e-01, - 6.5837482e-01, 6.6538730e-01, 6.7244316e-01, 6.7954247e-01, - 6.8668531e-01, 6.9387176e-01, 7.0110189e-01, 7.0837578e-01, - 7.1569350e-01, 7.2305513e-01, 7.3046074e-01, 7.3791041e-01, - 7.4540421e-01, 7.5294222e-01, 7.6052450e-01, 7.6815115e-01, - 7.7582222e-01, 7.8353779e-01, 7.9129794e-01, 7.9910274e-01, - 8.0695226e-01, 8.1484657e-01, 8.2278575e-01, 8.3076988e-01, - 8.3879901e-01, 8.4687323e-01, 8.5499261e-01, 8.6315721e-01, - 8.7136712e-01, 8.7962240e-01, 8.8792312e-01, 8.9626935e-01, - 9.0466117e-01, 9.1309865e-01, 9.2158186e-01, 9.3011086e-01, - 9.3868573e-01, 9.4730654e-01, 9.5597335e-01, 9.6468625e-01, - 9.7344529e-01, 9.8225055e-01, 9.9110210e-01, 1.0000000e+00, -}; - -const uint8_t -util_format_srgb_to_linear_8unorm_table[256] = { - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, - 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, - 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 20, - 20, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 29, 29, - 30, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 37, 38, 39, 40, 41, - 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - 71, 72, 73, 74, 76, 77, 78, 79, 80, 81, 82, 84, 85, 86, 87, 88, - 90, 91, 92, 93, 95, 96, 97, 99, 100, 101, 103, 104, 105, 107, 108, 109, - 111, 112, 114, 115, 116, 118, 119, 121, 122, 124, 125, 127, 128, 130, 131, 133, - 134, 136, 138, 139, 141, 142, 144, 146, 147, 149, 151, 152, 154, 156, 157, 159, - 161, 163, 164, 166, 168, 170, 171, 173, 175, 177, 179, 181, 183, 184, 186, 188, - 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, - 222, 224, 226, 229, 231, 233, 235, 237, 239, 242, 244, 246, 248, 250, 253, 255, -}; - -const uint8_t -util_format_linear_to_srgb_8unorm_table[256] = { - 0, 13, 22, 28, 34, 38, 42, 46, 50, 53, 56, 59, 61, 64, 66, 69, - 71, 73, 75, 77, 79, 81, 83, 85, 86, 88, 90, 92, 93, 95, 96, 98, - 99, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 115, 117, 118, 119, - 120, 121, 122, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, - 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 148, 149, 150, 151, - 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 164, - 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 173, 173, 174, 175, 175, 176, - 177, 178, 178, 179, 180, 180, 181, 182, 182, 183, 184, 185, 185, 186, 187, 187, - 188, 189, 189, 190, 190, 191, 192, 192, 193, 194, 194, 195, 196, 196, 197, 197, - 198, 199, 199, 200, 200, 201, 202, 202, 203, 203, 204, 205, 205, 206, 206, 207, - 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214, 214, 215, 215, 216, - 216, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 223, 224, 224, - 225, 226, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, - 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, - 241, 241, 242, 242, 243, 243, 244, 244, 245, 245, 246, 246, 246, 247, 247, 248, - 248, 249, 249, 250, 250, 251, 251, 251, 252, 252, 253, 253, 254, 254, 255, 255, -}; - -const unsigned -util_format_linear_to_srgb_helper_table[104] = { - 0x0073000d, 0x007a000d, 0x0080000d, 0x0087000d, - 0x008d000d, 0x0094000d, 0x009a000d, 0x00a1000d, - 0x00a7001a, 0x00b4001a, 0x00c1001a, 0x00ce001a, - 0x00da001a, 0x00e7001a, 0x00f4001a, 0x0101001a, - 0x010e0033, 0x01280033, 0x01410033, 0x015b0033, - 0x01750033, 0x018f0033, 0x01a80033, 0x01c20033, - 0x01dc0067, 0x020f0067, 0x02430067, 0x02760067, - 0x02aa0067, 0x02dd0067, 0x03110067, 0x03440067, - 0x037800ce, 0x03df00ce, 0x044600ce, 0x04ad00ce, - 0x051400ce, 0x057b00c5, 0x05dd00bc, 0x063b00b5, - 0x06970158, 0x07420142, 0x07e30130, 0x087b0120, - 0x090b0112, 0x09940106, 0x0a1700fc, 0x0a9500f2, - 0x0b0f01cb, 0x0bf401ae, 0x0ccb0195, 0x0d950180, - 0x0e56016e, 0x0f0d015e, 0x0fbc0150, 0x10630143, - 0x11070264, 0x1238023e, 0x1357021d, 0x14660201, - 0x156601e9, 0x165a01d3, 0x174401c0, 0x182401af, - 0x18fe0331, 0x1a9602fe, 0x1c1502d2, 0x1d7e02ad, - 0x1ed4028d, 0x201a0270, 0x21520256, 0x227d0240, - 0x239f0443, 0x25c003fe, 0x27bf03c4, 0x29a10392, - 0x2b6a0367, 0x2d1d0341, 0x2ebe031f, 0x304d0300, - 0x31d105b0, 0x34a80555, 0x37520507, 0x39d504c5, - 0x3c37048b, 0x3e7c0458, 0x40a8042a, 0x42bd0401, - 0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, - 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559, - 0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, - 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723, -}; - diff --git a/src/gallium/auxiliary/util/u_format_srgb.h b/src/gallium/auxiliary/util/u_format_srgb.h deleted file mode 100644 index 740a919..0000000 --- a/src/gallium/auxiliary/util/u_format_srgb.h +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - -/** - * @file - * SRGB translation. - * - * @author Brian Paul - * @author Michal Krol - * @author Jose Fonseca - */ - -#ifndef U_FORMAT_SRGB_H_ -#define U_FORMAT_SRGB_H_ - - -#include "pipe/p_compiler.h" -#include "u_pack_color.h" -#include "u_math.h" - - -extern const float -util_format_srgb_8unorm_to_linear_float_table[256]; - -extern const uint8_t -util_format_srgb_to_linear_8unorm_table[256]; - -extern const uint8_t -util_format_linear_to_srgb_8unorm_table[256]; - -extern const unsigned -util_format_linear_to_srgb_helper_table[104]; - - -/** - * Convert a unclamped linear float to srgb value in the [0,255]. - */ -static INLINE uint8_t -util_format_linear_float_to_srgb_8unorm(float x) -{ - /* this would be exact but (probably much) slower */ - if (0) { - if (x >= 1.0f) - return 255; - else if (x >= 0.0031308f) - return float_to_ubyte(1.055f * powf(x, 0.41666666f) - 0.055f); - else if (x > 0.0f) - return float_to_ubyte(12.92f * x); - else - return 0; - } - else { - /* - * This is taken from https://gist.github.com/rygorous/2203834 - * Use LUT and do linear interpolation. - */ - union fi almostone, minval, f; - unsigned tab, bias, scale, t; - - almostone.ui = 0x3f7fffff; - minval.ui = (127-13) << 23; - - /* - * Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively. - * The tests are carefully written so that NaNs map to 0, same as in the - * reference implementation. - */ - if (!(x > minval.f)) - x = minval.f; - if (x > almostone.f) - x = almostone.f; - - /* Do the table lookup and unpack bias, scale */ - f.f = x; - tab = util_format_linear_to_srgb_helper_table[(f.ui - minval.ui) >> 20]; - bias = (tab >> 16) << 9; - scale = tab & 0xffff; - - /* Grab next-highest mantissa bits and perform linear interpolation */ - t = (f.ui >> 12) & 0xff; - return (uint8_t) ((bias + scale*t) >> 16); - } -} - - -/** - * Convert an 8-bit sRGB value from non-linear space to a - * linear RGB value in [0, 1]. - * Implemented with a 256-entry lookup table. - */ -static INLINE float -util_format_srgb_8unorm_to_linear_float(uint8_t x) -{ - return util_format_srgb_8unorm_to_linear_float_table[x]; -} - - -/* - * XXX These 2 functions probably don't make a lot of sense (but lots - * of potential callers which most likely all don't make sense neither) - */ - -/** - * Convert a 8bit normalized value from linear to srgb. - */ -static INLINE uint8_t -util_format_linear_to_srgb_8unorm(uint8_t x) -{ - return util_format_linear_to_srgb_8unorm_table[x]; -} - - -/** - * Convert a 8bit normalized value from srgb to linear. - */ -static INLINE uint8_t -util_format_srgb_to_linear_8unorm(uint8_t x) -{ - return util_format_srgb_to_linear_8unorm_table[x]; -} - - -#endif /* U_FORMAT_SRGB_H_ */ diff --git a/src/gallium/auxiliary/util/u_format_table.c b/src/gallium/auxiliary/util/u_format_table.c deleted file mode 100644 index 1cb0484..0000000 --- a/src/gallium/auxiliary/util/u_format_table.c +++ /dev/null @@ -1,33985 +0,0 @@ -/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */ - -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#include "u_format.h" -#include "u_format_s3tc.h" -#include "u_format_rgtc.h" -#include "u_format_latc.h" -#include "u_format_etc.h" - - -#include "pipe/p_compiler.h" -#include "u_math.h" -#include "u_half.h" -#include "u_format.h" -#include "u_format_other.h" -#include "u_format_srgb.h" -#include "u_format_yuv.h" -#include "u_format_zs.h" - -union util_format_none { - uint8_t value; - struct { - uint8_t r; - } chan; -}; - -static INLINE void -util_format_none_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_none_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[0], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_none_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b8g8r8a8_unorm { - uint32_t value; - struct { - uint8_t b; - uint8_t g; - uint8_t r; - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[2])) & 0xff; - value |= ((float_to_ubyte(src[1])) & 0xff) << 8; - value |= ((float_to_ubyte(src[0])) & 0xff) << 16; - value |= (float_to_ubyte(src[3])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b8g8r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[2]) & 0xff; - value |= ((src[1]) & 0xff) << 8; - value |= ((src[0]) & 0xff) << 16; - value |= (src[3]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b8g8r8x8_unorm { - uint32_t value; - struct { - uint8_t b; - uint8_t g; - uint8_t r; - uint8_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[2])) & 0xff; - value |= ((float_to_ubyte(src[1])) & 0xff) << 8; - value |= ((float_to_ubyte(src[0])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b8g8r8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[2]) & 0xff; - value |= ((src[1]) & 0xff) << 8; - value |= ((src[0]) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8r8g8b8_unorm { - uint32_t value; - struct { - uint8_t a; - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[3])) & 0xff; - value |= ((float_to_ubyte(src[0])) & 0xff) << 8; - value |= ((float_to_ubyte(src[1])) & 0xff) << 16; - value |= (float_to_ubyte(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[3]) & 0xff; - value |= ((src[0]) & 0xff) << 8; - value |= ((src[1]) & 0xff) << 16; - value |= (src[2]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_x8r8g8b8_unorm { - uint32_t value; - struct { - uint8_t x; - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((float_to_ubyte(src[0])) & 0xff) << 8; - value |= ((float_to_ubyte(src[1])) & 0xff) << 16; - value |= (float_to_ubyte(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_x8r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((src[0]) & 0xff) << 8; - value |= ((src[1]) & 0xff) << 16; - value |= (src[2]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8b8g8r8_unorm { - uint32_t value; - struct { - uint8_t a; - uint8_t b; - uint8_t g; - uint8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[3])) & 0xff; - value |= ((float_to_ubyte(src[2])) & 0xff) << 8; - value |= ((float_to_ubyte(src[1])) & 0xff) << 16; - value |= (float_to_ubyte(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[3]) & 0xff; - value |= ((src[2]) & 0xff) << 8; - value |= ((src[1]) & 0xff) << 16; - value |= (src[0]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_x8b8g8r8_unorm { - uint32_t value; - struct { - uint8_t x; - uint8_t b; - uint8_t g; - uint8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((float_to_ubyte(src[2])) & 0xff) << 8; - value |= ((float_to_ubyte(src[1])) & 0xff) << 16; - value |= (float_to_ubyte(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_x8b8g8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((src[2]) & 0xff) << 8; - value |= ((src[1]) & 0xff) << 16; - value |= (src[0]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8x8_unorm { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[0])) & 0xff; - value |= ((float_to_ubyte(src[1])) & 0xff) << 8; - value |= ((float_to_ubyte(src[2])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8x8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[0]) & 0xff; - value |= ((src[1]) & 0xff) << 8; - value |= ((src[2]) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b5g5r5x1_unorm { - uint16_t value; - struct { - unsigned b:5; - unsigned g:5; - unsigned r:5; - unsigned x:1; - } chan; -}; - -static INLINE void -util_format_b5g5r5x1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x1f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g5r5x1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; - value |= (((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0x1f)) & 0x1f) << 5; - value |= (((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0x1f)) & 0x1f) << 10; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b5g5r5x1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x1f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b5g5r5x1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0x1f); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0x1f); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x1f); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g5r5x1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)(src[2] >> 3)) & 0x1f; - value |= (((uint16_t)(src[1] >> 3)) & 0x1f) << 5; - value |= (((uint16_t)(src[0] >> 3)) & 0x1f) << 10; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b5g5r5a1_unorm { - uint16_t value; - struct { - unsigned b:5; - unsigned g:5; - unsigned r:5; - unsigned a:1; - } chan; -}; - -static INLINE void -util_format_b5g5r5a1_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - a = value >> 15; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x1f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g5r5a1_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; - value |= (((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0x1f)) & 0x1f) << 5; - value |= (((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0x1f)) & 0x1f) << 10; - value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0x1)) << 15; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b5g5r5a1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - a = value >> 15; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x1f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ -} - -static INLINE void -util_format_b5g5r5a1_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0x1f; - g = (value >> 5) & 0x1f; - r = (value >> 10) & 0x1f; - a = value >> 15; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0x1f); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0x1f); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x1f); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0x1); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g5r5a1_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)(src[2] >> 3)) & 0x1f; - value |= (((uint16_t)(src[1] >> 3)) & 0x1f) << 5; - value |= (((uint16_t)(src[0] >> 3)) & 0x1f) << 10; - value |= ((uint16_t)(src[3] >> 7)) << 15; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b4g4r4a4_unorm { - uint16_t value; - struct { - unsigned b:4; - unsigned g:4; - unsigned r:4; - unsigned a:4; - } chan; -}; - -static INLINE void -util_format_b4g4r4a4_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - a = value >> 12; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0xf)); /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b4g4r4a4_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xf)) & 0xf; - value |= (((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xf)) & 0xf) << 4; - value |= (((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf) << 8; - value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 12; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b4g4r4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - a = value >> 12; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0xf)); /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ -} - -static INLINE void -util_format_b4g4r4a4_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - uint16_t a; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - a = value >> 12; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0xf); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0xf); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b4g4r4a4_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)(src[2] >> 4)) & 0xf; - value |= (((uint16_t)(src[1] >> 4)) & 0xf) << 4; - value |= (((uint16_t)(src[0] >> 4)) & 0xf) << 8; - value |= ((uint16_t)(src[3] >> 4)) << 12; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b4g4r4x4_unorm { - uint16_t value; - struct { - unsigned b:4; - unsigned g:4; - unsigned r:4; - unsigned x:4; - } chan; -}; - -static INLINE void -util_format_b4g4r4x4_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0xf)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b4g4r4x4_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xf)) & 0xf; - value |= (((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xf)) & 0xf) << 4; - value |= (((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b4g4r4x4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0xf)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b4g4r4x4_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0xf; - g = (value >> 4) & 0xf; - r = (value >> 8) & 0xf; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0xf); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0xf); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b4g4r4x4_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)(src[2] >> 4)) & 0xf; - value |= (((uint16_t)(src[1] >> 4)) & 0xf) << 4; - value |= (((uint16_t)(src[0] >> 4)) & 0xf) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b5g6r5_unorm { - uint16_t value; - struct { - unsigned b:5; - unsigned g:6; - unsigned r:5; - } chan; -}; - -static INLINE void -util_format_b5g6r5_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x3f; - r = value >> 11; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x3f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g6r5_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; - value |= (((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0x3f)) & 0x3f) << 5; - value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0x1f)) << 11; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b5g6r5_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x3f; - r = value >> 11; - dst[0] = (float)(r * (1.0f/0x1f)); /* r */ - dst[1] = (float)(g * (1.0f/0x3f)); /* g */ - dst[2] = (float)(b * (1.0f/0x1f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b5g6r5_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t b; - uint16_t g; - uint16_t r; - b = (value) & 0x1f; - g = (value >> 5) & 0x3f; - r = value >> 11; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0x1f); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0x3f); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x1f); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b5g6r5_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint16_t)(src[2] >> 3)) & 0x1f; - value |= (((uint16_t)(src[1] >> 2)) & 0x3f) << 5; - value |= ((uint16_t)(src[0] >> 3)) << 11; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10a2_unorm { - uint32_t value; - struct { - unsigned r:10; - unsigned g:10; - unsigned b:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_r10g10b10a2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)util_iround(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff; - value |= (((uint32_t)util_iround(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10; - value |= (((uint32_t)util_iround(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff) << 20; - value |= ((uint32_t)util_iround(CLAMP(src[3], 0, 1) * 0x3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10a2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ -} - -static INLINE void -util_format_r10g10b10a2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (uint8_t)(r >> 2); /* r */ - dst[1] = (uint8_t)(g >> 2); /* g */ - dst[2] = (uint8_t)(b >> 2); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0x3); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[0]) * 0x3ff / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x3ff / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[2]) * 0x3ff / 0xff)) & 0x3ff) << 20; - value |= ((uint32_t)(src[3] >> 6)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10a2_unorm { - uint32_t value; - struct { - unsigned b:10; - unsigned g:10; - unsigned r:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10a2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)util_iround(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff; - value |= (((uint32_t)util_iround(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10; - value |= (((uint32_t)util_iround(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20; - value |= ((uint32_t)util_iround(CLAMP(src[3], 0, 1) * 0x3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10a2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ -} - -static INLINE void -util_format_b10g10r10a2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (uint8_t)(r >> 2); /* r */ - dst[1] = (uint8_t)(g >> 2); /* g */ - dst[2] = (uint8_t)(b >> 2); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0x3); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[2]) * 0x3ff / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x3ff / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[0]) * 0x3ff / 0xff)) & 0x3ff) << 20; - value |= ((uint32_t)(src[3] >> 6)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b2g3r3_unorm { - uint8_t value; - struct { - unsigned b:2; - unsigned g:3; - unsigned r:3; - } chan; -}; - -static INLINE void -util_format_b2g3r3_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t b; - uint8_t g; - uint8_t r; - b = (value) & 0x3; - g = (value >> 2) & 0x7; - r = value >> 5; - dst[0] = (float)(r * (1.0f/0x7)); /* r */ - dst[1] = (float)(g * (1.0f/0x7)); /* g */ - dst[2] = (float)(b * (1.0f/0x3)); /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b2g3r3_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)util_iround(CLAMP(src[2], 0, 1) * 0x3)) & 0x3; - value |= (((uint8_t)util_iround(CLAMP(src[1], 0, 1) * 0x7)) & 0x7) << 2; - value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0x7)) << 5; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b2g3r3_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t b; - uint8_t g; - uint8_t r; - b = (value) & 0x3; - g = (value >> 2) & 0x7; - r = value >> 5; - dst[0] = (float)(r * (1.0f/0x7)); /* r */ - dst[1] = (float)(g * (1.0f/0x7)); /* g */ - dst[2] = (float)(b * (1.0f/0x3)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b2g3r3_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t b; - uint8_t g; - uint8_t r; - b = (value) & 0x3; - g = (value >> 2) & 0x7; - r = value >> 5; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0x7); /* r */ - dst[1] = (uint8_t)(((uint32_t)g) * 0xff / 0x7); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x3); /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b2g3r3_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)(src[2] >> 6)) & 0x3; - value |= (((uint8_t)(src[1] >> 5)) & 0x7) << 2; - value |= ((uint8_t)(src[0] >> 5)) << 5; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8_unorm { - uint8_t value; - struct { - uint8_t rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = ubyte_to_float(rgb); /* r */ - dst[1] = ubyte_to_float(rgb); /* g */ - dst[2] = ubyte_to_float(rgb); /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= float_to_ubyte(src[0]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = ubyte_to_float(rgb); /* r */ - dst[1] = ubyte_to_float(rgb); /* g */ - dst[2] = ubyte_to_float(rgb); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= src[0]; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8_unorm { - uint8_t value; - struct { - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= float_to_ubyte(src[3]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= src[3]; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i8_unorm { - uint8_t value; - struct { - uint8_t rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = ubyte_to_float(rgba); /* r */ - dst[1] = ubyte_to_float(rgba); /* g */ - dst[2] = ubyte_to_float(rgba); /* b */ - dst[3] = ubyte_to_float(rgba); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= float_to_ubyte(src[0]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = ubyte_to_float(rgba); /* r */ - dst[1] = ubyte_to_float(rgba); /* g */ - dst[2] = ubyte_to_float(rgba); /* b */ - dst[3] = ubyte_to_float(rgba); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = rgba; /* r */ - dst[1] = rgba; /* g */ - dst[2] = rgba; /* b */ - dst[3] = rgba; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= src[0]; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l4a4_unorm { - uint8_t value; - struct { - unsigned rgb:4; - unsigned a:4; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - uint8_t a; - rgb = (value) & 0xf; - a = value >> 4; - dst[0] = (float)(rgb * (1.0f/0xf)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xf)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xf)); /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf; - value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - uint8_t a; - rgb = (value) & 0xf; - a = value >> 4; - dst[0] = (float)(rgb * (1.0f/0xf)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xf)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xf)); /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - uint8_t a; - rgb = (value) & 0xf; - a = value >> 4; - dst[0] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* r */ - dst[1] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* g */ - dst[2] = (uint8_t)(((uint32_t)rgb) * 0xff / 0xf); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)(src[0] >> 4)) & 0xf; - value |= ((uint8_t)(src[3] >> 4)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8a8_unorm { - uint16_t value; - struct { - uint8_t rgb; - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = ubyte_to_float(rgb); /* r */ - dst[1] = ubyte_to_float(rgb); /* g */ - dst[2] = ubyte_to_float(rgb); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (float_to_ubyte(src[0])) & 0xff; - value |= (float_to_ubyte(src[3])) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = ubyte_to_float(rgb); /* r */ - dst[1] = ubyte_to_float(rgb); /* g */ - dst[2] = ubyte_to_float(rgb); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (src[0]) & 0xff; - value |= (src[3]) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16_unorm { - uint16_t value; - struct { - uint16_t rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (uint8_t)(rgb >> 8); /* r */ - dst[1] = (uint8_t)(rgb >> 8); /* g */ - dst[2] = (uint8_t)(rgb >> 8); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a16_unorm { - uint16_t value; - struct { - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(a >> 8); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i16_unorm { - uint16_t value; - struct { - uint16_t rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */ - dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (float)(rgba * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgba * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgba * (1.0f/0xffff)); /* b */ - dst[3] = (float)(rgba * (1.0f/0xffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (uint8_t)(rgba >> 8); /* r */ - dst[1] = (uint8_t)(rgba >> 8); /* g */ - dst[2] = (uint8_t)(rgba >> 8); /* b */ - dst[3] = (uint8_t)(rgba >> 8); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16a16_unorm { - uint32_t value; - struct { - uint16_t rgb; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff; - value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (float)(rgb * (1.0f/0xffff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0xffff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0xffff)); /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (uint8_t)(rgb >> 8); /* r */ - dst[1] = (uint8_t)(rgb >> 8); /* g */ - dst[2] = (uint8_t)(rgb >> 8); /* b */ - dst[3] = (uint8_t)(a >> 8); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff; - value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8_snorm { - uint8_t value; - struct { - int8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)(src[3] >> 1)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8_snorm { - uint8_t value; - struct { - int8_t rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)(src[0] >> 1)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8a8_snorm { - uint16_t value; - struct { - int8_t rgb; - int8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (float)(rgb * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7f)); /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(rgb, 0)) * 0xff / 0x7f); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ; - value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i8_snorm { - uint8_t value; - struct { - int8_t rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */ - dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (float)(rgba * (1.0f/0x7f)); /* r */ - dst[1] = (float)(rgba * (1.0f/0x7f)); /* g */ - dst[2] = (float)(rgba * (1.0f/0x7f)); /* b */ - dst[3] = (float)(rgba * (1.0f/0x7f)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(rgba, 0)) * 0xff / 0x7f); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)(src[0] >> 1)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a16_snorm { - uint16_t value; - struct { - int16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16_snorm { - uint16_t value; - struct { - int16_t rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16a16_snorm { - uint32_t value; - struct { - int16_t rgb; - int16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (float)(rgb * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgb * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgb * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (uint8_t)(MAX2(rgb, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(rgb, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(rgb, 0) >> 7); /* b */ - dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i16_snorm { - uint16_t value; - struct { - int16_t rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (float)(rgba * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(rgba * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(rgba * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(rgba * (1.0f/0x7fff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (uint8_t)(MAX2(rgba, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(rgba, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(rgba, 0) >> 7); /* b */ - dst[3] = (uint8_t)(MAX2(rgba, 0) >> 7); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a16_float { - uint16_t value; - struct { - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_a16_float pixel; - pixel.chan.a = util_float_to_half(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_a16_float pixel; - pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16_float { - uint16_t value; - struct { - uint16_t rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgb); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgb); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgb); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l16_float pixel; - pixel.chan.rgb = util_float_to_half(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgb); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgb); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgb); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l16_float pixel; - pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16a16_float { - uint32_t value; - struct { - uint16_t rgb; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgb); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgb); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgb); /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l16a16_float pixel; - pixel.chan.rgb = util_float_to_half(src[0]); - pixel.chan.a = util_float_to_half(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgb); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgb); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgb); /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgb)); /* b */ - dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l16a16_float pixel; - pixel.chan.rgb = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i16_float { - uint16_t value; - struct { - uint16_t rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_i16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgba); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgba); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgba); /* b */ - dst[3] = util_half_to_float(pixel.chan.rgba); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_i16_float pixel; - pixel.chan.rgba = util_float_to_half(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_i16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.rgba); /* r */ - dst[1] = util_half_to_float(pixel.chan.rgba); /* g */ - dst[2] = util_half_to_float(pixel.chan.rgba); /* b */ - dst[3] = util_half_to_float(pixel.chan.rgba); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_i16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* b */ - dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.rgba)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_i16_float pixel; - pixel.chan.rgba = util_float_to_half((float)(src[0] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a32_float { - uint32_t value; - struct { - float a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_a32_float pixel; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = float_to_ubyte(pixel.chan.a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_a32_float pixel; - pixel.chan.a = ubyte_to_float(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32_float { - uint32_t value; - struct { - float rgb; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32_float pixel; - pixel.chan.rgb = src[0]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */ - dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */ - dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32_float pixel; - pixel.chan.rgb = ubyte_to_float(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32a32_float { - uint64_t value; - struct { - float rgb; - float a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_float pixel; - pixel.chan.rgb = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.rgb); /* r */ - dst[1] = float_to_ubyte(pixel.chan.rgb); /* g */ - dst[2] = float_to_ubyte(pixel.chan.rgb); /* b */ - dst[3] = float_to_ubyte(pixel.chan.a); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_float pixel; - pixel.chan.rgb = ubyte_to_float(src[0]); - pixel.chan.a = ubyte_to_float(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i32_float { - uint32_t value; - struct { - float rgba; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_i32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgba; /* r */ - dst[1] = pixel.chan.rgba; /* g */ - dst[2] = pixel.chan.rgba; /* b */ - dst[3] = pixel.chan.rgba; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_i32_float pixel; - pixel.chan.rgba = src[0]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_i32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgba; /* r */ - dst[1] = pixel.chan.rgba; /* g */ - dst[2] = pixel.chan.rgba; /* b */ - dst[3] = pixel.chan.rgba; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_i32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.rgba); /* r */ - dst[1] = float_to_ubyte(pixel.chan.rgba); /* g */ - dst[2] = float_to_ubyte(pixel.chan.rgba); /* b */ - dst[3] = float_to_ubyte(pixel.chan.rgba); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_i32_float pixel; - pixel.chan.rgba = ubyte_to_float(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8_srgb { - uint8_t value; - struct { - uint8_t rgb; - } chan; -}; - -static INLINE void -util_format_l8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = util_format_srgb_8unorm_to_linear_float(rgb); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(rgb); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(rgb); /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= util_format_linear_float_to_srgb_8unorm(src[0]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = util_format_srgb_8unorm_to_linear_float(rgb); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(rgb); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(rgb); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = util_format_srgb_to_linear_8unorm(rgb); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(rgb); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(rgb); /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= util_format_linear_to_srgb_8unorm(src[0]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8a8_srgb { - uint16_t value; - struct { - uint8_t rgb; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_l8a8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = util_format_srgb_8unorm_to_linear_float(rgb); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(rgb); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(rgb); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff; - value |= (float_to_ubyte(src[3])) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8a8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = util_format_srgb_8unorm_to_linear_float(rgb); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(rgb); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(rgb); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -util_format_l8a8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = util_format_srgb_to_linear_8unorm(rgb); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(rgb); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(rgb); /* b */ - dst[3] = a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (util_format_linear_to_srgb_8unorm(src[0])) & 0xff; - value |= (src[3]) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_srgb { - struct { - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -util_format_r8g8b8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_srgb pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_format_srgb_8unorm_to_linear_float(pixel.chan.r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(pixel.chan.g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_srgb pixel; - pixel.chan.r = util_format_linear_float_to_srgb_8unorm(src[0]); - pixel.chan.g = util_format_linear_float_to_srgb_8unorm(src[1]); - pixel.chan.b = util_format_linear_float_to_srgb_8unorm(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_srgb pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_format_srgb_8unorm_to_linear_float(pixel.chan.r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(pixel.chan.g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8b8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_srgb pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_format_srgb_to_linear_8unorm(pixel.chan.r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(pixel.chan.g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(pixel.chan.b); /* b */ - dst[3] = 255; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_srgb pixel; - pixel.chan.r = util_format_linear_to_srgb_8unorm(src[0]); - pixel.chan.g = util_format_linear_to_srgb_8unorm(src[1]); - pixel.chan.b = util_format_linear_to_srgb_8unorm(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_srgb { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_r8g8b8a8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 16; - value |= (float_to_ubyte(src[3])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -util_format_r8g8b8a8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_to_srgb_8unorm(src[0])) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 16; - value |= (src[3]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8b8g8r8_srgb { - uint32_t value; - struct { - uint8_t a; - uint8_t b; - uint8_t g; - uint8_t r; - } chan; -}; - -static INLINE void -util_format_a8b8g8r8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8b8g8r8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[3])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_float_to_srgb_8unorm(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8b8g8r8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -util_format_a8b8g8r8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t b; - uint32_t g; - uint32_t r; - a = (value) & 0xff; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8b8g8r8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[3]) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_to_srgb_8unorm(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_x8b8g8r8_srgb { - uint32_t value; - struct { - uint8_t x; - uint8_t b; - uint8_t g; - uint8_t r; - } chan; -}; - -static INLINE void -util_format_x8b8g8r8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_x8b8g8r8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_float_to_srgb_8unorm(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_x8b8g8r8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_x8b8g8r8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - r = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_x8b8g8r8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_to_srgb_8unorm(src[0])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b8g8r8a8_srgb { - uint32_t value; - struct { - uint8_t b; - uint8_t g; - uint8_t r; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_b8g8r8a8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b8g8r8a8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff) << 16; - value |= (float_to_ubyte(src[3])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b8g8r8a8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -util_format_b8g8r8a8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b8g8r8a8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_to_srgb_8unorm(src[2])) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[0])) & 0xff) << 16; - value |= (src[3]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b8g8r8x8_srgb { - uint32_t value; - struct { - uint8_t b; - uint8_t g; - uint8_t r; - uint8_t x; - } chan; -}; - -static INLINE void -util_format_b8g8r8x8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b8g8r8x8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b8g8r8x8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b8g8r8x8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0xff; - g = (value >> 8) & 0xff; - r = (value >> 16) & 0xff; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b8g8r8x8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_to_srgb_8unorm(src[2])) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[0])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8r8g8b8_srgb { - uint32_t value; - struct { - uint8_t a; - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -util_format_a8r8g8b8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8r8g8b8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[3])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_float_to_srgb_8unorm(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8r8g8b8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -util_format_a8r8g8b8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - uint32_t r; - uint32_t g; - uint32_t b; - a = (value) & 0xff; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8r8g8b8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[3]) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[0])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_to_srgb_8unorm(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_x8r8g8b8_srgb { - uint32_t value; - struct { - uint8_t x; - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -util_format_x8r8g8b8_srgb_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_x8r8g8b8_srgb_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_float_to_srgb_8unorm(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_x8r8g8b8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_x8r8g8b8_srgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value >> 8) & 0xff; - g = (value >> 16) & 0xff; - b = value >> 24; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_x8r8g8b8_srgb_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((util_format_linear_to_srgb_8unorm(src[0])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 16; - value |= (util_format_linear_to_srgb_8unorm(src[2])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8sg8sb8ux8u_norm { - uint32_t value; - struct { - int8_t r; - int8_t g; - uint8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - uint32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = (value >> 16) & 0xff; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; - value |= ((float_to_ubyte(src[2])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8sg8sb8ux8u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - uint32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = (value >> 16) & 0xff; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - uint32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = (value >> 16) & 0xff; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = b; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(src[0] >> 1)) & 0xff) ; - value |= (uint32_t)((((uint32_t)(src[1] >> 1)) & 0xff) << 8) ; - value |= ((src[2]) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10sg10sb10sa2u_norm { - uint32_t value; - struct { - int r:10; - int g:10; - int b:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_r10sg10sb10sa2u_norm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - uint32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10sg10sb10sa2u_norm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; - value |= ((uint32_t)util_iround(CLAMP(src[3], 0, 1) * 0x3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10sg10sb10sa2u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - uint32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = value >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x3)); /* a */ -} - -static INLINE void -util_format_r10sg10sb10sa2u_norm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - uint32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = value >> 30; - dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */ - dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */ - dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0x3); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10sg10sb10sa2u_norm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) << 20) ; - value |= ((uint32_t)(src[3] >> 6)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r5sg5sb6u_norm { - uint16_t value; - struct { - int r:5; - int g:5; - unsigned b:6; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - uint16_t b; - r = ((int16_t)(value << 11) ) >> 11; - g = ((int16_t)(value << 6) ) >> 11; - b = value >> 10; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0x3f)); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint16_t)util_iround(CLAMP(src[0], -1, 1) * 0xf)) & 0x1f) ; - value |= (uint16_t)((((uint16_t)util_iround(CLAMP(src[1], -1, 1) * 0xf)) & 0x1f) << 5) ; - value |= ((uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0x3f)) << 10; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r5sg5sb6u_norm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - uint16_t b; - r = ((int16_t)(value << 11) ) >> 11; - g = ((int16_t)(value << 6) ) >> 11; - b = value >> 10; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = (float)(g * (1.0f/0xf)); /* g */ - dst[2] = (float)(b * (1.0f/0x3f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - uint16_t b; - r = ((int16_t)(value << 11) ) >> 11; - g = ((int16_t)(value << 6) ) >> 11; - b = value >> 10; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0xf); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0xf); /* g */ - dst[2] = (uint8_t)(((uint32_t)b) * 0xff / 0x3f); /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint16_t)(src[0] >> 4)) & 0x1f) ; - value |= (uint16_t)((((uint16_t)(src[1] >> 4)) & 0x1f) << 5) ; - value |= ((uint16_t)(src[2] >> 2)) << 10; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r64_float { - uint64_t value; - struct { - double r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64_float pixel; - pixel.chan.r = (double)src[0]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64_float pixel; - pixel.chan.r = (double)(src[0] * (1.0f/0xff)); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r64g64_float { - struct { - double r; - double g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64_float pixel; - pixel.chan.r = (double)src[0]; - pixel.chan.g = (double)src[1]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r64g64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r64g64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64_float pixel; - pixel.chan.r = (double)(src[0] * (1.0f/0xff)); - pixel.chan.g = (double)(src[1] * (1.0f/0xff)); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r64g64b64_float { - struct { - double r; - double g; - double b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 24; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64_float pixel; - pixel.chan.r = (double)src[0]; - pixel.chan.g = (double)src[1]; - pixel.chan.b = (double)src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 24; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r64g64b64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r64g64b64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */ - dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */ - dst[3] = 255; /* a */ - src += 24; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64_float pixel; - pixel.chan.r = (double)(src[0] * (1.0f/0xff)); - pixel.chan.g = (double)(src[1] * (1.0f/0xff)); - pixel.chan.b = (double)(src[2] * (1.0f/0xff)); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 24; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r64g64b64a64_float { - struct { - double r; - double g; - double b; - double a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64a64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ - src += 32; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64a64_float pixel; - pixel.chan.r = (double)src[0]; - pixel.chan.g = (double)src[1]; - pixel.chan.b = (double)src[2]; - pixel.chan.a = (double)src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 32; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r64g64b64a64_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r64g64b64a64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64a64_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */ - dst[2] = (uint8_t)util_iround(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */ - dst[3] = (uint8_t)util_iround(CLAMP(pixel.chan.a, 0, 1) * 0xff); /* a */ - src += 32; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r64g64b64a64_float pixel; - pixel.chan.r = (double)(src[0] * (1.0f/0xff)); - pixel.chan.g = (double)(src[1] * (1.0f/0xff)); - pixel.chan.b = (double)(src[2] * (1.0f/0xff)); - pixel.chan.a = (double)(src[3] * (1.0f/0xff)); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 32; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_float { - uint32_t value; - struct { - float r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_float pixel; - pixel.chan.r = src[0]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_float { - uint64_t value; - struct { - float r; - float g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_float pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = float_to_ubyte(pixel.chan.g); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - pixel.chan.g = ubyte_to_float(src[1]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_float { - struct { - float r; - float g; - float b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_float pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = float_to_ubyte(pixel.chan.g); /* g */ - dst[2] = float_to_ubyte(pixel.chan.b); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - pixel.chan.g = ubyte_to_float(src[1]); - pixel.chan.b = ubyte_to_float(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_float { - struct { - float r; - float g; - float b; - float a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_float pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = float_to_ubyte(pixel.chan.g); /* g */ - dst[2] = float_to_ubyte(pixel.chan.b); /* b */ - dst[3] = float_to_ubyte(pixel.chan.a); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - pixel.chan.g = ubyte_to_float(src[1]); - pixel.chan.b = ubyte_to_float(src[2]); - pixel.chan.a = ubyte_to_float(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_unorm { - uint32_t value; - struct { - uint32_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (float)(r * (1.0/0xffffffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (float)(r * (1.0/0xffffffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (uint8_t)(r >> 24); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_unorm { - uint64_t value; - struct { - uint32_t r; - uint32_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_unorm pixel; - pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff); - pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_unorm pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_unorm { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_unorm pixel; - pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff); - pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff); - pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */ - dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_unorm pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff); - pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_unorm { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_unorm pixel; - pixel.chan.r = (uint32_t)(CLAMP(src[0], 0, 1) * (double)0xffffffff); - pixel.chan.g = (uint32_t)(CLAMP(src[1], 0, 1) * (double)0xffffffff); - pixel.chan.b = (uint32_t)(CLAMP(src[2], 0, 1) * (double)0xffffffff); - pixel.chan.a = (uint32_t)(CLAMP(src[3], 0, 1) * (double)0xffffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0xffffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0xffffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0xffffffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0xffffffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 24); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 24); /* g */ - dst[2] = (uint8_t)(pixel.chan.b >> 24); /* b */ - dst[3] = (uint8_t)(pixel.chan.a >> 24); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_unorm pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0xffffffff / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0xffffffff / 0xff); - pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0xffffffff / 0xff); - pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0xffffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_uscaled { - uint32_t value; - struct { - uint32_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)CLAMP(src[0], 0, 4294967295); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (uint8_t)(((uint64_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_uscaled { - uint64_t value; - struct { - uint32_t r; - uint32_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uscaled pixel; - pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295); - pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uscaled pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_uscaled { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uscaled pixel; - pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295); - pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295); - pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uscaled pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_uscaled { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uscaled pixel; - pixel.chan.r = (uint32_t)CLAMP(src[0], 0, 4294967295); - pixel.chan.g = (uint32_t)CLAMP(src[1], 0, 4294967295); - pixel.chan.b = (uint32_t)CLAMP(src[2], 0, 4294967295); - pixel.chan.a = (uint32_t)CLAMP(src[3], 0, 4294967295); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint64_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint64_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uscaled pixel; - pixel.chan.r = (uint32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (uint32_t)(((uint64_t)src[2]) * 0x1 / 0xff); - pixel.chan.a = (uint32_t)(((uint64_t)src[3]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_snorm { - uint32_t value; - struct { - int32_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (float)(r * (1.0/0x7fffffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (uint8_t)(MAX2(r, 0) >> 23); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_snorm { - uint64_t value; - struct { - int32_t r; - int32_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_snorm pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff); - pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_snorm pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_snorm { - struct { - int32_t r; - int32_t g; - int32_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_snorm pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff); - pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff); - pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */ - dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_snorm pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff); - pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_snorm { - struct { - int32_t r; - int32_t g; - int32_t b; - int32_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_snorm pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -1, 1) * (double)0x7fffffff); - pixel.chan.g = (int32_t)(CLAMP(src[1], -1, 1) * (double)0x7fffffff); - pixel.chan.b = (int32_t)(CLAMP(src[2], -1, 1) * (double)0x7fffffff); - pixel.chan.a = (int32_t)(CLAMP(src[3], -1, 1) * (double)0x7fffffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x7fffffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x7fffffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x7fffffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0x7fffffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 23); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 23); /* g */ - dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 23); /* b */ - dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 23); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_snorm pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x7fffffff / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x7fffffff / 0xff); - pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x7fffffff / 0xff); - pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x7fffffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_sscaled { - uint32_t value; - struct { - int32_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)CLAMP(src[0], -2147483648, 2147483647)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (uint8_t)(((uint64_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)(((uint64_t)src[0]) * 0x1 / 0xff)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_sscaled { - uint64_t value; - struct { - int32_t r; - int32_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sscaled pixel; - pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647); - pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sscaled pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_sscaled { - struct { - int32_t r; - int32_t g; - int32_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sscaled pixel; - pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647); - pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647); - pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sscaled pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_sscaled { - struct { - int32_t r; - int32_t g; - int32_t b; - int32_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sscaled pixel; - pixel.chan.r = (int32_t)CLAMP(src[0], -2147483648, 2147483647); - pixel.chan.g = (int32_t)CLAMP(src[1], -2147483648, 2147483647); - pixel.chan.b = (int32_t)CLAMP(src[2], -2147483648, 2147483647); - pixel.chan.a = (int32_t)CLAMP(src[3], -2147483648, 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint64_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sscaled pixel; - pixel.chan.r = (int32_t)(((uint64_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int32_t)(((uint64_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (int32_t)(((uint64_t)src[2]) * 0x1 / 0xff); - pixel.chan.a = (int32_t)(((uint64_t)src[3]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_float { - uint16_t value; - struct { - uint16_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_float { - uint32_t value; - struct { - uint16_t r; - uint16_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - pixel.chan.g = util_float_to_half(src[1]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_float { - struct { - uint16_t r; - uint16_t g; - uint16_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - pixel.chan.g = util_float_to_half(src[1]); - pixel.chan.b = util_float_to_half(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */ - dst[3] = 255; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff))); - pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_float { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - pixel.chan.g = util_float_to_half(src[1]); - pixel.chan.b = util_float_to_half(src[2]); - pixel.chan.a = util_float_to_half(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */ - dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff))); - pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff))); - pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_unorm { - uint16_t value; - struct { - uint16_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (uint8_t)(r >> 8); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_unorm { - uint32_t value; - struct { - uint16_t r; - uint16_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(g * (1.0f/0xffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff; - value |= ((uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(g * (1.0f/0xffff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (uint8_t)(r >> 8); /* r */ - dst[1] = (uint8_t)(g >> 8); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff; - value |= ((uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_unorm { - struct { - uint16_t r; - uint16_t g; - uint16_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_unorm pixel; - pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff); - pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */ - dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */ - dst[3] = 255; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_unorm pixel; - pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff); - pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_unorm { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_unorm pixel; - pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff); - pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff); - pixel.chan.a = (uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0f/0xffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */ - dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */ - dst[3] = (uint8_t)(pixel.chan.a >> 8); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_unorm pixel; - pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff); - pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff); - pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_uscaled { - uint16_t value; - struct { - uint16_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)CLAMP(src[0], 0, 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_uscaled { - uint32_t value; - struct { - uint16_t r; - uint16_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff; - value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff; - value |= ((uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_uscaled { - struct { - uint16_t r; - uint16_t g; - uint16_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uscaled pixel; - pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535); - pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535); - pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uscaled pixel; - pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_uscaled { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uscaled pixel; - pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535); - pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535); - pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535); - pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MIN2(pixel.chan.a, 1)) * 0xff / 0x1); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uscaled pixel; - pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0x1 / 0xff); - pixel.chan.a = (uint16_t)(((uint32_t)src[3]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_snorm { - uint16_t value; - struct { - int16_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_snorm { - uint32_t value; - struct { - int16_t r; - int16_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(g * (1.0f/0x7fff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(g * (1.0f/0x7fff)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(g, 0) >> 7); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_snorm { - struct { - int16_t r; - int16_t g; - int16_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_snorm pixel; - pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff); - pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff); - pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */ - dst[3] = 255; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_snorm pixel; - pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff); - pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff); - pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_snorm { - uint64_t value; - struct { - int16_t r; - int16_t g; - int16_t b; - int16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_snorm pixel; - pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff); - pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff); - pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff); - pixel.chan.a = (int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0f/0x7fff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */ - dst[3] = (uint8_t)(MAX2(pixel.chan.a, 0) >> 7); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_snorm pixel; - pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff); - pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff); - pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff); - pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_sscaled { - uint16_t value; - struct { - int16_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_sscaled { - uint32_t value; - struct { - int16_t r; - int16_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_sscaled { - struct { - int16_t r; - int16_t g; - int16_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sscaled pixel; - pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767); - pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767); - pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sscaled pixel; - pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_sscaled { - uint64_t value; - struct { - int16_t r; - int16_t g; - int16_t b; - int16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sscaled pixel; - pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767); - pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767); - pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767); - pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = (float)pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.a, 0, 1)) * 0xff / 0x1); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sscaled pixel; - pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x1 / 0xff); - pixel.chan.a = (int16_t)(((uint32_t)src[3]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_unorm { - uint8_t value; - struct { - uint8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= float_to_ubyte(src[0]); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= src[0]; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_unorm { - uint16_t value; - struct { - uint8_t r; - uint8_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (float_to_ubyte(src[0])) & 0xff; - value |= (float_to_ubyte(src[1])) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (src[0]) & 0xff; - value |= (src[1]) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_unorm { - struct { - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = ubyte_to_float(pixel.chan.r); /* r */ - dst[1] = ubyte_to_float(pixel.chan.g); /* g */ - dst[2] = ubyte_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_unorm pixel; - pixel.chan.r = float_to_ubyte(src[0]); - pixel.chan.g = float_to_ubyte(src[1]); - pixel.chan.b = float_to_ubyte(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = ubyte_to_float(pixel.chan.r); /* r */ - dst[1] = ubyte_to_float(pixel.chan.g); /* g */ - dst[2] = ubyte_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 255; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_unorm pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_unorm { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (float_to_ubyte(src[0])) & 0xff; - value |= ((float_to_ubyte(src[1])) & 0xff) << 8; - value |= ((float_to_ubyte(src[2])) & 0xff) << 16; - value |= (float_to_ubyte(src[3])) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = ubyte_to_float(g); /* g */ - dst[2] = ubyte_to_float(b); /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = r; /* r */ - dst[1] = g; /* g */ - dst[2] = b; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (src[0]) & 0xff; - value |= ((src[1]) & 0xff) << 8; - value |= ((src[2]) & 0xff) << 16; - value |= (src[3]) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_uscaled { - uint8_t value; - struct { - uint8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[0], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_uscaled { - uint16_t value; - struct { - uint8_t r; - uint8_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff; - value |= ((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_uscaled { - struct { - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uscaled pixel; - pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255); - pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255); - pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)MIN2(pixel.chan.r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(pixel.chan.g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(pixel.chan.b, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uscaled pixel; - pixel.chan.r = (uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_uscaled { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8; - value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16; - value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MIN2(a, 1)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff; - value |= (((uint8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8; - value |= (((uint8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16; - value |= ((uint8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_snorm { - uint8_t value; - struct { - int8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)(src[0] >> 1)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_snorm { - uint16_t value; - struct { - int8_t r; - int8_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ; - value |= (uint16_t)(((int8_t)(src[1] >> 1)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_snorm { - struct { - int8_t r; - int8_t g; - int8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_snorm pixel; - pixel.chan.r = (int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f); - pixel.chan.g = (int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f); - pixel.chan.b = (int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)MAX2(pixel.chan.r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(pixel.chan.g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(pixel.chan.b, 0)) * 0xff / 0x7f); /* b */ - dst[3] = 255; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_snorm pixel; - pixel.chan.r = (int8_t)(src[0] >> 1); - pixel.chan.g = (int8_t)(src[1] >> 1); - pixel.chan.b = (int8_t)(src[2] >> 1); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_snorm { - uint32_t value; - struct { - int8_t r; - int8_t g; - int8_t b; - int8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(b * (1.0f/0x7f)); /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(b * (1.0f/0x7f)); /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ; - value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)(src[3] >> 1)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_sscaled { - uint8_t value; - struct { - int8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (float)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_sscaled { - uint16_t value; - struct { - int8_t r; - int8_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ; - value |= (uint16_t)(((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_sscaled { - struct { - int8_t r; - int8_t g; - int8_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sscaled pixel; - pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127); - pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127); - pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)pixel.chan.r; /* r */ - dst[1] = (float)pixel.chan.g; /* g */ - dst[2] = (float)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sscaled pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(pixel.chan.b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sscaled pixel; - pixel.chan.r = (int8_t)(((uint32_t)src[0]) * 0x1 / 0xff); - pixel.chan.g = (int8_t)(((uint32_t)src[1]) * 0x1 / 0xff); - pixel.chan.b = (int8_t)(((uint32_t)src[2]) * 0x1 / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_sscaled { - uint32_t value; - struct { - int8_t r; - int8_t g; - int8_t b; - int8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)CLAMP(a, 0, 1)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0xff) ; - value |= (uint32_t)((((int8_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_fixed { - uint32_t value; - struct { - int32_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_fixed pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32_fixed pixel; - pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_fixed { - uint64_t value; - struct { - int32_t r; - int32_t g; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_fixed pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000); - pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */ - dst[2] = 0; /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_fixed pixel; - pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_fixed { - struct { - int32_t r; - int32_t g; - int32_t b; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_fixed pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000); - pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000); - pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */ - dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */ - dst[3] = 255; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_fixed pixel; - pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_fixed { - struct { - int32_t r; - int32_t g; - int32_t b; - int32_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_fixed pixel; - pixel.chan.r = (int32_t)(CLAMP(src[0], -65536, 65535) * (double)0x10000); - pixel.chan.g = (int32_t)(CLAMP(src[1], -65536, 65535) * (double)0x10000); - pixel.chan.b = (int32_t)(CLAMP(src[2], -65536, 65535) * (double)0x10000); - pixel.chan.a = (int32_t)(CLAMP(src[3], -65536, 65535) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_fixed_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0/0x10000)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0/0x10000)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0/0x10000)); /* b */ - dst[3] = (float)(pixel.chan.a * (1.0/0x10000)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_fixed pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)util_iround((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ - dst[1] = (uint8_t)util_iround((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */ - dst[2] = (uint8_t)util_iround((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */ - dst[3] = (uint8_t)util_iround((CLAMP(pixel.chan.a, 0, 65536) * (1.0/0x10000)) * 0xff); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_fixed pixel; - pixel.chan.r = (int32_t)((float)(src[0] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.g = (int32_t)((float)(src[1] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.b = (int32_t)((float)(src[2] * (1.0f/0xff)) * (double)0x10000); - pixel.chan.a = (int32_t)((float)(src[3] * (1.0f/0xff)) * (double)0x10000); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10x2_uscaled { - uint32_t value; - struct { - unsigned r:10; - unsigned g:10; - unsigned b:10; - unsigned x:2; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff; - value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10; - value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10x2_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) << 20; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10x2_snorm { - uint32_t value; - struct { - int r:10; - int g:10; - int b:10; - unsigned x:2; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10x2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */ - dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */ - dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) << 20) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r4a4_unorm { - uint8_t value; - struct { - unsigned a:4; - unsigned r:4; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - uint8_t r; - a = (value) & 0xf; - r = value >> 4; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) & 0xf; - value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r4a4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t a; - uint8_t r; - a = (value) & 0xf; - r = value >> 4; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - uint8_t r; - a = (value) & 0xf; - r = value >> 4; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)(src[3] >> 4)) & 0xf; - value |= ((uint8_t)(src[0] >> 4)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a4r4_unorm { - uint8_t value; - struct { - unsigned r:4; - unsigned a:4; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - uint8_t a; - r = (value) & 0xf; - a = value >> 4; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)util_iround(CLAMP(src[0], 0, 1) * 0xf)) & 0xf; - value |= ((uint8_t)util_iround(CLAMP(src[3], 0, 1) * 0xf)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a4r4_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t r; - uint8_t a; - r = (value) & 0xf; - a = value >> 4; - dst[0] = (float)(r * (1.0f/0xf)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xf)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - uint8_t a; - r = (value) & 0xf; - a = value >> 4; - dst[0] = (uint8_t)(((uint32_t)r) * 0xff / 0xf); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(((uint32_t)a) * 0xff / 0xf); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= ((uint8_t)(src[0] >> 4)) & 0xf; - value |= ((uint8_t)(src[3] >> 4)) << 4; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8a8_unorm { - uint16_t value; - struct { - uint8_t r; - uint8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (float_to_ubyte(src[0])) & 0xff; - value |= (float_to_ubyte(src[3])) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8a8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (src[0]) & 0xff; - value |= (src[3]) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8r8_unorm { - uint16_t value; - struct { - uint8_t a; - uint8_t r; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - uint16_t r; - a = (value) & 0xff; - r = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (float_to_ubyte(src[3])) & 0xff; - value |= (float_to_ubyte(src[0])) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t a; - uint16_t r; - a = (value) & 0xff; - r = value >> 8; - dst[0] = ubyte_to_float(r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = ubyte_to_float(a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - uint16_t r; - a = (value) & 0xff; - r = value >> 8; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (src[3]) & 0xff; - value |= (src[0]) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10a2_uscaled { - uint32_t value; - struct { - unsigned r:10; - unsigned g:10; - unsigned b:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_r10g10b10a2_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff; - value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10; - value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20; - value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -util_format_r10g10b10a2_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MIN2(a, 1)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) << 20; - value |= ((uint32_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10a2_sscaled { - uint32_t value; - struct { - int r:10; - int g:10; - int b:10; - int a:2; - } chan; -}; - -static INLINE void -util_format_r10g10b10a2_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10a2_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -util_format_r10g10b10a2_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10a2_snorm { - uint32_t value; - struct { - int r:10; - int g:10; - int b:10; - int a:2; - } chan; -}; - -static INLINE void -util_format_r10g10b10a2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[3], -1, 1) * 0x1)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10a2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ -} - -static INLINE void -util_format_r10g10b10a2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - b = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */ - dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */ - dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)(src[3] >> 7)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10a2_uscaled { - uint32_t value; - struct { - unsigned b:10; - unsigned g:10; - unsigned r:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10a2_uscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff; - value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10; - value |= (((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff) << 20; - value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -util_format_b10g10r10a2_uscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (uint8_t)(((uint32_t)MIN2(r, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)MIN2(g, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)MIN2(b, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MIN2(a, 1)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff) << 20; - value |= ((uint32_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10a2_sscaled { - uint32_t value; - struct { - int b:10; - int g:10; - int r:10; - int a:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10a2_sscaled_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_sscaled_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)CLAMP(src[2], -512, 511)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)CLAMP(src[1], -512, 511)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)CLAMP(src[0], -512, 511)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)CLAMP(src[3], -2, 1)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10a2_sscaled_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)r; /* r */ - dst[1] = (float)g; /* g */ - dst[2] = (float)b; /* b */ - dst[3] = (float)a; /* a */ -} - -static INLINE void -util_format_b10g10r10a2_sscaled_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (uint8_t)(((uint32_t)CLAMP(r, 0, 1)) * 0xff / 0x1); /* r */ - dst[1] = (uint8_t)(((uint32_t)CLAMP(g, 0, 1)) * 0xff / 0x1); /* g */ - dst[2] = (uint8_t)(((uint32_t)CLAMP(b, 0, 1)) * 0xff / 0x1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_sscaled_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[2]) * 0x1 / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1 / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[0]) * 0x1 / 0xff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[3]) * 0x1 / 0xff)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10a2_snorm { - uint32_t value; - struct { - int b:10; - int g:10; - int r:10; - int a:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10a2_snorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_snorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)util_iround(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)util_iround(CLAMP(src[3], -1, 1) * 0x1)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10a2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (float)(r * (1.0f/0x1ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x1ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x1ff)); /* b */ - dst[3] = (float)(a * (1.0f/0x1)); /* a */ -} - -static INLINE void -util_format_b10g10r10a2_snorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t b; - int32_t g; - int32_t r; - int32_t a; - b = ((int32_t)(value << 22) ) >> 22; - g = ((int32_t)(value << 12) ) >> 22; - r = ((int32_t)(value << 2) ) >> 22; - a = ((int32_t)(value) ) >> 30; - dst[0] = (uint8_t)(MAX2(r, 0) >> 1); /* r */ - dst[1] = (uint8_t)(MAX2(g, 0) >> 1); /* g */ - dst[2] = (uint8_t)(MAX2(b, 0) >> 1); /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x1); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_snorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((uint32_t)(((uint32_t)src[2]) * 0x1ff / 0xff)) & 0x3ff) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[1]) * 0x1ff / 0xff)) & 0x3ff) << 10) ; - value |= (uint32_t)((((uint32_t)(((uint32_t)src[0]) * 0x1ff / 0xff)) & 0x3ff) << 20) ; - value |= (uint32_t)(((uint32_t)(src[3] >> 7)) << 30) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_uint { - uint8_t value; - struct { - uint8_t r; - } chan; -}; - -static INLINE void -util_format_r8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)MIN2(src[0], 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t r; - r = value; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[0], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_uint { - uint16_t value; - struct { - uint8_t r; - uint8_t g; - } chan; -}; - -static INLINE void -util_format_r8g8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)MIN2(src[0], 255)) & 0xff; - value |= ((uint8_t)MIN2(src[1], 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t g; - r = (value) & 0xff; - g = value >> 8; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= ((uint8_t)CLAMP(src[1], 0, 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_uint { - struct { - uint8_t r; - uint8_t g; - uint8_t b; - } chan; -}; - -static INLINE void -util_format_r8g8b8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uint pixel; - pixel.chan.r = (uint8_t)MIN2(src[0], 255); - pixel.chan.g = (uint8_t)MIN2(src[1], 255); - pixel.chan.b = (uint8_t)MIN2(src[2], 255); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8b8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_uint pixel; - pixel.chan.r = (uint8_t)CLAMP(src[0], 0, 255); - pixel.chan.g = (uint8_t)CLAMP(src[1], 0, 255); - pixel.chan.b = (uint8_t)CLAMP(src[2], 0, 255); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_uint { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_r8g8b8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)MIN2(src[0], 255)) & 0xff; - value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8; - value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16; - value |= ((uint8_t)MIN2(src[3], 255)) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_r8g8b8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - a = value >> 24; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8; - value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16; - value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 24; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8_sint { - uint8_t value; - struct { - int8_t r; - } chan; -}; - -static INLINE void -util_format_r8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t r; - r = (int8_t)(value) ; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8_sint { - uint16_t value; - struct { - int8_t r; - int8_t g; - } chan; -}; - -static INLINE void -util_format_r8g8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)CLAMP(src[1], -128, 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t g; - r = ((int16_t)(value << 8) ) >> 8; - g = ((int16_t)(value) ) >> 8; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = (unsigned)MAX2(g, 0); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)MIN2(src[1], 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8_sint { - struct { - int8_t r; - int8_t g; - int8_t b; - } chan; -}; - -static INLINE void -util_format_r8g8b8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sint pixel; - pixel.chan.r = (int8_t)CLAMP(src[0], -128, 127); - pixel.chan.g = (int8_t)CLAMP(src[1], -128, 127); - pixel.chan.b = (int8_t)CLAMP(src[2], -128, 127); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r8g8b8_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8b8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = 1; /* a */ - src += 3; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r8g8b8_sint pixel; - pixel.chan.r = (int8_t)MIN2(src[0], 127); - pixel.chan.g = (int8_t)MIN2(src[1], 127); - pixel.chan.b = (int8_t)MIN2(src[2], 127); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 3; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8a8_sint { - uint32_t value; - struct { - int8_t r; - int8_t g; - int8_t b; - int8_t a; - } chan; -}; - -static INLINE void -util_format_r8g8b8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)CLAMP(src[3], -128, 127)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_r8g8b8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - int32_t a; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - a = ((int32_t)(value) ) >> 24; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = (unsigned)MAX2(g, 0); /* g */ - dst[2] = (unsigned)MAX2(b, 0); /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ; - value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ; - value |= (uint32_t)(((int8_t)MIN2(src[3], 127)) << 24) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_uint { - uint16_t value; - struct { - uint16_t r; - } chan; -}; - -static INLINE void -util_format_r16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)MIN2(src[0], 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - r = value; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)CLAMP(src[0], 0, 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_uint { - uint32_t value; - struct { - uint16_t r; - uint16_t g; - } chan; -}; - -static INLINE void -util_format_r16g16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff; - value |= ((uint16_t)MIN2(src[1], 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - r = (value) & 0xffff; - g = value >> 16; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff; - value |= ((uint16_t)CLAMP(src[1], 0, 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_uint { - struct { - uint16_t r; - uint16_t g; - uint16_t b; - } chan; -}; - -static INLINE void -util_format_r16g16b16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uint pixel; - pixel.chan.r = (uint16_t)MIN2(src[0], 65535); - pixel.chan.g = (uint16_t)MIN2(src[1], 65535); - pixel.chan.b = (uint16_t)MIN2(src[2], 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16b16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_uint pixel; - pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535); - pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535); - pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_uint { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t a; - } chan; -}; - -static INLINE void -util_format_r16g16b16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = (unsigned)pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uint pixel; - pixel.chan.r = (uint16_t)MIN2(src[0], 65535); - pixel.chan.g = (uint16_t)MIN2(src[1], 65535); - pixel.chan.b = (uint16_t)MIN2(src[2], 65535); - pixel.chan.a = (uint16_t)MIN2(src[3], 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = (unsigned)pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r16g16b16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = (int)pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_uint pixel; - pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535); - pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535); - pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535); - pixel.chan.a = (uint16_t)CLAMP(src[3], 0, 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16_sint { - uint16_t value; - struct { - int16_t r; - } chan; -}; - -static INLINE void -util_format_r16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - r = (int16_t)(value) ; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16_sint { - uint32_t value; - struct { - int16_t r; - int16_t g; - } chan; -}; - -static INLINE void -util_format_r16g16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)CLAMP(src[1], -32768, 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - r = ((int32_t)(value << 16) ) >> 16; - g = ((int32_t)(value) ) >> 16; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = (unsigned)MAX2(g, 0); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)MIN2(src[1], 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16_sint { - struct { - int16_t r; - int16_t g; - int16_t b; - } chan; -}; - -static INLINE void -util_format_r16g16b16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sint pixel; - pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767); - pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767); - pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16b16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = 1; /* a */ - src += 6; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16_sint pixel; - pixel.chan.r = (int16_t)MIN2(src[0], 32767); - pixel.chan.g = (int16_t)MIN2(src[1], 32767); - pixel.chan.b = (int16_t)MIN2(src[2], 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 6; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16a16_sint { - uint64_t value; - struct { - int16_t r; - int16_t g; - int16_t b; - int16_t a; - } chan; -}; - -static INLINE void -util_format_r16g16b16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = (int)pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sint pixel; - pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767); - pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767); - pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767); - pixel.chan.a = (int16_t)CLAMP(src[3], -32768, 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16a16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = (int)pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r16g16b16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16a16_sint pixel; - pixel.chan.r = (int16_t)MIN2(src[0], 32767); - pixel.chan.g = (int16_t)MIN2(src[1], 32767); - pixel.chan.b = (int16_t)MIN2(src[2], 32767); - pixel.chan.a = (int16_t)MIN2(src[3], 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_uint { - uint32_t value; - struct { - uint32_t r; - } chan; -}; - -static INLINE void -util_format_r32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= src[0]; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - r = value; - dst[0] = (int)MIN2(r, 2147483647); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)MAX2(src[0], 0); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_uint { - uint64_t value; - struct { - uint32_t r; - uint32_t g; - } chan; -}; - -static INLINE void -util_format_r32g32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */ - dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_uint pixel; - pixel.chan.r = (uint32_t)MAX2(src[0], 0); - pixel.chan.g = (uint32_t)MAX2(src[1], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_uint { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - } chan; -}; - -static INLINE void -util_format_r32g32b32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32b32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */ - dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */ - dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_uint pixel; - pixel.chan.r = (uint32_t)MAX2(src[0], 0); - pixel.chan.g = (uint32_t)MAX2(src[1], 0); - pixel.chan.b = (uint32_t)MAX2(src[2], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_uint { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - } chan; -}; - -static INLINE void -util_format_r32g32b32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r32g32b32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */ - dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */ - dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */ - dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_uint pixel; - pixel.chan.r = (uint32_t)MAX2(src[0], 0); - pixel.chan.g = (uint32_t)MAX2(src[1], 0); - pixel.chan.b = (uint32_t)MAX2(src[2], 0); - pixel.chan.a = (uint32_t)MAX2(src[3], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32_sint { - uint32_t value; - struct { - int32_t r; - } chan; -}; - -static INLINE void -util_format_r32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(src[0]) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - r = (int32_t)(value) ; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32_sint { - uint64_t value; - struct { - int32_t r; - int32_t g; - } chan; -}; - -static INLINE void -util_format_r32g32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = 0; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32_sint pixel; - pixel.chan.r = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.g = (int32_t)MIN2(src[1], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32_sint { - struct { - int32_t r; - int32_t g; - int32_t b; - } chan; -}; - -static INLINE void -util_format_r32g32b32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32b32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = 1; /* a */ - src += 12; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32_sint pixel; - pixel.chan.r = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.g = (int32_t)MIN2(src[1], 2147483647); - pixel.chan.b = (int32_t)MIN2(src[2], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 12; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32a32_sint { - struct { - int32_t r; - int32_t g; - int32_t b; - int32_t a; - } chan; -}; - -static INLINE void -util_format_r32g32b32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r32g32b32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32a32_sint pixel; - pixel.chan.r = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.g = (int32_t)MIN2(src[1], 2147483647); - pixel.chan.b = (int32_t)MIN2(src[2], 2147483647); - pixel.chan.a = (int32_t)MIN2(src[3], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8_uint { - uint8_t value; - struct { - uint8_t a; - } chan; -}; - -static INLINE void -util_format_a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)MIN2(src[3], 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[3], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i8_uint { - uint8_t value; - struct { - uint8_t rgba; - } chan; -}; - -static INLINE void -util_format_i8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = (unsigned)rgba; /* r */ - dst[1] = (unsigned)rgba; /* g */ - dst[2] = (unsigned)rgba; /* b */ - dst[3] = (unsigned)rgba; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)MIN2(src[0], 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = (unsigned)rgba; /* r */ - dst[1] = (unsigned)rgba; /* g */ - dst[2] = (unsigned)rgba; /* b */ - dst[3] = (unsigned)rgba; /* a */ -} - -static INLINE void -util_format_i8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgba; - rgba = value; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[0], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8_uint { - uint8_t value; - struct { - uint8_t rgb; - } chan; -}; - -static INLINE void -util_format_l8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)MIN2(src[0], 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - uint8_t rgb; - rgb = value; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)CLAMP(src[0], 0, 255); - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8a8_uint { - uint16_t value; - struct { - uint8_t rgb; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_l8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)MIN2(src[0], 255)) & 0xff; - value |= ((uint8_t)MIN2(src[3], 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_l8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - uint16_t a; - rgb = (value) & 0xff; - a = value >> 8; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a8_sint { - uint8_t value; - struct { - int8_t a; - } chan; -}; - -static INLINE void -util_format_a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)CLAMP(src[3], -128, 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t a; - a = (int8_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)MIN2(src[3], 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i8_sint { - uint8_t value; - struct { - int8_t rgba; - } chan; -}; - -static INLINE void -util_format_i8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ -} - -static INLINE void -util_format_i8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgba; - rgba = (int8_t)(value) ; - dst[0] = (unsigned)MAX2(rgba, 0); /* r */ - dst[1] = (unsigned)MAX2(rgba, 0); /* g */ - dst[2] = (unsigned)MAX2(rgba, 0); /* b */ - dst[3] = (unsigned)MAX2(rgba, 0); /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8_sint { - uint8_t value; - struct { - int8_t rgb; - } chan; -}; - -static INLINE void -util_format_l8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)CLAMP(src[0], -128, 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint8_t value = *(const uint8_t *)src; - int8_t rgb; - rgb = (int8_t)(value) ; - dst[0] = (unsigned)MAX2(rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(rgb, 0); /* b */ - dst[3] = 1; /* a */ - src += 1; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint8_t value = 0; - value |= (uint8_t)((int8_t)MIN2(src[0], 127)) ; - *(uint8_t *)dst = value; - src += 4; - dst += 1; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l8a8_sint { - uint16_t value; - struct { - int8_t rgb; - int8_t a; - } chan; -}; - -static INLINE void -util_format_l8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_l8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - int16_t a; - rgb = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (unsigned)MAX2(rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(rgb, 0); /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a16_uint { - uint16_t value; - struct { - uint16_t a; - } chan; -}; - -static INLINE void -util_format_a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)MIN2(src[3], 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)CLAMP(src[3], 0, 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i16_uint { - uint16_t value; - struct { - uint16_t rgba; - } chan; -}; - -static INLINE void -util_format_i16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (unsigned)rgba; /* r */ - dst[1] = (unsigned)rgba; /* g */ - dst[2] = (unsigned)rgba; /* b */ - dst[3] = (unsigned)rgba; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)MIN2(src[0], 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (unsigned)rgba; /* r */ - dst[1] = (unsigned)rgba; /* g */ - dst[2] = (unsigned)rgba; /* b */ - dst[3] = (unsigned)rgba; /* a */ -} - -static INLINE void -util_format_i16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgba; - rgba = value; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)CLAMP(src[0], 0, 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16_uint { - uint16_t value; - struct { - uint16_t rgb; - } chan; -}; - -static INLINE void -util_format_l16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)MIN2(src[0], 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t rgb; - rgb = value; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)CLAMP(src[0], 0, 65535); - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16a16_uint { - uint32_t value; - struct { - uint16_t rgb; - uint16_t a; - } chan; -}; - -static INLINE void -util_format_l16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff; - value |= ((uint16_t)MIN2(src[3], 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (unsigned)rgb; /* r */ - dst[1] = (unsigned)rgb; /* g */ - dst[2] = (unsigned)rgb; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_l16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - uint32_t a; - rgb = (value) & 0xffff; - a = value >> 16; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff; - value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a16_sint { - uint16_t value; - struct { - int16_t a; - } chan; -}; - -static INLINE void -util_format_a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)CLAMP(src[3], -32768, 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t a; - a = (int16_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)MIN2(src[3], 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i16_sint { - uint16_t value; - struct { - int16_t rgba; - } chan; -}; - -static INLINE void -util_format_i16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (int)rgba; /* r */ - dst[1] = (int)rgba; /* g */ - dst[2] = (int)rgba; /* b */ - dst[3] = (int)rgba; /* a */ -} - -static INLINE void -util_format_i16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgba; - rgba = (int16_t)(value) ; - dst[0] = (unsigned)MAX2(rgba, 0); /* r */ - dst[1] = (unsigned)MAX2(rgba, 0); /* g */ - dst[2] = (unsigned)MAX2(rgba, 0); /* b */ - dst[3] = (unsigned)MAX2(rgba, 0); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16_sint { - uint16_t value; - struct { - int16_t rgb; - } chan; -}; - -static INLINE void -util_format_l16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)CLAMP(src[0], -32768, 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t rgb; - rgb = (int16_t)(value) ; - dst[0] = (unsigned)MAX2(rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(rgb, 0); /* b */ - dst[3] = 1; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)((int16_t)MIN2(src[0], 32767)) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l16a16_sint { - uint32_t value; - struct { - int16_t rgb; - int16_t a; - } chan; -}; - -static INLINE void -util_format_l16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (int)rgb; /* r */ - dst[1] = (int)rgb; /* g */ - dst[2] = (int)rgb; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_l16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - int32_t a; - rgb = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (unsigned)MAX2(rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(rgb, 0); /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a32_uint { - uint32_t value; - struct { - uint32_t a; - } chan; -}; - -static INLINE void -util_format_a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= src[3]; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ -} - -static INLINE void -util_format_a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t a; - a = value; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)MIN2(a, 2147483647); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)MAX2(src[3], 0); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i32_uint { - uint32_t value; - struct { - uint32_t rgba; - } chan; -}; - -static INLINE void -util_format_i32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgba; - rgba = value; - dst[0] = rgba; /* r */ - dst[1] = rgba; /* g */ - dst[2] = rgba; /* b */ - dst[3] = rgba; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= src[0]; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t rgba; - rgba = value; - dst[0] = rgba; /* r */ - dst[1] = rgba; /* g */ - dst[2] = rgba; /* b */ - dst[3] = rgba; /* a */ -} - -static INLINE void -util_format_i32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgba; - rgba = value; - dst[0] = (int)MIN2(rgba, 2147483647); /* r */ - dst[1] = (int)MIN2(rgba, 2147483647); /* g */ - dst[2] = (int)MIN2(rgba, 2147483647); /* b */ - dst[3] = (int)MIN2(rgba, 2147483647); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)MAX2(src[0], 0); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32_uint { - uint32_t value; - struct { - uint32_t rgb; - } chan; -}; - -static INLINE void -util_format_l32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - rgb = value; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= src[0]; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - rgb = value; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t rgb; - rgb = value; - dst[0] = (int)MIN2(rgb, 2147483647); /* r */ - dst[1] = (int)MIN2(rgb, 2147483647); /* g */ - dst[2] = (int)MIN2(rgb, 2147483647); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)MAX2(src[0], 0); - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32a32_uint { - uint64_t value; - struct { - uint32_t rgb; - uint32_t a; - } chan; -}; - -static INLINE void -util_format_l32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_uint pixel; - pixel.chan.rgb = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_l32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.rgb, 2147483647); /* r */ - dst[1] = (int)MIN2(pixel.chan.rgb, 2147483647); /* g */ - dst[2] = (int)MIN2(pixel.chan.rgb, 2147483647); /* b */ - dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_uint pixel; - pixel.chan.rgb = (uint32_t)MAX2(src[0], 0); - pixel.chan.a = (uint32_t)MAX2(src[3], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_a32_sint { - uint32_t value; - struct { - int32_t a; - } chan; -}; - -static INLINE void -util_format_a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t a; - a = (int32_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(src[3]) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t a; - a = (int32_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = a; /* a */ -} - -static INLINE void -util_format_a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t a; - a = (int32_t)(value) ; - dst[0] = 0; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)MIN2(src[3], 2147483647)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_i32_sint { - uint32_t value; - struct { - int32_t rgba; - } chan; -}; - -static INLINE void -util_format_i32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgba; - rgba = (int32_t)(value) ; - dst[0] = rgba; /* r */ - dst[1] = rgba; /* g */ - dst[2] = rgba; /* b */ - dst[3] = rgba; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(src[0]) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_i32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t rgba; - rgba = (int32_t)(value) ; - dst[0] = rgba; /* r */ - dst[1] = rgba; /* g */ - dst[2] = rgba; /* b */ - dst[3] = rgba; /* a */ -} - -static INLINE void -util_format_i32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgba; - rgba = (int32_t)(value) ; - dst[0] = (unsigned)MAX2(rgba, 0); /* r */ - dst[1] = (unsigned)MAX2(rgba, 0); /* g */ - dst[2] = (unsigned)MAX2(rgba, 0); /* b */ - dst[3] = (unsigned)MAX2(rgba, 0); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_i32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32_sint { - uint32_t value; - struct { - int32_t rgb; - } chan; -}; - -static INLINE void -util_format_l32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - rgb = (int32_t)(value) ; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(src[0]) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - rgb = (int32_t)(value) ; - dst[0] = rgb; /* r */ - dst[1] = rgb; /* g */ - dst[2] = rgb; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_l32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t rgb; - rgb = (int32_t)(value) ; - dst[0] = (unsigned)MAX2(rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(rgb, 0); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)((int32_t)MIN2(src[0], 2147483647)) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_l32a32_sint { - uint64_t value; - struct { - int32_t rgb; - int32_t a; - } chan; -}; - -static INLINE void -util_format_l32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_sint pixel; - pixel.chan.rgb = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_l32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_l32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.rgb; /* r */ - dst[1] = pixel.chan.rgb; /* g */ - dst[2] = pixel.chan.rgb; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_l32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.rgb, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.rgb, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.rgb, 0); /* b */ - dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_l32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_l32a32_sint pixel; - pixel.chan.rgb = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.a = (int32_t)MIN2(src[3], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10a2_uint { - uint32_t value; - struct { - unsigned b:10; - unsigned g:10; - unsigned r:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10a2_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)MIN2(src[2], 1023)) & 0x3ff; - value |= (((uint32_t)MIN2(src[1], 1023)) & 0x3ff) << 10; - value |= (((uint32_t)MIN2(src[0], 1023)) & 0x3ff) << 20; - value |= ((uint32_t)MIN2(src[3], 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_b10g10r10a2_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - uint32_t a; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10a2_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff; - value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10; - value |= (((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff) << 20; - value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8x8_snorm { - uint32_t value; - struct { - int8_t r; - int8_t g; - int8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(b * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)util_iround(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8x8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = (float)(g * (1.0f/0x7f)); /* g */ - dst[2] = (float)(b * (1.0f/0x7f)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = (uint8_t)(((uint32_t)MAX2(g, 0)) * 0xff / 0x7f); /* g */ - dst[2] = (uint8_t)(((uint32_t)MAX2(b, 0)) * 0xff / 0x7f); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)(src[0] >> 1)) & 0xff) ; - value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)(src[2] >> 1)) & 0xff) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8x8_srgb { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_float_to_srgb_8unorm(src[0])) & 0xff; - value |= ((util_format_linear_float_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_float_to_srgb_8unorm(src[2])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8x8_srgb_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = util_format_srgb_8unorm_to_linear_float(r); /* r */ - dst[1] = util_format_srgb_8unorm_to_linear_float(g); /* g */ - dst[2] = util_format_srgb_8unorm_to_linear_float(b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = util_format_srgb_to_linear_8unorm(r); /* r */ - dst[1] = util_format_srgb_to_linear_8unorm(g); /* g */ - dst[2] = util_format_srgb_to_linear_8unorm(b); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (util_format_linear_to_srgb_8unorm(src[0])) & 0xff; - value |= ((util_format_linear_to_srgb_8unorm(src[1])) & 0xff) << 8; - value |= ((util_format_linear_to_srgb_8unorm(src[2])) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8x8_uint { - uint32_t value; - struct { - uint8_t r; - uint8_t g; - uint8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -util_format_r8g8b8x8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8x8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)MIN2(src[0], 255)) & 0xff; - value |= (((uint8_t)MIN2(src[1], 255)) & 0xff) << 8; - value |= (((uint8_t)MIN2(src[2], 255)) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8x8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8b8x8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - r = (value) & 0xff; - g = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8x8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= (((uint8_t)CLAMP(src[1], 0, 255)) & 0xff) << 8; - value |= (((uint8_t)CLAMP(src[2], 0, 255)) & 0xff) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8g8b8x8_sint { - uint32_t value; - struct { - int8_t r; - int8_t g; - int8_t b; - uint8_t x; - } chan; -}; - -static INLINE void -util_format_r8g8b8x8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8x8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint32_t)((((int8_t)CLAMP(src[1], -128, 127)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)CLAMP(src[2], -128, 127)) & 0xff) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8g8b8x8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r8g8b8x8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t g; - int32_t b; - r = ((int32_t)(value << 24) ) >> 24; - g = ((int32_t)(value << 16) ) >> 24; - b = ((int32_t)(value << 8) ) >> 24; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = (unsigned)MAX2(g, 0); /* g */ - dst[2] = (unsigned)MAX2(b, 0); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8g8b8x8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ; - value |= (uint32_t)((((int8_t)MIN2(src[1], 127)) & 0xff) << 8) ; - value |= (uint32_t)((((int8_t)MIN2(src[2], 127)) & 0xff) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_b10g10r10x2_unorm { - uint32_t value; - struct { - unsigned b:10; - unsigned g:10; - unsigned r:10; - unsigned x:2; - } chan; -}; - -static INLINE void -util_format_b10g10r10x2_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = 1; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10x2_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)util_iround(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff; - value |= (((uint32_t)util_iround(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10; - value |= (((uint32_t)util_iround(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_b10g10r10x2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - dst[0] = (float)(r * (1.0f/0x3ff)); /* r */ - dst[1] = (float)(g * (1.0f/0x3ff)); /* g */ - dst[2] = (float)(b * (1.0f/0x3ff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_b10g10r10x2_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t b; - uint32_t g; - uint32_t r; - b = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - r = (value >> 20) & 0x3ff; - dst[0] = (uint8_t)(r >> 2); /* r */ - dst[1] = (uint8_t)(g >> 2); /* g */ - dst[2] = (uint8_t)(b >> 2); /* b */ - dst[3] = 255; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_b10g10r10x2_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)(((uint32_t)src[2]) * 0x3ff / 0xff)) & 0x3ff; - value |= (((uint32_t)(((uint32_t)src[1]) * 0x3ff / 0xff)) & 0x3ff) << 10; - value |= (((uint32_t)(((uint32_t)src[0]) * 0x3ff / 0xff)) & 0x3ff) << 20; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16x16_unorm { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_unorm pixel; - pixel.chan.r = (uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff); - pixel.chan.g = (uint16_t)util_iround(CLAMP(src[1], 0, 1) * 0xffff); - pixel.chan.b = (uint16_t)util_iround(CLAMP(src[2], 0, 1) * 0xffff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16x16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16x16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0xffff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0xffff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0xffff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_unorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(pixel.chan.r >> 8); /* r */ - dst[1] = (uint8_t)(pixel.chan.g >> 8); /* g */ - dst[2] = (uint8_t)(pixel.chan.b >> 8); /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_unorm pixel; - pixel.chan.r = (uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff); - pixel.chan.g = (uint16_t)(((uint32_t)src[1]) * 0xffff / 0xff); - pixel.chan.b = (uint16_t)(((uint32_t)src[2]) * 0xffff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16x16_snorm { - uint64_t value; - struct { - int16_t r; - int16_t g; - int16_t b; - uint16_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_snorm pixel; - pixel.chan.r = (int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff); - pixel.chan.g = (int16_t)util_iround(CLAMP(src[1], -1, 1) * 0x7fff); - pixel.chan.b = (int16_t)util_iround(CLAMP(src[2], -1, 1) * 0x7fff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16x16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16x16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (float)(pixel.chan.r * (1.0f/0x7fff)); /* r */ - dst[1] = (float)(pixel.chan.g * (1.0f/0x7fff)); /* g */ - dst[2] = (float)(pixel.chan.b * (1.0f/0x7fff)); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_snorm pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (uint8_t)(MAX2(pixel.chan.r, 0) >> 7); /* r */ - dst[1] = (uint8_t)(MAX2(pixel.chan.g, 0) >> 7); /* g */ - dst[2] = (uint8_t)(MAX2(pixel.chan.b, 0) >> 7); /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_snorm pixel; - pixel.chan.r = (int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff); - pixel.chan.g = (int16_t)(((uint32_t)src[1]) * 0x7fff / 0xff); - pixel.chan.b = (int16_t)(((uint32_t)src[2]) * 0x7fff / 0xff); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16x16_float { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - pixel.chan.g = util_float_to_half(src[1]); - pixel.chan.b = util_float_to_half(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16x16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16x16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = util_half_to_float(pixel.chan.g); /* g */ - dst[2] = util_half_to_float(pixel.chan.b); /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = float_to_ubyte(util_half_to_float(pixel.chan.g)); /* g */ - dst[2] = float_to_ubyte(util_half_to_float(pixel.chan.b)); /* b */ - dst[3] = 255; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.g = util_float_to_half((float)(src[1] * (1.0f/0xff))); - pixel.chan.b = util_float_to_half((float)(src[2] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16x16_uint { - uint64_t value; - struct { - uint16_t r; - uint16_t g; - uint16_t b; - uint16_t x; - } chan; -}; - -static INLINE void -util_format_r16g16b16x16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16x16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_uint pixel; - pixel.chan.r = (uint16_t)MIN2(src[0], 65535); - pixel.chan.g = (uint16_t)MIN2(src[1], 65535); - pixel.chan.b = (uint16_t)MIN2(src[2], 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16x16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16x16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)pixel.chan.r; /* r */ - dst[1] = (unsigned)pixel.chan.g; /* g */ - dst[2] = (unsigned)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16b16x16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16x16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_uint pixel; - pixel.chan.r = (uint16_t)CLAMP(src[0], 0, 65535); - pixel.chan.g = (uint16_t)CLAMP(src[1], 0, 65535); - pixel.chan.b = (uint16_t)CLAMP(src[2], 0, 65535); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16g16b16x16_sint { - uint64_t value; - struct { - int16_t r; - int16_t g; - int16_t b; - uint16_t x; - } chan; -}; - -static INLINE void -util_format_r16g16b16x16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16x16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_sint pixel; - pixel.chan.r = (int16_t)CLAMP(src[0], -32768, 32767); - pixel.chan.g = (int16_t)CLAMP(src[1], -32768, 32767); - pixel.chan.b = (int16_t)CLAMP(src[2], -32768, 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16g16b16x16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16g16b16x16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)pixel.chan.r; /* r */ - dst[1] = (int)pixel.chan.g; /* g */ - dst[2] = (int)pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r16g16b16x16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = 1; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16g16b16x16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16g16b16x16_sint pixel; - pixel.chan.r = (int16_t)MIN2(src[0], 32767); - pixel.chan.g = (int16_t)MIN2(src[1], 32767); - pixel.chan.b = (int16_t)MIN2(src[2], 32767); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32x32_float { - struct { - float r; - float g; - float b; - uint32_t x; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_float pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32x32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32x32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = float_to_ubyte(pixel.chan.g); /* g */ - dst[2] = float_to_ubyte(pixel.chan.b); /* b */ - dst[3] = 255; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - pixel.chan.g = ubyte_to_float(src[1]); - pixel.chan.b = ubyte_to_float(src[2]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32x32_uint { - struct { - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t x; - } chan; -}; - -static INLINE void -util_format_r32g32b32x32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32x32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_uint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32x32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32x32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32b32x32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */ - dst[1] = (int)MIN2(pixel.chan.g, 2147483647); /* g */ - dst[2] = (int)MIN2(pixel.chan.b, 2147483647); /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32x32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_uint pixel; - pixel.chan.r = (uint32_t)MAX2(src[0], 0); - pixel.chan.g = (uint32_t)MAX2(src[1], 0); - pixel.chan.b = (uint32_t)MAX2(src[2], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32g32b32x32_sint { - struct { - int32_t r; - int32_t g; - int32_t b; - uint32_t x; - } chan; -}; - -static INLINE void -util_format_r32g32b32x32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32x32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_sint pixel; - pixel.chan.r = src[0]; - pixel.chan.g = src[1]; - pixel.chan.b = src[2]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32g32b32x32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32g32b32x32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = pixel.chan.g; /* g */ - dst[2] = pixel.chan.b; /* b */ - dst[3] = 1; /* a */ -} - -static INLINE void -util_format_r32g32b32x32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = (unsigned)MAX2(pixel.chan.g, 0); /* g */ - dst[2] = (unsigned)MAX2(pixel.chan.b, 0); /* b */ - dst[3] = 1; /* a */ - src += 16; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32g32b32x32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32g32b32x32_sint pixel; - pixel.chan.r = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.g = (int32_t)MIN2(src[1], 2147483647); - pixel.chan.b = (int32_t)MIN2(src[2], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 16; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8a8_snorm { - uint16_t value; - struct { - int8_t r; - int8_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; - value |= (uint16_t)(((int8_t)util_iround(CLAMP(src[3], -1, 1) * 0x7f)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8a8_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (float)(r * (1.0f/0x7f)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7f)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (uint8_t)(((uint32_t)MAX2(r, 0)) * 0xff / 0x7f); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(((uint32_t)MAX2(a, 0)) * 0xff / 0x7f); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)(src[0] >> 1)) & 0xff) ; - value |= (uint16_t)(((int8_t)(src[3] >> 1)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16a16_unorm { - uint32_t value; - struct { - uint16_t r; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)util_iround(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff; - value |= ((uint16_t)util_iround(CLAMP(src[3], 0, 1) * 0xffff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16a16_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (float)(r * (1.0f/0xffff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0xffff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (uint8_t)(r >> 8); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(a >> 8); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)(((uint32_t)src[0]) * 0xffff / 0xff)) & 0xffff; - value |= ((uint16_t)(((uint32_t)src[3]) * 0xffff / 0xff)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16a16_snorm { - uint32_t value; - struct { - int16_t r; - int16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)util_iround(CLAMP(src[3], -1, 1) * 0x7fff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16a16_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (float)(r * (1.0f/0x7fff)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (float)(a * (1.0f/0x7fff)); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (uint8_t)(MAX2(r, 0) >> 7); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (uint8_t)(MAX2(a, 0) >> 7); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)(((uint32_t)src[0]) * 0x7fff / 0xff)) & 0xffff) ; - value |= (uint32_t)(((int16_t)(((uint32_t)src[3]) * 0x7fff / 0xff)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16a16_float { - uint32_t value; - struct { - uint16_t r; - uint16_t a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16a16_float pixel; - pixel.chan.r = util_float_to_half(src[0]); - pixel.chan.a = util_float_to_half(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16a16_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = util_half_to_float(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = util_half_to_float(pixel.chan.a); /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r16a16_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(util_half_to_float(pixel.chan.r)); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = float_to_ubyte(util_half_to_float(pixel.chan.a)); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r16a16_float pixel; - pixel.chan.r = util_float_to_half((float)(src[0] * (1.0f/0xff))); - pixel.chan.a = util_float_to_half((float)(src[3] * (1.0f/0xff))); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32a32_float { - uint64_t value; - struct { - float r; - float a; - } chan; -}; - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const float *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_float pixel; - pixel.chan.r = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32a32_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_float pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = float_to_ubyte(pixel.chan.r); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = float_to_ubyte(pixel.chan.a); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -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) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_float pixel; - pixel.chan.r = ubyte_to_float(src[0]); - pixel.chan.a = ubyte_to_float(src[3]); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8a8_uint { - uint16_t value; - struct { - uint8_t r; - uint8_t a; - } chan; -}; - -static INLINE void -util_format_r8a8_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8a8_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)MIN2(src[0], 255)) & 0xff; - value |= ((uint8_t)MIN2(src[3], 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8a8_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_r8a8_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - uint16_t r; - uint16_t a; - r = (value) & 0xff; - a = value >> 8; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8a8_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= ((uint8_t)CLAMP(src[0], 0, 255)) & 0xff; - value |= ((uint8_t)CLAMP(src[3], 0, 255)) << 8; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r8a8_sint { - uint16_t value; - struct { - int8_t r; - int8_t a; - } chan; -}; - -static INLINE void -util_format_r8a8_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8a8_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)CLAMP(src[0], -128, 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)CLAMP(src[3], -128, 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r8a8_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_r8a8_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint16_t value = *(const uint16_t *)src; - int16_t r; - int16_t a; - r = ((int16_t)(value << 8) ) >> 8; - a = ((int16_t)(value) ) >> 8; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 2; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r8a8_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint16_t value = 0; - value |= (uint16_t)(((int8_t)MIN2(src[0], 127)) & 0xff) ; - value |= (uint16_t)(((int8_t)MIN2(src[3], 127)) << 8) ; - *(uint16_t *)dst = value; - src += 4; - dst += 2; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16a16_uint { - uint32_t value; - struct { - uint16_t r; - uint16_t a; - } chan; -}; - -static INLINE void -util_format_r16a16_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16a16_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)MIN2(src[0], 65535)) & 0xffff; - value |= ((uint16_t)MIN2(src[3], 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16a16_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (unsigned)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_r16a16_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t a; - r = (value) & 0xffff; - a = value >> 16; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16a16_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint16_t)CLAMP(src[0], 0, 65535)) & 0xffff; - value |= ((uint16_t)CLAMP(src[3], 0, 65535)) << 16; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r16a16_sint { - uint32_t value; - struct { - int16_t r; - int16_t a; - } chan; -}; - -static INLINE void -util_format_r16a16_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16a16_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)CLAMP(src[0], -32768, 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)CLAMP(src[3], -32768, 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r16a16_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (int)r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)a; /* a */ -} - -static INLINE void -util_format_r16a16_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - int32_t r; - int32_t a; - r = ((int32_t)(value << 16) ) >> 16; - a = ((int32_t)(value) ) >> 16; - dst[0] = (unsigned)MAX2(r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(a, 0); /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r16a16_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= (uint32_t)(((int16_t)MIN2(src[0], 32767)) & 0xffff) ; - value |= (uint32_t)(((int16_t)MIN2(src[3], 32767)) << 16) ; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32a32_uint { - uint64_t value; - struct { - uint32_t r; - uint32_t a; - } chan; -}; - -static INLINE void -util_format_r32a32_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32a32_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_uint pixel; - pixel.chan.r = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32a32_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r32a32_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_uint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (int)MIN2(pixel.chan.r, 2147483647); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (int)MIN2(pixel.chan.a, 2147483647); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32a32_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_uint pixel; - pixel.chan.r = (uint32_t)MAX2(src[0], 0); - pixel.chan.a = (uint32_t)MAX2(src[3], 0); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r32a32_sint { - uint64_t value; - struct { - int32_t r; - int32_t a; - } chan; -}; - -static INLINE void -util_format_r32a32_sint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32a32_sint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_sint pixel; - pixel.chan.r = src[0]; - pixel.chan.a = src[3]; - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r32a32_sint_fetch_signed(int *dst, const uint8_t *src, unsigned i, unsigned j) -{ - union util_format_r32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = pixel.chan.r; /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = pixel.chan.a; /* a */ -} - -static INLINE void -util_format_r32a32_sint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_sint pixel; - memcpy(&pixel, src, sizeof pixel); - dst[0] = (unsigned)MAX2(pixel.chan.r, 0); /* r */ - dst[1] = 0; /* g */ - dst[2] = 0; /* b */ - dst[3] = (unsigned)MAX2(pixel.chan.a, 0); /* a */ - src += 8; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r32a32_sint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - union util_format_r32a32_sint pixel; - pixel.chan.r = (int32_t)MIN2(src[0], 2147483647); - pixel.chan.a = (int32_t)MIN2(src[3], 2147483647); - memcpy(dst, &pixel, sizeof pixel); - src += 4; - dst += 8; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -union util_format_r10g10b10a2_uint { - uint32_t value; - struct { - unsigned r:10; - unsigned g:10; - unsigned b:10; - unsigned a:2; - } chan; -}; - -static INLINE void -util_format_r10g10b10a2_uint_unpack_unsigned(unsigned *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - unsigned *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uint_pack_unsigned(uint8_t *dst_row, unsigned dst_stride, const unsigned *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const unsigned *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)MIN2(src[0], 1023)) & 0x3ff; - value |= (((uint32_t)MIN2(src[1], 1023)) & 0x3ff) << 10; - value |= (((uint32_t)MIN2(src[2], 1023)) & 0x3ff) << 20; - value |= ((uint32_t)MIN2(src[3], 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uint_fetch_unsigned(unsigned *dst, const uint8_t *src, unsigned i, unsigned j) -{ - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (unsigned)r; /* r */ - dst[1] = (unsigned)g; /* g */ - dst[2] = (unsigned)b; /* b */ - dst[3] = (unsigned)a; /* a */ -} - -static INLINE void -util_format_r10g10b10a2_uint_unpack_signed(int *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - int *dst = dst_row; - const uint8_t *src = src_row; - for(x = 0; x < width; x += 1) { - uint32_t value = *(const uint32_t *)src; - uint32_t r; - uint32_t g; - uint32_t b; - uint32_t a; - r = (value) & 0x3ff; - g = (value >> 10) & 0x3ff; - b = (value >> 20) & 0x3ff; - a = value >> 30; - dst[0] = (int)r; /* r */ - dst[1] = (int)g; /* g */ - dst[2] = (int)b; /* b */ - dst[3] = (int)a; /* a */ - src += 4; - dst += 4; - } - src_row += src_stride; - dst_row += dst_stride/sizeof(*dst_row); - } -} - -static INLINE void -util_format_r10g10b10a2_uint_pack_signed(uint8_t *dst_row, unsigned dst_stride, const int *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; y += 1) { - const int *src = src_row; - uint8_t *dst = dst_row; - for(x = 0; x < width; x += 1) { - uint32_t value = 0; - value |= ((uint32_t)CLAMP(src[0], 0, 1023)) & 0x3ff; - value |= (((uint32_t)CLAMP(src[1], 0, 1023)) & 0x3ff) << 10; - value |= (((uint32_t)CLAMP(src[2], 0, 1023)) & 0x3ff) << 20; - value |= ((uint32_t)CLAMP(src[3], 0, 3)) << 30; - *(uint32_t *)dst = value; - src += 4; - dst += 4; - } - dst_row += dst_stride; - src_row += src_stride/sizeof(*src_row); - } -} - -const struct util_format_description -util_format_none_description = { - PIPE_FORMAT_NONE, - "PIPE_FORMAT_NONE", - "none", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_none_unpack_rgba_8unorm, - &util_format_none_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_none_unpack_rgba_float, - &util_format_none_pack_rgba_float, - &util_format_none_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b8g8r8a8_unorm_description = { - PIPE_FORMAT_B8G8R8A8_UNORM, - "PIPE_FORMAT_B8G8R8A8_UNORM", - "b8g8r8a8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b8g8r8a8_unorm_unpack_rgba_8unorm, - &util_format_b8g8r8a8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b8g8r8a8_unorm_unpack_rgba_float, - &util_format_b8g8r8a8_unorm_pack_rgba_float, - &util_format_b8g8r8a8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b8g8r8x8_unorm_description = { - PIPE_FORMAT_B8G8R8X8_UNORM, - "PIPE_FORMAT_B8G8R8X8_UNORM", - "b8g8r8x8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b8g8r8x8_unorm_unpack_rgba_8unorm, - &util_format_b8g8r8x8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b8g8r8x8_unorm_unpack_rgba_float, - &util_format_b8g8r8x8_unorm_pack_rgba_float, - &util_format_b8g8r8x8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8r8g8b8_unorm_description = { - PIPE_FORMAT_A8R8G8B8_UNORM, - "PIPE_FORMAT_A8R8G8B8_UNORM", - "a8r8g8b8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */ - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_Z, /* g */ - UTIL_FORMAT_SWIZZLE_W, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a8r8g8b8_unorm_unpack_rgba_8unorm, - &util_format_a8r8g8b8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8r8g8b8_unorm_unpack_rgba_float, - &util_format_a8r8g8b8_unorm_pack_rgba_float, - &util_format_a8r8g8b8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x8r8g8b8_unorm_description = { - PIPE_FORMAT_X8R8G8B8_UNORM, - "PIPE_FORMAT_X8R8G8B8_UNORM", - "x8r8g8b8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */ - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_Z, /* g */ - UTIL_FORMAT_SWIZZLE_W, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_x8r8g8b8_unorm_unpack_rgba_8unorm, - &util_format_x8r8g8b8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_x8r8g8b8_unorm_unpack_rgba_float, - &util_format_x8r8g8b8_unorm_pack_rgba_float, - &util_format_x8r8g8b8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8b8g8r8_unorm_description = { - PIPE_FORMAT_A8B8G8R8_UNORM, - "PIPE_FORMAT_A8B8G8R8_UNORM", - "a8b8g8r8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */ - }, - { - UTIL_FORMAT_SWIZZLE_W, /* r */ - UTIL_FORMAT_SWIZZLE_Z, /* g */ - UTIL_FORMAT_SWIZZLE_Y, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a8b8g8r8_unorm_unpack_rgba_8unorm, - &util_format_a8b8g8r8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8b8g8r8_unorm_unpack_rgba_float, - &util_format_a8b8g8r8_unorm_pack_rgba_float, - &util_format_a8b8g8r8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x8b8g8r8_unorm_description = { - PIPE_FORMAT_X8B8G8R8_UNORM, - "PIPE_FORMAT_X8B8G8R8_UNORM", - "x8b8g8r8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */ - }, - { - UTIL_FORMAT_SWIZZLE_W, /* r */ - UTIL_FORMAT_SWIZZLE_Z, /* g */ - UTIL_FORMAT_SWIZZLE_Y, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_x8b8g8r8_unorm_unpack_rgba_8unorm, - &util_format_x8b8g8r8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_x8b8g8r8_unorm_unpack_rgba_float, - &util_format_x8b8g8r8_unorm_pack_rgba_float, - &util_format_x8b8g8r8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8x8_unorm_description = { - PIPE_FORMAT_R8G8B8X8_UNORM, - "PIPE_FORMAT_R8G8B8X8_UNORM", - "r8g8b8x8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8x8_unorm_unpack_rgba_8unorm, - &util_format_r8g8b8x8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8x8_unorm_unpack_rgba_float, - &util_format_r8g8b8x8_unorm_pack_rgba_float, - &util_format_r8g8b8x8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b5g5r5x1_unorm_description = { - PIPE_FORMAT_B5G5R5X1_UNORM, - "PIPE_FORMAT_B5G5R5X1_UNORM", - "b5g5r5x1_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 5}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 10}, /* z = r */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 1, 15} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b5g5r5x1_unorm_unpack_rgba_8unorm, - &util_format_b5g5r5x1_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b5g5r5x1_unorm_unpack_rgba_float, - &util_format_b5g5r5x1_unorm_pack_rgba_float, - &util_format_b5g5r5x1_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b5g5r5a1_unorm_description = { - PIPE_FORMAT_B5G5R5A1_UNORM, - "PIPE_FORMAT_B5G5R5A1_UNORM", - "b5g5r5a1_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 5}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 10}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 1, 15} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b5g5r5a1_unorm_unpack_rgba_8unorm, - &util_format_b5g5r5a1_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b5g5r5a1_unorm_unpack_rgba_float, - &util_format_b5g5r5a1_unorm_pack_rgba_float, - &util_format_b5g5r5a1_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b4g4r4a4_unorm_description = { - PIPE_FORMAT_B4G4R4A4_UNORM, - "PIPE_FORMAT_B4G4R4A4_UNORM", - "b4g4r4a4_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 8}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 12} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b4g4r4a4_unorm_unpack_rgba_8unorm, - &util_format_b4g4r4a4_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b4g4r4a4_unorm_unpack_rgba_float, - &util_format_b4g4r4a4_unorm_pack_rgba_float, - &util_format_b4g4r4a4_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b4g4r4x4_unorm_description = { - PIPE_FORMAT_B4G4R4X4_UNORM, - "PIPE_FORMAT_B4G4R4X4_UNORM", - "b4g4r4x4_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 8}, /* z = r */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 4, 12} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b4g4r4x4_unorm_unpack_rgba_8unorm, - &util_format_b4g4r4x4_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b4g4r4x4_unorm_unpack_rgba_float, - &util_format_b4g4r4x4_unorm_pack_rgba_float, - &util_format_b4g4r4x4_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b5g6r5_unorm_description = { - PIPE_FORMAT_B5G6R5_UNORM, - "PIPE_FORMAT_B5G6R5_UNORM", - "b5g6r5_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 6, 5}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 5, 11}, /* z = r */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b5g6r5_unorm_unpack_rgba_8unorm, - &util_format_b5g6r5_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b5g6r5_unorm_unpack_rgba_float, - &util_format_b5g6r5_unorm_pack_rgba_float, - &util_format_b5g6r5_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10a2_unorm_description = { - PIPE_FORMAT_R10G10B10A2_UNORM, - "PIPE_FORMAT_R10G10B10A2_UNORM", - "r10g10b10a2_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10a2_unorm_unpack_rgba_8unorm, - &util_format_r10g10b10a2_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10a2_unorm_unpack_rgba_float, - &util_format_r10g10b10a2_unorm_pack_rgba_float, - &util_format_r10g10b10a2_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10a2_unorm_description = { - PIPE_FORMAT_B10G10R10A2_UNORM, - "PIPE_FORMAT_B10G10R10A2_UNORM", - "b10g10r10a2_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b10g10r10a2_unorm_unpack_rgba_8unorm, - &util_format_b10g10r10a2_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b10g10r10a2_unorm_unpack_rgba_float, - &util_format_b10g10r10a2_unorm_pack_rgba_float, - &util_format_b10g10r10a2_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b2g3r3_unorm_description = { - PIPE_FORMAT_B2G3R3_UNORM, - "PIPE_FORMAT_B2G3R3_UNORM", - "b2g3r3_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 2, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 3, 2}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 3, 5}, /* z = r */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b2g3r3_unorm_unpack_rgba_8unorm, - &util_format_b2g3r3_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b2g3r3_unorm_unpack_rgba_float, - &util_format_b2g3r3_unorm_pack_rgba_float, - &util_format_b2g3r3_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8_unorm_description = { - PIPE_FORMAT_L8_UNORM, - "PIPE_FORMAT_L8_UNORM", - "l8_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l8_unorm_unpack_rgba_8unorm, - &util_format_l8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8_unorm_unpack_rgba_float, - &util_format_l8_unorm_pack_rgba_float, - &util_format_l8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8_unorm_description = { - PIPE_FORMAT_A8_UNORM, - "PIPE_FORMAT_A8_UNORM", - "a8_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a8_unorm_unpack_rgba_8unorm, - &util_format_a8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8_unorm_unpack_rgba_float, - &util_format_a8_unorm_pack_rgba_float, - &util_format_a8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i8_unorm_description = { - PIPE_FORMAT_I8_UNORM, - "PIPE_FORMAT_I8_UNORM", - "i8_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i8_unorm_unpack_rgba_8unorm, - &util_format_i8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i8_unorm_unpack_rgba_float, - &util_format_i8_unorm_pack_rgba_float, - &util_format_i8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l4a4_unorm_description = { - PIPE_FORMAT_L4A4_UNORM, - "PIPE_FORMAT_L4A4_UNORM", - "l4a4_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l4a4_unorm_unpack_rgba_8unorm, - &util_format_l4a4_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l4a4_unorm_unpack_rgba_float, - &util_format_l4a4_unorm_pack_rgba_float, - &util_format_l4a4_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8a8_unorm_description = { - PIPE_FORMAT_L8A8_UNORM, - "PIPE_FORMAT_L8A8_UNORM", - "l8a8_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l8a8_unorm_unpack_rgba_8unorm, - &util_format_l8a8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8a8_unorm_unpack_rgba_float, - &util_format_l8a8_unorm_pack_rgba_float, - &util_format_l8a8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16_unorm_description = { - PIPE_FORMAT_L16_UNORM, - "PIPE_FORMAT_L16_UNORM", - "l16_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16_unorm_unpack_rgba_8unorm, - &util_format_l16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16_unorm_unpack_rgba_float, - &util_format_l16_unorm_pack_rgba_float, - &util_format_l16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a16_unorm_description = { - PIPE_FORMAT_A16_UNORM, - "PIPE_FORMAT_A16_UNORM", - "a16_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a16_unorm_unpack_rgba_8unorm, - &util_format_a16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a16_unorm_unpack_rgba_float, - &util_format_a16_unorm_pack_rgba_float, - &util_format_a16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i16_unorm_description = { - PIPE_FORMAT_I16_UNORM, - "PIPE_FORMAT_I16_UNORM", - "i16_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i16_unorm_unpack_rgba_8unorm, - &util_format_i16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i16_unorm_unpack_rgba_float, - &util_format_i16_unorm_pack_rgba_float, - &util_format_i16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16a16_unorm_description = { - PIPE_FORMAT_L16A16_UNORM, - "PIPE_FORMAT_L16A16_UNORM", - "l16a16_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16a16_unorm_unpack_rgba_8unorm, - &util_format_l16a16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16a16_unorm_unpack_rgba_float, - &util_format_l16a16_unorm_pack_rgba_float, - &util_format_l16a16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8_snorm_description = { - PIPE_FORMAT_A8_SNORM, - "PIPE_FORMAT_A8_SNORM", - "a8_snorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a8_snorm_unpack_rgba_8unorm, - &util_format_a8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8_snorm_unpack_rgba_float, - &util_format_a8_snorm_pack_rgba_float, - &util_format_a8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8_snorm_description = { - PIPE_FORMAT_L8_SNORM, - "PIPE_FORMAT_L8_SNORM", - "l8_snorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l8_snorm_unpack_rgba_8unorm, - &util_format_l8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8_snorm_unpack_rgba_float, - &util_format_l8_snorm_pack_rgba_float, - &util_format_l8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8a8_snorm_description = { - PIPE_FORMAT_L8A8_SNORM, - "PIPE_FORMAT_L8A8_SNORM", - "l8a8_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l8a8_snorm_unpack_rgba_8unorm, - &util_format_l8a8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8a8_snorm_unpack_rgba_float, - &util_format_l8a8_snorm_pack_rgba_float, - &util_format_l8a8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i8_snorm_description = { - PIPE_FORMAT_I8_SNORM, - "PIPE_FORMAT_I8_SNORM", - "i8_snorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i8_snorm_unpack_rgba_8unorm, - &util_format_i8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i8_snorm_unpack_rgba_float, - &util_format_i8_snorm_pack_rgba_float, - &util_format_i8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a16_snorm_description = { - PIPE_FORMAT_A16_SNORM, - "PIPE_FORMAT_A16_SNORM", - "a16_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a16_snorm_unpack_rgba_8unorm, - &util_format_a16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a16_snorm_unpack_rgba_float, - &util_format_a16_snorm_pack_rgba_float, - &util_format_a16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16_snorm_description = { - PIPE_FORMAT_L16_SNORM, - "PIPE_FORMAT_L16_SNORM", - "l16_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16_snorm_unpack_rgba_8unorm, - &util_format_l16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16_snorm_unpack_rgba_float, - &util_format_l16_snorm_pack_rgba_float, - &util_format_l16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16a16_snorm_description = { - PIPE_FORMAT_L16A16_SNORM, - "PIPE_FORMAT_L16A16_SNORM", - "l16a16_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16a16_snorm_unpack_rgba_8unorm, - &util_format_l16a16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16a16_snorm_unpack_rgba_float, - &util_format_l16a16_snorm_pack_rgba_float, - &util_format_l16a16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i16_snorm_description = { - PIPE_FORMAT_I16_SNORM, - "PIPE_FORMAT_I16_SNORM", - "i16_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i16_snorm_unpack_rgba_8unorm, - &util_format_i16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i16_snorm_unpack_rgba_float, - &util_format_i16_snorm_pack_rgba_float, - &util_format_i16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a16_float_description = { - PIPE_FORMAT_A16_FLOAT, - "PIPE_FORMAT_A16_FLOAT", - "a16_float", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a16_float_unpack_rgba_8unorm, - &util_format_a16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a16_float_unpack_rgba_float, - &util_format_a16_float_pack_rgba_float, - &util_format_a16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16_float_description = { - PIPE_FORMAT_L16_FLOAT, - "PIPE_FORMAT_L16_FLOAT", - "l16_float", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16_float_unpack_rgba_8unorm, - &util_format_l16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16_float_unpack_rgba_float, - &util_format_l16_float_pack_rgba_float, - &util_format_l16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16a16_float_description = { - PIPE_FORMAT_L16A16_FLOAT, - "PIPE_FORMAT_L16A16_FLOAT", - "l16a16_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l16a16_float_unpack_rgba_8unorm, - &util_format_l16a16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l16a16_float_unpack_rgba_float, - &util_format_l16a16_float_pack_rgba_float, - &util_format_l16a16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i16_float_description = { - PIPE_FORMAT_I16_FLOAT, - "PIPE_FORMAT_I16_FLOAT", - "i16_float", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i16_float_unpack_rgba_8unorm, - &util_format_i16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i16_float_unpack_rgba_float, - &util_format_i16_float_pack_rgba_float, - &util_format_i16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a32_float_description = { - PIPE_FORMAT_A32_FLOAT, - "PIPE_FORMAT_A32_FLOAT", - "a32_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a32_float_unpack_rgba_8unorm, - &util_format_a32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a32_float_unpack_rgba_float, - &util_format_a32_float_pack_rgba_float, - &util_format_a32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32_float_description = { - PIPE_FORMAT_L32_FLOAT, - "PIPE_FORMAT_L32_FLOAT", - "l32_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l32_float_unpack_rgba_8unorm, - &util_format_l32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l32_float_unpack_rgba_float, - &util_format_l32_float_pack_rgba_float, - &util_format_l32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32a32_float_description = { - PIPE_FORMAT_L32A32_FLOAT, - "PIPE_FORMAT_L32A32_FLOAT", - "l32a32_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_l32a32_float_unpack_rgba_8unorm, - &util_format_l32a32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l32a32_float_unpack_rgba_float, - &util_format_l32a32_float_pack_rgba_float, - &util_format_l32a32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i32_float_description = { - PIPE_FORMAT_I32_FLOAT, - "PIPE_FORMAT_I32_FLOAT", - "i32_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_i32_float_unpack_rgba_8unorm, - &util_format_i32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_i32_float_unpack_rgba_float, - &util_format_i32_float_pack_rgba_float, - &util_format_i32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8_srgb_description = { - PIPE_FORMAT_L8_SRGB, - "PIPE_FORMAT_L8_SRGB", - "l8_srgb", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_X, /* sg */ - UTIL_FORMAT_SWIZZLE_X, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_l8_srgb_unpack_rgba_8unorm, - &util_format_l8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8_srgb_unpack_rgba_float, - &util_format_l8_srgb_pack_rgba_float, - &util_format_l8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8a8_srgb_description = { - PIPE_FORMAT_L8A8_SRGB, - "PIPE_FORMAT_L8A8_SRGB", - "l8a8_srgb", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_X, /* sg */ - UTIL_FORMAT_SWIZZLE_X, /* sb */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_l8a8_srgb_unpack_rgba_8unorm, - &util_format_l8a8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_l8a8_srgb_unpack_rgba_float, - &util_format_l8a8_srgb_pack_rgba_float, - &util_format_l8a8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_srgb_description = { - PIPE_FORMAT_R8G8B8_SRGB, - "PIPE_FORMAT_R8G8B8_SRGB", - "r8g8b8_srgb", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_r8g8b8_srgb_unpack_rgba_8unorm, - &util_format_r8g8b8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8_srgb_unpack_rgba_float, - &util_format_r8g8b8_srgb_pack_rgba_float, - &util_format_r8g8b8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_srgb_description = { - PIPE_FORMAT_R8G8B8A8_SRGB, - "PIPE_FORMAT_R8G8B8A8_SRGB", - "r8g8b8a8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_r8g8b8a8_srgb_unpack_rgba_8unorm, - &util_format_r8g8b8a8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8a8_srgb_unpack_rgba_float, - &util_format_r8g8b8a8_srgb_pack_rgba_float, - &util_format_r8g8b8a8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8b8g8r8_srgb_description = { - PIPE_FORMAT_A8B8G8R8_SRGB, - "PIPE_FORMAT_A8B8G8R8_SRGB", - "a8b8g8r8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */ - }, - { - UTIL_FORMAT_SWIZZLE_W, /* sr */ - UTIL_FORMAT_SWIZZLE_Z, /* sg */ - UTIL_FORMAT_SWIZZLE_Y, /* sb */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_a8b8g8r8_srgb_unpack_rgba_8unorm, - &util_format_a8b8g8r8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8b8g8r8_srgb_unpack_rgba_float, - &util_format_a8b8g8r8_srgb_pack_rgba_float, - &util_format_a8b8g8r8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x8b8g8r8_srgb_description = { - PIPE_FORMAT_X8B8G8R8_SRGB, - "PIPE_FORMAT_X8B8G8R8_SRGB", - "x8b8g8r8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = r */ - }, - { - UTIL_FORMAT_SWIZZLE_W, /* sr */ - UTIL_FORMAT_SWIZZLE_Z, /* sg */ - UTIL_FORMAT_SWIZZLE_Y, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_x8b8g8r8_srgb_unpack_rgba_8unorm, - &util_format_x8b8g8r8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_x8b8g8r8_srgb_unpack_rgba_float, - &util_format_x8b8g8r8_srgb_pack_rgba_float, - &util_format_x8b8g8r8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b8g8r8a8_srgb_description = { - PIPE_FORMAT_B8G8R8A8_SRGB, - "PIPE_FORMAT_B8G8R8A8_SRGB", - "b8g8r8a8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_X, /* sb */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_b8g8r8a8_srgb_unpack_rgba_8unorm, - &util_format_b8g8r8a8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b8g8r8a8_srgb_unpack_rgba_float, - &util_format_b8g8r8a8_srgb_pack_rgba_float, - &util_format_b8g8r8a8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b8g8r8x8_srgb_description = { - PIPE_FORMAT_B8G8R8X8_SRGB, - "PIPE_FORMAT_B8G8R8X8_SRGB", - "b8g8r8x8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = r */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_X, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_b8g8r8x8_srgb_unpack_rgba_8unorm, - &util_format_b8g8r8x8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b8g8r8x8_srgb_unpack_rgba_float, - &util_format_b8g8r8x8_srgb_pack_rgba_float, - &util_format_b8g8r8x8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8r8g8b8_srgb_description = { - PIPE_FORMAT_A8R8G8B8_SRGB, - "PIPE_FORMAT_A8R8G8B8_SRGB", - "a8r8g8b8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */ - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* sr */ - UTIL_FORMAT_SWIZZLE_Z, /* sg */ - UTIL_FORMAT_SWIZZLE_W, /* sb */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_a8r8g8b8_srgb_unpack_rgba_8unorm, - &util_format_a8r8g8b8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8r8g8b8_srgb_unpack_rgba_float, - &util_format_a8r8g8b8_srgb_pack_rgba_float, - &util_format_a8r8g8b8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x8r8g8b8_srgb_description = { - PIPE_FORMAT_X8R8G8B8_SRGB, - "PIPE_FORMAT_X8R8G8B8_SRGB", - "x8r8g8b8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = b */ - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* sr */ - UTIL_FORMAT_SWIZZLE_Z, /* sg */ - UTIL_FORMAT_SWIZZLE_W, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_x8r8g8b8_srgb_unpack_rgba_8unorm, - &util_format_x8r8g8b8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_x8r8g8b8_srgb_unpack_rgba_float, - &util_format_x8r8g8b8_srgb_pack_rgba_float, - &util_format_x8r8g8b8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8sg8sb8ux8u_norm_description = { - PIPE_FORMAT_R8SG8SB8UX8U_NORM, - "PIPE_FORMAT_R8SG8SB8UX8U_NORM", - "r8sg8sb8ux8u_norm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8sg8sb8ux8u_norm_unpack_rgba_8unorm, - &util_format_r8sg8sb8ux8u_norm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8sg8sb8ux8u_norm_unpack_rgba_float, - &util_format_r8sg8sb8ux8u_norm_pack_rgba_float, - &util_format_r8sg8sb8ux8u_norm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10sg10sb10sa2u_norm_description = { - PIPE_FORMAT_R10SG10SB10SA2U_NORM, - "PIPE_FORMAT_R10SG10SB10SA2U_NORM", - "r10sg10sb10sa2u_norm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10sg10sb10sa2u_norm_unpack_rgba_8unorm, - &util_format_r10sg10sb10sa2u_norm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10sg10sb10sa2u_norm_unpack_rgba_float, - &util_format_r10sg10sb10sa2u_norm_pack_rgba_float, - &util_format_r10sg10sb10sa2u_norm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r5sg5sb6u_norm_description = { - PIPE_FORMAT_R5SG5SB6U_NORM, - "PIPE_FORMAT_R5SG5SB6U_NORM", - "r5sg5sb6u_norm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 5, 5}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 6, 10}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r5sg5sb6u_norm_unpack_rgba_8unorm, - &util_format_r5sg5sb6u_norm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r5sg5sb6u_norm_unpack_rgba_float, - &util_format_r5sg5sb6u_norm_pack_rgba_float, - &util_format_r5sg5sb6u_norm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_s8_uint_description = { - PIPE_FORMAT_S8_UINT, - "PIPE_FORMAT_S8_UINT", - "s8_uint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_NONE, /* z */ - UTIL_FORMAT_SWIZZLE_X, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - &util_format_s8_uint_unpack_s_8uint, - &util_format_s8_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z16_unorm_description = { - PIPE_FORMAT_Z16_UNORM, - "PIPE_FORMAT_Z16_UNORM", - "z16_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = z */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_NONE, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z16_unorm_unpack_z_32unorm, - &util_format_z16_unorm_pack_z_32unorm, - &util_format_z16_unorm_unpack_z_float, - &util_format_z16_unorm_pack_z_float, - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z32_unorm_description = { - PIPE_FORMAT_Z32_UNORM, - "PIPE_FORMAT_Z32_UNORM", - "z32_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = z */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_NONE, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z32_unorm_unpack_z_32unorm, - &util_format_z32_unorm_pack_z_32unorm, - &util_format_z32_unorm_unpack_z_float, - &util_format_z32_unorm_pack_z_float, - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z32_float_description = { - PIPE_FORMAT_Z32_FLOAT, - "PIPE_FORMAT_Z32_FLOAT", - "z32_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = z */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_NONE, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z32_float_unpack_z_32unorm, - &util_format_z32_float_pack_z_32unorm, - &util_format_z32_float_unpack_z_float, - &util_format_z32_float_pack_z_float, - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z24_unorm_s8_uint_description = { - PIPE_FORMAT_Z24_UNORM_S8_UINT, - "PIPE_FORMAT_Z24_UNORM_S8_UINT", - "z24_unorm_s8_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0}, /* x = z */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24}, /* y = s */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_Y, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z24_unorm_s8_uint_unpack_z_32unorm, - &util_format_z24_unorm_s8_uint_pack_z_32unorm, - &util_format_z24_unorm_s8_uint_unpack_z_float, - &util_format_z24_unorm_s8_uint_pack_z_float, - &util_format_z24_unorm_s8_uint_unpack_s_8uint, - &util_format_z24_unorm_s8_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_s8_uint_z24_unorm_description = { - PIPE_FORMAT_S8_UINT_Z24_UNORM, - "PIPE_FORMAT_S8_UINT_Z24_UNORM", - "s8_uint_z24_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8}, /* y = z */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* z */ - UTIL_FORMAT_SWIZZLE_X, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_s8_uint_z24_unorm_unpack_z_32unorm, - &util_format_s8_uint_z24_unorm_pack_z_32unorm, - &util_format_s8_uint_z24_unorm_unpack_z_float, - &util_format_s8_uint_z24_unorm_pack_z_float, - &util_format_s8_uint_z24_unorm_unpack_s_8uint, - &util_format_s8_uint_z24_unorm_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x24s8_uint_description = { - PIPE_FORMAT_X24S8_UINT, - "PIPE_FORMAT_X24S8_UINT", - "x24s8_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24}, /* y = s */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_NONE, /* z */ - UTIL_FORMAT_SWIZZLE_Y, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - &util_format_x24s8_uint_unpack_s_8uint, - &util_format_x24s8_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_s8x24_uint_description = { - PIPE_FORMAT_S8X24_UINT, - "PIPE_FORMAT_S8X24_UINT", - "s8x24_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = s */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 8}, /* y = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_NONE, /* z */ - UTIL_FORMAT_SWIZZLE_X, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - &util_format_s8x24_uint_unpack_s_8uint, - &util_format_s8x24_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z24x8_unorm_description = { - PIPE_FORMAT_Z24X8_UNORM, - "PIPE_FORMAT_Z24X8_UNORM", - "z24x8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 0}, /* x = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24}, /* y = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_NONE, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z24x8_unorm_unpack_z_32unorm, - &util_format_z24x8_unorm_pack_z_32unorm, - &util_format_z24x8_unorm_unpack_z_float, - &util_format_z24x8_unorm_pack_z_float, - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x8z24_unorm_description = { - PIPE_FORMAT_X8Z24_UNORM, - "PIPE_FORMAT_X8Z24_UNORM", - "x8z24_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 24, 8}, /* y = z */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* z */ - UTIL_FORMAT_SWIZZLE_NONE, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_x8z24_unorm_unpack_z_32unorm, - &util_format_x8z24_unorm_pack_z_32unorm, - &util_format_x8z24_unorm_unpack_z_float, - &util_format_x8z24_unorm_pack_z_float, - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_z32_float_s8x24_uint_description = { - PIPE_FORMAT_Z32_FLOAT_S8X24_UINT, - "PIPE_FORMAT_Z32_FLOAT_S8X24_UINT", - "z32_float_s8x24_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - TRUE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = z */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32}, /* y = s */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40}, /* z = x */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* z */ - UTIL_FORMAT_SWIZZLE_Y, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - &util_format_z32_float_s8x24_uint_unpack_z_32unorm, - &util_format_z32_float_s8x24_uint_pack_z_32unorm, - &util_format_z32_float_s8x24_uint_unpack_z_float, - &util_format_z32_float_s8x24_uint_pack_z_float, - &util_format_z32_float_s8x24_uint_unpack_s_8uint, - &util_format_z32_float_s8x24_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_x32_s8x24_uint_description = { - PIPE_FORMAT_X32_S8X24_UINT, - "PIPE_FORMAT_X32_S8X24_UINT", - "x32_s8x24_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 32}, /* y = s */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 24, 40}, /* z = x */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_NONE, /* z */ - UTIL_FORMAT_SWIZZLE_Y, /* s */ - UTIL_FORMAT_SWIZZLE_NONE, /* ignored */ - UTIL_FORMAT_SWIZZLE_NONE /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_ZS, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - &util_format_x32_s8x24_uint_unpack_s_8uint, - &util_format_x32_s8x24_uint_pack_s_8uint, - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_uyvy_description = { - PIPE_FORMAT_UYVY, - "PIPE_FORMAT_UYVY", - "uyvy", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_1 /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_uyvy_unpack_rgba_8unorm, - &util_format_uyvy_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_uyvy_unpack_rgba_float, - &util_format_uyvy_pack_rgba_float, - &util_format_uyvy_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_yuyv_description = { - PIPE_FORMAT_YUYV, - "PIPE_FORMAT_YUYV", - "yuyv", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_1 /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_yuyv_unpack_rgba_8unorm, - &util_format_yuyv_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_yuyv_unpack_rgba_float, - &util_format_yuyv_pack_rgba_float, - &util_format_yuyv_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_b8g8_unorm_description = { - PIPE_FORMAT_R8G8_B8G8_UNORM, - "PIPE_FORMAT_R8G8_B8G8_UNORM", - "r8g8_b8g8_unorm", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm, - &util_format_r8g8_b8g8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_b8g8_unorm_unpack_rgba_float, - &util_format_r8g8_b8g8_unorm_pack_rgba_float, - &util_format_r8g8_b8g8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_g8r8_g8b8_unorm_description = { - PIPE_FORMAT_G8R8_G8B8_UNORM, - "PIPE_FORMAT_G8R8_G8B8_UNORM", - "g8r8_g8b8_unorm", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm, - &util_format_g8r8_g8b8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_g8r8_g8b8_unorm_unpack_rgba_float, - &util_format_g8r8_g8b8_unorm_pack_rgba_float, - &util_format_g8r8_g8b8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_g8r8_b8r8_unorm_description = { - PIPE_FORMAT_G8R8_B8R8_UNORM, - "PIPE_FORMAT_G8R8_B8R8_UNORM", - "g8r8_b8r8_unorm", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm, - &util_format_g8r8_b8r8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_g8r8_b8r8_unorm_unpack_rgba_float, - &util_format_g8r8_b8r8_unorm_pack_rgba_float, - &util_format_g8r8_b8r8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_r8b8_unorm_description = { - PIPE_FORMAT_R8G8_R8B8_UNORM, - "PIPE_FORMAT_R8G8_R8B8_UNORM", - "r8g8_r8b8_unorm", - {2, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_SUBSAMPLED, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm, - &util_format_r8g8_r8b8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_r8b8_unorm_unpack_rgba_float, - &util_format_r8g8_r8b8_unorm_pack_rgba_float, - &util_format_r8g8_r8b8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r11g11b10_float_description = { - PIPE_FORMAT_R11G11B10_FLOAT, - "PIPE_FORMAT_R11G11B10_FLOAT", - "r11g11b10_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r11g11b10_float_unpack_rgba_8unorm, - &util_format_r11g11b10_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r11g11b10_float_unpack_rgba_float, - &util_format_r11g11b10_float_pack_rgba_float, - &util_format_r11g11b10_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r9g9b9e5_float_description = { - PIPE_FORMAT_R9G9B9E5_FLOAT, - "PIPE_FORMAT_R9G9B9E5_FLOAT", - "r9g9b9e5_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r9g9b9e5_float_unpack_rgba_8unorm, - &util_format_r9g9b9e5_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r9g9b9e5_float_unpack_rgba_float, - &util_format_r9g9b9e5_float_pack_rgba_float, - &util_format_r9g9b9e5_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r1_unorm_description = { - PIPE_FORMAT_R1_UNORM, - "PIPE_FORMAT_R1_UNORM", - "r1_unorm", - {8, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r1_unorm_unpack_rgba_8unorm, - &util_format_r1_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r1_unorm_unpack_rgba_float, - &util_format_r1_unorm_pack_rgba_float, - &util_format_r1_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8bx_snorm_description = { - PIPE_FORMAT_R8G8Bx_SNORM, - "PIPE_FORMAT_R8G8Bx_SNORM", - "r8g8bx_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 2, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = y */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8bx_snorm_unpack_rgba_8unorm, - &util_format_r8g8bx_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8bx_snorm_unpack_rgba_float, - &util_format_r8g8bx_snorm_pack_rgba_float, - &util_format_r8g8bx_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt1_rgb_description = { - PIPE_FORMAT_DXT1_RGB, - "PIPE_FORMAT_DXT1_RGB", - "dxt1_rgb", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_dxt1_rgb_unpack_rgba_8unorm, - &util_format_dxt1_rgb_pack_rgba_8unorm, - &util_format_dxt1_rgb_fetch_rgba_8unorm, - &util_format_dxt1_rgb_unpack_rgba_float, - &util_format_dxt1_rgb_pack_rgba_float, - &util_format_dxt1_rgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt1_rgba_description = { - PIPE_FORMAT_DXT1_RGBA, - "PIPE_FORMAT_DXT1_RGBA", - "dxt1_rgba", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_dxt1_rgba_unpack_rgba_8unorm, - &util_format_dxt1_rgba_pack_rgba_8unorm, - &util_format_dxt1_rgba_fetch_rgba_8unorm, - &util_format_dxt1_rgba_unpack_rgba_float, - &util_format_dxt1_rgba_pack_rgba_float, - &util_format_dxt1_rgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt3_rgba_description = { - PIPE_FORMAT_DXT3_RGBA, - "PIPE_FORMAT_DXT3_RGBA", - "dxt3_rgba", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_dxt3_rgba_unpack_rgba_8unorm, - &util_format_dxt3_rgba_pack_rgba_8unorm, - &util_format_dxt3_rgba_fetch_rgba_8unorm, - &util_format_dxt3_rgba_unpack_rgba_float, - &util_format_dxt3_rgba_pack_rgba_float, - &util_format_dxt3_rgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt5_rgba_description = { - PIPE_FORMAT_DXT5_RGBA, - "PIPE_FORMAT_DXT5_RGBA", - "dxt5_rgba", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_dxt5_rgba_unpack_rgba_8unorm, - &util_format_dxt5_rgba_pack_rgba_8unorm, - &util_format_dxt5_rgba_fetch_rgba_8unorm, - &util_format_dxt5_rgba_unpack_rgba_float, - &util_format_dxt5_rgba_pack_rgba_float, - &util_format_dxt5_rgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt1_srgb_description = { - PIPE_FORMAT_DXT1_SRGB, - "PIPE_FORMAT_DXT1_SRGB", - "dxt1_srgb", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_dxt1_srgb_unpack_rgba_8unorm, - &util_format_dxt1_srgb_pack_rgba_8unorm, - &util_format_dxt1_srgb_fetch_rgba_8unorm, - &util_format_dxt1_srgb_unpack_rgba_float, - &util_format_dxt1_srgb_pack_rgba_float, - &util_format_dxt1_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt1_srgba_description = { - PIPE_FORMAT_DXT1_SRGBA, - "PIPE_FORMAT_DXT1_SRGBA", - "dxt1_srgba", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_dxt1_srgba_unpack_rgba_8unorm, - &util_format_dxt1_srgba_pack_rgba_8unorm, - &util_format_dxt1_srgba_fetch_rgba_8unorm, - &util_format_dxt1_srgba_unpack_rgba_float, - &util_format_dxt1_srgba_pack_rgba_float, - &util_format_dxt1_srgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt3_srgba_description = { - PIPE_FORMAT_DXT3_SRGBA, - "PIPE_FORMAT_DXT3_SRGBA", - "dxt3_srgba", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_dxt3_srgba_unpack_rgba_8unorm, - &util_format_dxt3_srgba_pack_rgba_8unorm, - &util_format_dxt3_srgba_fetch_rgba_8unorm, - &util_format_dxt3_srgba_unpack_rgba_float, - &util_format_dxt3_srgba_pack_rgba_float, - &util_format_dxt3_srgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_dxt5_srgba_description = { - PIPE_FORMAT_DXT5_SRGBA, - "PIPE_FORMAT_DXT5_SRGBA", - "dxt5_srgba", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_S3TC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_dxt5_srgba_unpack_rgba_8unorm, - &util_format_dxt5_srgba_pack_rgba_8unorm, - &util_format_dxt5_srgba_fetch_rgba_8unorm, - &util_format_dxt5_srgba_unpack_rgba_float, - &util_format_dxt5_srgba_pack_rgba_float, - &util_format_dxt5_srgba_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_rgtc1_unorm_description = { - PIPE_FORMAT_RGTC1_UNORM, - "PIPE_FORMAT_RGTC1_UNORM", - "rgtc1_unorm", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_rgtc1_unorm_unpack_rgba_8unorm, - &util_format_rgtc1_unorm_pack_rgba_8unorm, - &util_format_rgtc1_unorm_fetch_rgba_8unorm, - &util_format_rgtc1_unorm_unpack_rgba_float, - &util_format_rgtc1_unorm_pack_rgba_float, - &util_format_rgtc1_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_rgtc1_snorm_description = { - PIPE_FORMAT_RGTC1_SNORM, - "PIPE_FORMAT_RGTC1_SNORM", - "rgtc1_snorm", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_rgtc1_snorm_unpack_rgba_8unorm, - &util_format_rgtc1_snorm_pack_rgba_8unorm, - &util_format_rgtc1_snorm_fetch_rgba_8unorm, - &util_format_rgtc1_snorm_unpack_rgba_float, - &util_format_rgtc1_snorm_pack_rgba_float, - &util_format_rgtc1_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_rgtc2_unorm_description = { - PIPE_FORMAT_RGTC2_UNORM, - "PIPE_FORMAT_RGTC2_UNORM", - "rgtc2_unorm", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_rgtc2_unorm_unpack_rgba_8unorm, - &util_format_rgtc2_unorm_pack_rgba_8unorm, - &util_format_rgtc2_unorm_fetch_rgba_8unorm, - &util_format_rgtc2_unorm_unpack_rgba_float, - &util_format_rgtc2_unorm_pack_rgba_float, - &util_format_rgtc2_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_rgtc2_snorm_description = { - PIPE_FORMAT_RGTC2_SNORM, - "PIPE_FORMAT_RGTC2_SNORM", - "rgtc2_snorm", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_rgtc2_snorm_unpack_rgba_8unorm, - &util_format_rgtc2_snorm_pack_rgba_8unorm, - &util_format_rgtc2_snorm_fetch_rgba_8unorm, - &util_format_rgtc2_snorm_unpack_rgba_float, - &util_format_rgtc2_snorm_pack_rgba_float, - &util_format_rgtc2_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_latc1_unorm_description = { - PIPE_FORMAT_LATC1_UNORM, - "PIPE_FORMAT_LATC1_UNORM", - "latc1_unorm", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_latc1_unorm_unpack_rgba_8unorm, - &util_format_latc1_unorm_pack_rgba_8unorm, - &util_format_latc1_unorm_fetch_rgba_8unorm, - &util_format_latc1_unorm_unpack_rgba_float, - &util_format_latc1_unorm_pack_rgba_float, - &util_format_latc1_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_latc1_snorm_description = { - PIPE_FORMAT_LATC1_SNORM, - "PIPE_FORMAT_LATC1_SNORM", - "latc1_snorm", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_latc1_snorm_unpack_rgba_8unorm, - &util_format_latc1_snorm_pack_rgba_8unorm, - &util_format_latc1_snorm_fetch_rgba_8unorm, - &util_format_latc1_snorm_unpack_rgba_float, - &util_format_latc1_snorm_pack_rgba_float, - &util_format_latc1_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_latc2_unorm_description = { - PIPE_FORMAT_LATC2_UNORM, - "PIPE_FORMAT_LATC2_UNORM", - "latc2_unorm", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_latc2_unorm_unpack_rgba_8unorm, - &util_format_latc2_unorm_pack_rgba_8unorm, - &util_format_latc2_unorm_fetch_rgba_8unorm, - &util_format_latc2_unorm_unpack_rgba_float, - &util_format_latc2_unorm_pack_rgba_float, - &util_format_latc2_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_latc2_snorm_description = { - PIPE_FORMAT_LATC2_SNORM, - "PIPE_FORMAT_LATC2_SNORM", - "latc2_snorm", - {4, 4, 128}, /* block */ - UTIL_FORMAT_LAYOUT_RGTC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 128, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_latc2_snorm_unpack_rgba_8unorm, - &util_format_latc2_snorm_pack_rgba_8unorm, - &util_format_latc2_snorm_fetch_rgba_8unorm, - &util_format_latc2_snorm_unpack_rgba_float, - &util_format_latc2_snorm_pack_rgba_float, - &util_format_latc2_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_etc1_rgb8_description = { - PIPE_FORMAT_ETC1_RGB8, - "PIPE_FORMAT_ETC1_RGB8", - "etc1_rgb8", - {4, 4, 64}, /* block */ - UTIL_FORMAT_LAYOUT_ETC, - 1, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 64, 0}, /* x = x */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_etc1_rgb8_unpack_rgba_8unorm, - &util_format_etc1_rgb8_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_etc1_rgb8_unpack_rgba_float, - &util_format_etc1_rgb8_pack_rgba_float, - &util_format_etc1_rgb8_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r64_float_description = { - PIPE_FORMAT_R64_FLOAT, - "PIPE_FORMAT_R64_FLOAT", - "r64_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r64_float_unpack_rgba_8unorm, - &util_format_r64_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r64_float_unpack_rgba_float, - &util_format_r64_float_pack_rgba_float, - &util_format_r64_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r64g64_float_description = { - PIPE_FORMAT_R64G64_FLOAT, - "PIPE_FORMAT_R64G64_FLOAT", - "r64g64_float", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r64g64_float_unpack_rgba_8unorm, - &util_format_r64g64_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r64g64_float_unpack_rgba_float, - &util_format_r64g64_float_pack_rgba_float, - &util_format_r64g64_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r64g64b64_float_description = { - PIPE_FORMAT_R64G64B64_FLOAT, - "PIPE_FORMAT_R64G64B64_FLOAT", - "r64g64b64_float", - {1, 1, 192}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r64g64b64_float_unpack_rgba_8unorm, - &util_format_r64g64b64_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r64g64b64_float_unpack_rgba_float, - &util_format_r64g64b64_float_pack_rgba_float, - &util_format_r64g64b64_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r64g64b64a64_float_description = { - PIPE_FORMAT_R64G64B64A64_FLOAT, - "PIPE_FORMAT_R64G64B64A64_FLOAT", - "r64g64b64a64_float", - {1, 1, 256}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 64}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 128}, /* z = b */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 64, 192} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r64g64b64a64_float_unpack_rgba_8unorm, - &util_format_r64g64b64a64_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r64g64b64a64_float_unpack_rgba_float, - &util_format_r64g64b64a64_float_pack_rgba_float, - &util_format_r64g64b64a64_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_float_description = { - PIPE_FORMAT_R32_FLOAT, - "PIPE_FORMAT_R32_FLOAT", - "r32_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_float_unpack_rgba_8unorm, - &util_format_r32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_float_unpack_rgba_float, - &util_format_r32_float_pack_rgba_float, - &util_format_r32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_float_description = { - PIPE_FORMAT_R32G32_FLOAT, - "PIPE_FORMAT_R32G32_FLOAT", - "r32g32_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_float_unpack_rgba_8unorm, - &util_format_r32g32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_float_unpack_rgba_float, - &util_format_r32g32_float_pack_rgba_float, - &util_format_r32g32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_float_description = { - PIPE_FORMAT_R32G32B32_FLOAT, - "PIPE_FORMAT_R32G32B32_FLOAT", - "r32g32b32_float", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_float_unpack_rgba_8unorm, - &util_format_r32g32b32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_float_unpack_rgba_float, - &util_format_r32g32b32_float_pack_rgba_float, - &util_format_r32g32b32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_float_description = { - PIPE_FORMAT_R32G32B32A32_FLOAT, - "PIPE_FORMAT_R32G32B32A32_FLOAT", - "r32g32b32a32_float", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_float_unpack_rgba_8unorm, - &util_format_r32g32b32a32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_float_unpack_rgba_float, - &util_format_r32g32b32a32_float_pack_rgba_float, - &util_format_r32g32b32a32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_unorm_description = { - PIPE_FORMAT_R32_UNORM, - "PIPE_FORMAT_R32_UNORM", - "r32_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_unorm_unpack_rgba_8unorm, - &util_format_r32_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_unorm_unpack_rgba_float, - &util_format_r32_unorm_pack_rgba_float, - &util_format_r32_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_unorm_description = { - PIPE_FORMAT_R32G32_UNORM, - "PIPE_FORMAT_R32G32_UNORM", - "r32g32_unorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_unorm_unpack_rgba_8unorm, - &util_format_r32g32_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_unorm_unpack_rgba_float, - &util_format_r32g32_unorm_pack_rgba_float, - &util_format_r32g32_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_unorm_description = { - PIPE_FORMAT_R32G32B32_UNORM, - "PIPE_FORMAT_R32G32B32_UNORM", - "r32g32b32_unorm", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_unorm_unpack_rgba_8unorm, - &util_format_r32g32b32_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_unorm_unpack_rgba_float, - &util_format_r32g32b32_unorm_pack_rgba_float, - &util_format_r32g32b32_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_unorm_description = { - PIPE_FORMAT_R32G32B32A32_UNORM, - "PIPE_FORMAT_R32G32B32A32_UNORM", - "r32g32b32a32_unorm", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_unorm_unpack_rgba_8unorm, - &util_format_r32g32b32a32_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_unorm_unpack_rgba_float, - &util_format_r32g32b32a32_unorm_pack_rgba_float, - &util_format_r32g32b32a32_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_uscaled_description = { - PIPE_FORMAT_R32_USCALED, - "PIPE_FORMAT_R32_USCALED", - "r32_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_uscaled_unpack_rgba_8unorm, - &util_format_r32_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_uscaled_unpack_rgba_float, - &util_format_r32_uscaled_pack_rgba_float, - &util_format_r32_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_uscaled_description = { - PIPE_FORMAT_R32G32_USCALED, - "PIPE_FORMAT_R32G32_USCALED", - "r32g32_uscaled", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_uscaled_unpack_rgba_8unorm, - &util_format_r32g32_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_uscaled_unpack_rgba_float, - &util_format_r32g32_uscaled_pack_rgba_float, - &util_format_r32g32_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_uscaled_description = { - PIPE_FORMAT_R32G32B32_USCALED, - "PIPE_FORMAT_R32G32B32_USCALED", - "r32g32b32_uscaled", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_uscaled_unpack_rgba_8unorm, - &util_format_r32g32b32_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_uscaled_unpack_rgba_float, - &util_format_r32g32b32_uscaled_pack_rgba_float, - &util_format_r32g32b32_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_uscaled_description = { - PIPE_FORMAT_R32G32B32A32_USCALED, - "PIPE_FORMAT_R32G32B32A32_USCALED", - "r32g32b32a32_uscaled", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_uscaled_unpack_rgba_8unorm, - &util_format_r32g32b32a32_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_uscaled_unpack_rgba_float, - &util_format_r32g32b32a32_uscaled_pack_rgba_float, - &util_format_r32g32b32a32_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_snorm_description = { - PIPE_FORMAT_R32_SNORM, - "PIPE_FORMAT_R32_SNORM", - "r32_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_snorm_unpack_rgba_8unorm, - &util_format_r32_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_snorm_unpack_rgba_float, - &util_format_r32_snorm_pack_rgba_float, - &util_format_r32_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_snorm_description = { - PIPE_FORMAT_R32G32_SNORM, - "PIPE_FORMAT_R32G32_SNORM", - "r32g32_snorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_snorm_unpack_rgba_8unorm, - &util_format_r32g32_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_snorm_unpack_rgba_float, - &util_format_r32g32_snorm_pack_rgba_float, - &util_format_r32g32_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_snorm_description = { - PIPE_FORMAT_R32G32B32_SNORM, - "PIPE_FORMAT_R32G32B32_SNORM", - "r32g32b32_snorm", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_snorm_unpack_rgba_8unorm, - &util_format_r32g32b32_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_snorm_unpack_rgba_float, - &util_format_r32g32b32_snorm_pack_rgba_float, - &util_format_r32g32b32_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_snorm_description = { - PIPE_FORMAT_R32G32B32A32_SNORM, - "PIPE_FORMAT_R32G32B32A32_SNORM", - "r32g32b32a32_snorm", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_snorm_unpack_rgba_8unorm, - &util_format_r32g32b32a32_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_snorm_unpack_rgba_float, - &util_format_r32g32b32a32_snorm_pack_rgba_float, - &util_format_r32g32b32a32_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_sscaled_description = { - PIPE_FORMAT_R32_SSCALED, - "PIPE_FORMAT_R32_SSCALED", - "r32_sscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_sscaled_unpack_rgba_8unorm, - &util_format_r32_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_sscaled_unpack_rgba_float, - &util_format_r32_sscaled_pack_rgba_float, - &util_format_r32_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_sscaled_description = { - PIPE_FORMAT_R32G32_SSCALED, - "PIPE_FORMAT_R32G32_SSCALED", - "r32g32_sscaled", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_sscaled_unpack_rgba_8unorm, - &util_format_r32g32_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_sscaled_unpack_rgba_float, - &util_format_r32g32_sscaled_pack_rgba_float, - &util_format_r32g32_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_sscaled_description = { - PIPE_FORMAT_R32G32B32_SSCALED, - "PIPE_FORMAT_R32G32B32_SSCALED", - "r32g32b32_sscaled", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_sscaled_unpack_rgba_8unorm, - &util_format_r32g32b32_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_sscaled_unpack_rgba_float, - &util_format_r32g32b32_sscaled_pack_rgba_float, - &util_format_r32g32b32_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_sscaled_description = { - PIPE_FORMAT_R32G32B32A32_SSCALED, - "PIPE_FORMAT_R32G32B32A32_SSCALED", - "r32g32b32a32_sscaled", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_sscaled_unpack_rgba_8unorm, - &util_format_r32g32b32a32_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_sscaled_unpack_rgba_float, - &util_format_r32g32b32a32_sscaled_pack_rgba_float, - &util_format_r32g32b32a32_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_float_description = { - PIPE_FORMAT_R16_FLOAT, - "PIPE_FORMAT_R16_FLOAT", - "r16_float", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16_float_unpack_rgba_8unorm, - &util_format_r16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16_float_unpack_rgba_float, - &util_format_r16_float_pack_rgba_float, - &util_format_r16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_float_description = { - PIPE_FORMAT_R16G16_FLOAT, - "PIPE_FORMAT_R16G16_FLOAT", - "r16g16_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16_float_unpack_rgba_8unorm, - &util_format_r16g16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16_float_unpack_rgba_float, - &util_format_r16g16_float_pack_rgba_float, - &util_format_r16g16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_float_description = { - PIPE_FORMAT_R16G16B16_FLOAT, - "PIPE_FORMAT_R16G16B16_FLOAT", - "r16g16b16_float", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16_float_unpack_rgba_8unorm, - &util_format_r16g16b16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16_float_unpack_rgba_float, - &util_format_r16g16b16_float_pack_rgba_float, - &util_format_r16g16b16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_float_description = { - PIPE_FORMAT_R16G16B16A16_FLOAT, - "PIPE_FORMAT_R16G16B16A16_FLOAT", - "r16g16b16a16_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16a16_float_unpack_rgba_8unorm, - &util_format_r16g16b16a16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16a16_float_unpack_rgba_float, - &util_format_r16g16b16a16_float_pack_rgba_float, - &util_format_r16g16b16a16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_unorm_description = { - PIPE_FORMAT_R16_UNORM, - "PIPE_FORMAT_R16_UNORM", - "r16_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16_unorm_unpack_rgba_8unorm, - &util_format_r16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16_unorm_unpack_rgba_float, - &util_format_r16_unorm_pack_rgba_float, - &util_format_r16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_unorm_description = { - PIPE_FORMAT_R16G16_UNORM, - "PIPE_FORMAT_R16G16_UNORM", - "r16g16_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16_unorm_unpack_rgba_8unorm, - &util_format_r16g16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16_unorm_unpack_rgba_float, - &util_format_r16g16_unorm_pack_rgba_float, - &util_format_r16g16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_unorm_description = { - PIPE_FORMAT_R16G16B16_UNORM, - "PIPE_FORMAT_R16G16B16_UNORM", - "r16g16b16_unorm", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16_unorm_unpack_rgba_8unorm, - &util_format_r16g16b16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16_unorm_unpack_rgba_float, - &util_format_r16g16b16_unorm_pack_rgba_float, - &util_format_r16g16b16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_unorm_description = { - PIPE_FORMAT_R16G16B16A16_UNORM, - "PIPE_FORMAT_R16G16B16A16_UNORM", - "r16g16b16a16_unorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16a16_unorm_unpack_rgba_8unorm, - &util_format_r16g16b16a16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16a16_unorm_unpack_rgba_float, - &util_format_r16g16b16a16_unorm_pack_rgba_float, - &util_format_r16g16b16a16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_uscaled_description = { - PIPE_FORMAT_R16_USCALED, - "PIPE_FORMAT_R16_USCALED", - "r16_uscaled", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16_uscaled_unpack_rgba_8unorm, - &util_format_r16_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16_uscaled_unpack_rgba_float, - &util_format_r16_uscaled_pack_rgba_float, - &util_format_r16_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_uscaled_description = { - PIPE_FORMAT_R16G16_USCALED, - "PIPE_FORMAT_R16G16_USCALED", - "r16g16_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16_uscaled_unpack_rgba_8unorm, - &util_format_r16g16_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16_uscaled_unpack_rgba_float, - &util_format_r16g16_uscaled_pack_rgba_float, - &util_format_r16g16_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_uscaled_description = { - PIPE_FORMAT_R16G16B16_USCALED, - "PIPE_FORMAT_R16G16B16_USCALED", - "r16g16b16_uscaled", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16_uscaled_unpack_rgba_8unorm, - &util_format_r16g16b16_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16_uscaled_unpack_rgba_float, - &util_format_r16g16b16_uscaled_pack_rgba_float, - &util_format_r16g16b16_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_uscaled_description = { - PIPE_FORMAT_R16G16B16A16_USCALED, - "PIPE_FORMAT_R16G16B16A16_USCALED", - "r16g16b16a16_uscaled", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16a16_uscaled_unpack_rgba_8unorm, - &util_format_r16g16b16a16_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16a16_uscaled_unpack_rgba_float, - &util_format_r16g16b16a16_uscaled_pack_rgba_float, - &util_format_r16g16b16a16_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_snorm_description = { - PIPE_FORMAT_R16_SNORM, - "PIPE_FORMAT_R16_SNORM", - "r16_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16_snorm_unpack_rgba_8unorm, - &util_format_r16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16_snorm_unpack_rgba_float, - &util_format_r16_snorm_pack_rgba_float, - &util_format_r16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_snorm_description = { - PIPE_FORMAT_R16G16_SNORM, - "PIPE_FORMAT_R16G16_SNORM", - "r16g16_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16_snorm_unpack_rgba_8unorm, - &util_format_r16g16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16_snorm_unpack_rgba_float, - &util_format_r16g16_snorm_pack_rgba_float, - &util_format_r16g16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_snorm_description = { - PIPE_FORMAT_R16G16B16_SNORM, - "PIPE_FORMAT_R16G16B16_SNORM", - "r16g16b16_snorm", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16_snorm_unpack_rgba_8unorm, - &util_format_r16g16b16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16_snorm_unpack_rgba_float, - &util_format_r16g16b16_snorm_pack_rgba_float, - &util_format_r16g16b16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_snorm_description = { - PIPE_FORMAT_R16G16B16A16_SNORM, - "PIPE_FORMAT_R16G16B16A16_SNORM", - "r16g16b16a16_snorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16a16_snorm_unpack_rgba_8unorm, - &util_format_r16g16b16a16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16a16_snorm_unpack_rgba_float, - &util_format_r16g16b16a16_snorm_pack_rgba_float, - &util_format_r16g16b16a16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_sscaled_description = { - PIPE_FORMAT_R16_SSCALED, - "PIPE_FORMAT_R16_SSCALED", - "r16_sscaled", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16_sscaled_unpack_rgba_8unorm, - &util_format_r16_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16_sscaled_unpack_rgba_float, - &util_format_r16_sscaled_pack_rgba_float, - &util_format_r16_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_sscaled_description = { - PIPE_FORMAT_R16G16_SSCALED, - "PIPE_FORMAT_R16G16_SSCALED", - "r16g16_sscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16_sscaled_unpack_rgba_8unorm, - &util_format_r16g16_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16_sscaled_unpack_rgba_float, - &util_format_r16g16_sscaled_pack_rgba_float, - &util_format_r16g16_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_sscaled_description = { - PIPE_FORMAT_R16G16B16_SSCALED, - "PIPE_FORMAT_R16G16B16_SSCALED", - "r16g16b16_sscaled", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16_sscaled_unpack_rgba_8unorm, - &util_format_r16g16b16_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16_sscaled_unpack_rgba_float, - &util_format_r16g16b16_sscaled_pack_rgba_float, - &util_format_r16g16b16_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_sscaled_description = { - PIPE_FORMAT_R16G16B16A16_SSCALED, - "PIPE_FORMAT_R16G16B16A16_SSCALED", - "r16g16b16a16_sscaled", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16a16_sscaled_unpack_rgba_8unorm, - &util_format_r16g16b16a16_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16a16_sscaled_unpack_rgba_float, - &util_format_r16g16b16a16_sscaled_pack_rgba_float, - &util_format_r16g16b16a16_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_unorm_description = { - PIPE_FORMAT_R8_UNORM, - "PIPE_FORMAT_R8_UNORM", - "r8_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8_unorm_unpack_rgba_8unorm, - &util_format_r8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8_unorm_unpack_rgba_float, - &util_format_r8_unorm_pack_rgba_float, - &util_format_r8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_unorm_description = { - PIPE_FORMAT_R8G8_UNORM, - "PIPE_FORMAT_R8G8_UNORM", - "r8g8_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_unorm_unpack_rgba_8unorm, - &util_format_r8g8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_unorm_unpack_rgba_float, - &util_format_r8g8_unorm_pack_rgba_float, - &util_format_r8g8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_unorm_description = { - PIPE_FORMAT_R8G8B8_UNORM, - "PIPE_FORMAT_R8G8B8_UNORM", - "r8g8b8_unorm", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8_unorm_unpack_rgba_8unorm, - &util_format_r8g8b8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8_unorm_unpack_rgba_float, - &util_format_r8g8b8_unorm_pack_rgba_float, - &util_format_r8g8b8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_unorm_description = { - PIPE_FORMAT_R8G8B8A8_UNORM, - "PIPE_FORMAT_R8G8B8A8_UNORM", - "r8g8b8a8_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8a8_unorm_unpack_rgba_8unorm, - &util_format_r8g8b8a8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8a8_unorm_unpack_rgba_float, - &util_format_r8g8b8a8_unorm_pack_rgba_float, - &util_format_r8g8b8a8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_uscaled_description = { - PIPE_FORMAT_R8_USCALED, - "PIPE_FORMAT_R8_USCALED", - "r8_uscaled", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8_uscaled_unpack_rgba_8unorm, - &util_format_r8_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8_uscaled_unpack_rgba_float, - &util_format_r8_uscaled_pack_rgba_float, - &util_format_r8_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_uscaled_description = { - PIPE_FORMAT_R8G8_USCALED, - "PIPE_FORMAT_R8G8_USCALED", - "r8g8_uscaled", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_uscaled_unpack_rgba_8unorm, - &util_format_r8g8_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_uscaled_unpack_rgba_float, - &util_format_r8g8_uscaled_pack_rgba_float, - &util_format_r8g8_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_uscaled_description = { - PIPE_FORMAT_R8G8B8_USCALED, - "PIPE_FORMAT_R8G8B8_USCALED", - "r8g8b8_uscaled", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8_uscaled_unpack_rgba_8unorm, - &util_format_r8g8b8_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8_uscaled_unpack_rgba_float, - &util_format_r8g8b8_uscaled_pack_rgba_float, - &util_format_r8g8b8_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_uscaled_description = { - PIPE_FORMAT_R8G8B8A8_USCALED, - "PIPE_FORMAT_R8G8B8A8_USCALED", - "r8g8b8a8_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8a8_uscaled_unpack_rgba_8unorm, - &util_format_r8g8b8a8_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8a8_uscaled_unpack_rgba_float, - &util_format_r8g8b8a8_uscaled_pack_rgba_float, - &util_format_r8g8b8a8_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_snorm_description = { - PIPE_FORMAT_R8_SNORM, - "PIPE_FORMAT_R8_SNORM", - "r8_snorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8_snorm_unpack_rgba_8unorm, - &util_format_r8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8_snorm_unpack_rgba_float, - &util_format_r8_snorm_pack_rgba_float, - &util_format_r8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_snorm_description = { - PIPE_FORMAT_R8G8_SNORM, - "PIPE_FORMAT_R8G8_SNORM", - "r8g8_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_snorm_unpack_rgba_8unorm, - &util_format_r8g8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_snorm_unpack_rgba_float, - &util_format_r8g8_snorm_pack_rgba_float, - &util_format_r8g8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_snorm_description = { - PIPE_FORMAT_R8G8B8_SNORM, - "PIPE_FORMAT_R8G8B8_SNORM", - "r8g8b8_snorm", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8_snorm_unpack_rgba_8unorm, - &util_format_r8g8b8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8_snorm_unpack_rgba_float, - &util_format_r8g8b8_snorm_pack_rgba_float, - &util_format_r8g8b8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_snorm_description = { - PIPE_FORMAT_R8G8B8A8_SNORM, - "PIPE_FORMAT_R8G8B8A8_SNORM", - "r8g8b8a8_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8a8_snorm_unpack_rgba_8unorm, - &util_format_r8g8b8a8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8a8_snorm_unpack_rgba_float, - &util_format_r8g8b8a8_snorm_pack_rgba_float, - &util_format_r8g8b8a8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_sscaled_description = { - PIPE_FORMAT_R8_SSCALED, - "PIPE_FORMAT_R8_SSCALED", - "r8_sscaled", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8_sscaled_unpack_rgba_8unorm, - &util_format_r8_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8_sscaled_unpack_rgba_float, - &util_format_r8_sscaled_pack_rgba_float, - &util_format_r8_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_sscaled_description = { - PIPE_FORMAT_R8G8_SSCALED, - "PIPE_FORMAT_R8G8_SSCALED", - "r8g8_sscaled", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8_sscaled_unpack_rgba_8unorm, - &util_format_r8g8_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8_sscaled_unpack_rgba_float, - &util_format_r8g8_sscaled_pack_rgba_float, - &util_format_r8g8_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_sscaled_description = { - PIPE_FORMAT_R8G8B8_SSCALED, - "PIPE_FORMAT_R8G8B8_SSCALED", - "r8g8b8_sscaled", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8_sscaled_unpack_rgba_8unorm, - &util_format_r8g8b8_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8_sscaled_unpack_rgba_float, - &util_format_r8g8b8_sscaled_pack_rgba_float, - &util_format_r8g8b8_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_sscaled_description = { - PIPE_FORMAT_R8G8B8A8_SSCALED, - "PIPE_FORMAT_R8G8B8A8_SSCALED", - "r8g8b8a8_sscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8a8_sscaled_unpack_rgba_8unorm, - &util_format_r8g8b8a8_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8a8_sscaled_unpack_rgba_float, - &util_format_r8g8b8a8_sscaled_pack_rgba_float, - &util_format_r8g8b8a8_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_fixed_description = { - PIPE_FORMAT_R32_FIXED, - "PIPE_FORMAT_R32_FIXED", - "r32_fixed", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32_fixed_unpack_rgba_8unorm, - &util_format_r32_fixed_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32_fixed_unpack_rgba_float, - &util_format_r32_fixed_pack_rgba_float, - &util_format_r32_fixed_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_fixed_description = { - PIPE_FORMAT_R32G32_FIXED, - "PIPE_FORMAT_R32G32_FIXED", - "r32g32_fixed", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32_fixed_unpack_rgba_8unorm, - &util_format_r32g32_fixed_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32_fixed_unpack_rgba_float, - &util_format_r32g32_fixed_pack_rgba_float, - &util_format_r32g32_fixed_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_fixed_description = { - PIPE_FORMAT_R32G32B32_FIXED, - "PIPE_FORMAT_R32G32B32_FIXED", - "r32g32b32_fixed", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32_fixed_unpack_rgba_8unorm, - &util_format_r32g32b32_fixed_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32_fixed_unpack_rgba_float, - &util_format_r32g32b32_fixed_pack_rgba_float, - &util_format_r32g32b32_fixed_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_fixed_description = { - PIPE_FORMAT_R32G32B32A32_FIXED, - "PIPE_FORMAT_R32G32B32A32_FIXED", - "r32g32b32a32_fixed", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_FIXED, FALSE, FALSE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32a32_fixed_unpack_rgba_8unorm, - &util_format_r32g32b32a32_fixed_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32a32_fixed_unpack_rgba_float, - &util_format_r32g32b32a32_fixed_pack_rgba_float, - &util_format_r32g32b32a32_fixed_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10x2_uscaled_description = { - PIPE_FORMAT_R10G10B10X2_USCALED, - "PIPE_FORMAT_R10G10B10X2_USCALED", - "r10g10b10x2_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10x2_uscaled_unpack_rgba_8unorm, - &util_format_r10g10b10x2_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10x2_uscaled_unpack_rgba_float, - &util_format_r10g10b10x2_uscaled_pack_rgba_float, - &util_format_r10g10b10x2_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10x2_snorm_description = { - PIPE_FORMAT_R10G10B10X2_SNORM, - "PIPE_FORMAT_R10G10B10X2_SNORM", - "r10g10b10x2_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10x2_snorm_unpack_rgba_8unorm, - &util_format_r10g10b10x2_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10x2_snorm_unpack_rgba_float, - &util_format_r10g10b10x2_snorm_pack_rgba_float, - &util_format_r10g10b10x2_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_yv12_description = { - PIPE_FORMAT_YV12, - "PIPE_FORMAT_YV12", - "yv12", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 4, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_W /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_yv12_unpack_rgba_8unorm, - &util_format_yv12_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_yv12_unpack_rgba_float, - &util_format_yv12_pack_rgba_float, - &util_format_yv12_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_yv16_description = { - PIPE_FORMAT_YV16, - "PIPE_FORMAT_YV16", - "yv16", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 4, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_W /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_yv16_unpack_rgba_8unorm, - &util_format_yv16_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_yv16_unpack_rgba_float, - &util_format_yv16_pack_rgba_float, - &util_format_yv16_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_iyuv_description = { - PIPE_FORMAT_IYUV, - "PIPE_FORMAT_IYUV", - "iyuv", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 4, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_W /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_iyuv_unpack_rgba_8unorm, - &util_format_iyuv_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_iyuv_unpack_rgba_float, - &util_format_iyuv_pack_rgba_float, - &util_format_iyuv_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_nv12_description = { - PIPE_FORMAT_NV12, - "PIPE_FORMAT_NV12", - "nv12", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 4, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_W /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_nv12_unpack_rgba_8unorm, - &util_format_nv12_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_nv12_unpack_rgba_float, - &util_format_nv12_pack_rgba_float, - &util_format_nv12_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_nv21_description = { - PIPE_FORMAT_NV21, - "PIPE_FORMAT_NV21", - "nv21", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_OTHER, - 4, /* nr_channels */ - FALSE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 0}, /* x = x */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 8}, /* y = y */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 16}, /* z = z */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = w */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* y */ - UTIL_FORMAT_SWIZZLE_Y, /* u */ - UTIL_FORMAT_SWIZZLE_Z, /* v */ - UTIL_FORMAT_SWIZZLE_W /* ignored */ - }, - UTIL_FORMAT_COLORSPACE_YUV, - &util_format_nv21_unpack_rgba_8unorm, - &util_format_nv21_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_nv21_unpack_rgba_float, - &util_format_nv21_pack_rgba_float, - &util_format_nv21_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r4a4_unorm_description = { - PIPE_FORMAT_R4A4_UNORM, - "PIPE_FORMAT_R4A4_UNORM", - "r4a4_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r4a4_unorm_unpack_rgba_8unorm, - &util_format_r4a4_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r4a4_unorm_unpack_rgba_float, - &util_format_r4a4_unorm_pack_rgba_float, - &util_format_r4a4_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a4r4_unorm_description = { - PIPE_FORMAT_A4R4_UNORM, - "PIPE_FORMAT_A4R4_UNORM", - "a4r4_unorm", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 4, 4}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a4r4_unorm_unpack_rgba_8unorm, - &util_format_a4r4_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a4r4_unorm_unpack_rgba_float, - &util_format_a4r4_unorm_pack_rgba_float, - &util_format_a4r4_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8a8_unorm_description = { - PIPE_FORMAT_R8A8_UNORM, - "PIPE_FORMAT_R8A8_UNORM", - "r8a8_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8a8_unorm_unpack_rgba_8unorm, - &util_format_r8a8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8a8_unorm_unpack_rgba_float, - &util_format_r8a8_unorm_pack_rgba_float, - &util_format_r8a8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8r8_unorm_description = { - PIPE_FORMAT_A8R8_UNORM, - "PIPE_FORMAT_A8R8_UNORM", - "a8r8_unorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = a */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_Y, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_a8r8_unorm_unpack_rgba_8unorm, - &util_format_a8r8_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_a8r8_unorm_unpack_rgba_float, - &util_format_a8r8_unorm_pack_rgba_float, - &util_format_a8r8_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10a2_uscaled_description = { - PIPE_FORMAT_R10G10B10A2_USCALED, - "PIPE_FORMAT_R10G10B10A2_USCALED", - "r10g10b10a2_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10a2_uscaled_unpack_rgba_8unorm, - &util_format_r10g10b10a2_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10a2_uscaled_unpack_rgba_float, - &util_format_r10g10b10a2_uscaled_pack_rgba_float, - &util_format_r10g10b10a2_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10a2_sscaled_description = { - PIPE_FORMAT_R10G10B10A2_SSCALED, - "PIPE_FORMAT_R10G10B10A2_SSCALED", - "r10g10b10a2_sscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10a2_sscaled_unpack_rgba_8unorm, - &util_format_r10g10b10a2_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10a2_sscaled_unpack_rgba_float, - &util_format_r10g10b10a2_sscaled_pack_rgba_float, - &util_format_r10g10b10a2_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10a2_snorm_description = { - PIPE_FORMAT_R10G10B10A2_SNORM, - "PIPE_FORMAT_R10G10B10A2_SNORM", - "r10g10b10a2_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r10g10b10a2_snorm_unpack_rgba_8unorm, - &util_format_r10g10b10a2_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r10g10b10a2_snorm_unpack_rgba_float, - &util_format_r10g10b10a2_snorm_pack_rgba_float, - &util_format_r10g10b10a2_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10a2_uscaled_description = { - PIPE_FORMAT_B10G10R10A2_USCALED, - "PIPE_FORMAT_B10G10R10A2_USCALED", - "b10g10r10a2_uscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b10g10r10a2_uscaled_unpack_rgba_8unorm, - &util_format_b10g10r10a2_uscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b10g10r10a2_uscaled_unpack_rgba_float, - &util_format_b10g10r10a2_uscaled_pack_rgba_float, - &util_format_b10g10r10a2_uscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10a2_sscaled_description = { - PIPE_FORMAT_B10G10R10A2_SSCALED, - "PIPE_FORMAT_B10G10R10A2_SSCALED", - "b10g10r10a2_sscaled", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b10g10r10a2_sscaled_unpack_rgba_8unorm, - &util_format_b10g10r10a2_sscaled_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b10g10r10a2_sscaled_unpack_rgba_float, - &util_format_b10g10r10a2_sscaled_pack_rgba_float, - &util_format_b10g10r10a2_sscaled_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10a2_snorm_description = { - PIPE_FORMAT_B10G10R10A2_SNORM, - "PIPE_FORMAT_B10G10R10A2_SNORM", - "b10g10r10a2_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b10g10r10a2_snorm_unpack_rgba_8unorm, - &util_format_b10g10r10a2_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b10g10r10a2_snorm_unpack_rgba_float, - &util_format_b10g10r10a2_snorm_pack_rgba_float, - &util_format_b10g10r10a2_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_uint_description = { - PIPE_FORMAT_R8_UINT, - "PIPE_FORMAT_R8_UINT", - "r8_uint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_uint_description = { - PIPE_FORMAT_R8G8_UINT, - "PIPE_FORMAT_R8G8_UINT", - "r8g8_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8g8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_uint_description = { - PIPE_FORMAT_R8G8B8_UINT, - "PIPE_FORMAT_R8G8B8_UINT", - "r8g8b8_uint", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8g8b8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_uint_description = { - PIPE_FORMAT_R8G8B8A8_UINT, - "PIPE_FORMAT_R8G8B8A8_UINT", - "r8g8b8a8_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8a8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8a8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8a8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8a8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8g8b8a8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8_sint_description = { - PIPE_FORMAT_R8_SINT, - "PIPE_FORMAT_R8_SINT", - "r8_sint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8_sint_description = { - PIPE_FORMAT_R8G8_SINT, - "PIPE_FORMAT_R8G8_SINT", - "r8g8_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8g8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8_sint_description = { - PIPE_FORMAT_R8G8B8_SINT, - "PIPE_FORMAT_R8G8B8_SINT", - "r8g8b8_sint", - {1, 1, 24}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8g8b8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8a8_sint_description = { - PIPE_FORMAT_R8G8B8A8_SINT, - "PIPE_FORMAT_R8G8B8A8_SINT", - "r8g8b8a8_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 24} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8a8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8a8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8a8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8a8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8g8b8a8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_uint_description = { - PIPE_FORMAT_R16_UINT, - "PIPE_FORMAT_R16_UINT", - "r16_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_uint_description = { - PIPE_FORMAT_R16G16_UINT, - "PIPE_FORMAT_R16G16_UINT", - "r16g16_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16g16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_uint_description = { - PIPE_FORMAT_R16G16B16_UINT, - "PIPE_FORMAT_R16G16B16_UINT", - "r16g16b16_uint", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16g16b16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_uint_description = { - PIPE_FORMAT_R16G16B16A16_UINT, - "PIPE_FORMAT_R16G16B16A16_UINT", - "r16g16b16a16_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16a16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16a16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16a16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16a16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16g16b16a16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16_sint_description = { - PIPE_FORMAT_R16_SINT, - "PIPE_FORMAT_R16_SINT", - "r16_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16_sint_description = { - PIPE_FORMAT_R16G16_SINT, - "PIPE_FORMAT_R16G16_SINT", - "r16g16_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16g16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16_sint_description = { - PIPE_FORMAT_R16G16B16_SINT, - "PIPE_FORMAT_R16G16B16_SINT", - "r16g16b16_sint", - {1, 1, 48}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16g16b16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16a16_sint_description = { - PIPE_FORMAT_R16G16B16A16_SINT, - "PIPE_FORMAT_R16G16B16A16_SINT", - "r16g16b16a16_sint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 48} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16a16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16a16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16a16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16a16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16g16b16a16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_uint_description = { - PIPE_FORMAT_R32_UINT, - "PIPE_FORMAT_R32_UINT", - "r32_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_uint_description = { - PIPE_FORMAT_R32G32_UINT, - "PIPE_FORMAT_R32G32_UINT", - "r32g32_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32g32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_uint_description = { - PIPE_FORMAT_R32G32B32_UINT, - "PIPE_FORMAT_R32G32B32_UINT", - "r32g32b32_uint", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32g32b32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_uint_description = { - PIPE_FORMAT_R32G32B32A32_UINT, - "PIPE_FORMAT_R32G32B32A32_UINT", - "r32g32b32a32_uint", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32a32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32a32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32a32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32a32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32g32b32a32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32_sint_description = { - PIPE_FORMAT_R32_SINT, - "PIPE_FORMAT_R32_SINT", - "r32_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32_sint_description = { - PIPE_FORMAT_R32G32_SINT, - "PIPE_FORMAT_R32G32_SINT", - "r32g32_sint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32g32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32_sint_description = { - PIPE_FORMAT_R32G32B32_SINT, - "PIPE_FORMAT_R32G32B32_SINT", - "r32g32b32_sint", - {1, 1, 96}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 3, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32g32b32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32a32_sint_description = { - PIPE_FORMAT_R32G32B32A32_SINT, - "PIPE_FORMAT_R32G32B32A32_SINT", - "r32g32b32a32_sint", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 96} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32a32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32a32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32a32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32a32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32g32b32a32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8_uint_description = { - PIPE_FORMAT_A8_UINT, - "PIPE_FORMAT_A8_UINT", - "a8_uint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_a8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i8_uint_description = { - PIPE_FORMAT_I8_UINT, - "PIPE_FORMAT_I8_UINT", - "i8_uint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_i8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8_uint_description = { - PIPE_FORMAT_L8_UINT, - "PIPE_FORMAT_L8_UINT", - "l8_uint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8a8_uint_description = { - PIPE_FORMAT_L8A8_UINT, - "PIPE_FORMAT_L8A8_UINT", - "l8a8_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l8a8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l8a8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l8a8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l8a8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l8a8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a8_sint_description = { - PIPE_FORMAT_A8_SINT, - "PIPE_FORMAT_A8_SINT", - "a8_sint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_a8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i8_sint_description = { - PIPE_FORMAT_I8_SINT, - "PIPE_FORMAT_I8_SINT", - "i8_sint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_i8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8_sint_description = { - PIPE_FORMAT_L8_SINT, - "PIPE_FORMAT_L8_SINT", - "l8_sint", - {1, 1, 8}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l8a8_sint_description = { - PIPE_FORMAT_L8A8_SINT, - "PIPE_FORMAT_L8A8_SINT", - "l8a8_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l8a8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l8a8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l8a8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l8a8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l8a8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a16_uint_description = { - PIPE_FORMAT_A16_UINT, - "PIPE_FORMAT_A16_UINT", - "a16_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_a16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i16_uint_description = { - PIPE_FORMAT_I16_UINT, - "PIPE_FORMAT_I16_UINT", - "i16_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_i16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16_uint_description = { - PIPE_FORMAT_L16_UINT, - "PIPE_FORMAT_L16_UINT", - "l16_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16a16_uint_description = { - PIPE_FORMAT_L16A16_UINT, - "PIPE_FORMAT_L16A16_UINT", - "l16a16_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l16a16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l16a16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l16a16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l16a16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l16a16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a16_sint_description = { - PIPE_FORMAT_A16_SINT, - "PIPE_FORMAT_A16_SINT", - "a16_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_a16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i16_sint_description = { - PIPE_FORMAT_I16_SINT, - "PIPE_FORMAT_I16_SINT", - "i16_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_i16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16_sint_description = { - PIPE_FORMAT_L16_SINT, - "PIPE_FORMAT_L16_SINT", - "l16_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l16a16_sint_description = { - PIPE_FORMAT_L16A16_SINT, - "PIPE_FORMAT_L16A16_SINT", - "l16a16_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l16a16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l16a16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l16a16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l16a16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l16a16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a32_uint_description = { - PIPE_FORMAT_A32_UINT, - "PIPE_FORMAT_A32_UINT", - "a32_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_a32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i32_uint_description = { - PIPE_FORMAT_I32_UINT, - "PIPE_FORMAT_I32_UINT", - "i32_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_i32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32_uint_description = { - PIPE_FORMAT_L32_UINT, - "PIPE_FORMAT_L32_UINT", - "l32_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32a32_uint_description = { - PIPE_FORMAT_L32A32_UINT, - "PIPE_FORMAT_L32A32_UINT", - "l32a32_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l32a32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l32a32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l32a32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l32a32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_l32a32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_a32_sint_description = { - PIPE_FORMAT_A32_SINT, - "PIPE_FORMAT_A32_SINT", - "a32_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_0, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_a32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_a32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_a32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_a32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_a32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_i32_sint_description = { - PIPE_FORMAT_I32_SINT, - "PIPE_FORMAT_I32_SINT", - "i32_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgba */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_X /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_i32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_i32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_i32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_i32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_i32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32_sint_description = { - PIPE_FORMAT_L32_SINT, - "PIPE_FORMAT_L32_SINT", - "l32_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 1, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_l32a32_sint_description = { - PIPE_FORMAT_L32A32_SINT, - "PIPE_FORMAT_L32A32_SINT", - "l32a32_sint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = rgb */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_X, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_l32a32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_l32a32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_l32a32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_l32a32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_l32a32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10a2_uint_description = { - PIPE_FORMAT_B10G10R10A2_UINT, - "PIPE_FORMAT_B10G10R10A2_UINT", - "b10g10r10a2_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_b10g10r10a2_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_b10g10r10a2_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_b10g10r10a2_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_b10g10r10a2_uint_pack_signed, /* pack_rgba_sint */ - &util_format_b10g10r10a2_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8x8_snorm_description = { - PIPE_FORMAT_R8G8B8X8_SNORM, - "PIPE_FORMAT_R8G8B8X8_SNORM", - "r8g8b8x8_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8g8b8x8_snorm_unpack_rgba_8unorm, - &util_format_r8g8b8x8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8x8_snorm_unpack_rgba_float, - &util_format_r8g8b8x8_snorm_pack_rgba_float, - &util_format_r8g8b8x8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8x8_srgb_description = { - PIPE_FORMAT_R8G8B8X8_SRGB, - "PIPE_FORMAT_R8G8B8X8_SRGB", - "r8g8b8x8_srgb", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* sr */ - UTIL_FORMAT_SWIZZLE_Y, /* sg */ - UTIL_FORMAT_SWIZZLE_Z, /* sb */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_SRGB, - &util_format_r8g8b8x8_srgb_unpack_rgba_8unorm, - &util_format_r8g8b8x8_srgb_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8g8b8x8_srgb_unpack_rgba_float, - &util_format_r8g8b8x8_srgb_pack_rgba_float, - &util_format_r8g8b8x8_srgb_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8x8_uint_description = { - PIPE_FORMAT_R8G8B8X8_UINT, - "PIPE_FORMAT_R8G8B8X8_UINT", - "r8g8b8x8_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8x8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8x8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8x8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8x8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8g8b8x8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8g8b8x8_sint_description = { - PIPE_FORMAT_R8G8B8X8_SINT, - "PIPE_FORMAT_R8G8B8X8_SINT", - "r8g8b8x8_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 16}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 8, 24} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8g8b8x8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8g8b8x8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8g8b8x8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8g8b8x8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8g8b8x8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_b10g10r10x2_unorm_description = { - PIPE_FORMAT_B10G10R10X2_UNORM, - "PIPE_FORMAT_B10G10R10X2_UNORM", - "b10g10r10x2_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 0}, /* x = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 10, 20}, /* z = r */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 2, 30} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_Z, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_X, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_b10g10r10x2_unorm_unpack_rgba_8unorm, - &util_format_b10g10r10x2_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_b10g10r10x2_unorm_unpack_rgba_float, - &util_format_b10g10r10x2_unorm_pack_rgba_float, - &util_format_b10g10r10x2_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16x16_unorm_description = { - PIPE_FORMAT_R16G16B16X16_UNORM, - "PIPE_FORMAT_R16G16B16X16_UNORM", - "r16g16b16x16_unorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16x16_unorm_unpack_rgba_8unorm, - &util_format_r16g16b16x16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16x16_unorm_unpack_rgba_float, - &util_format_r16g16b16x16_unorm_pack_rgba_float, - &util_format_r16g16b16x16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16x16_snorm_description = { - PIPE_FORMAT_R16G16B16X16_SNORM, - "PIPE_FORMAT_R16G16B16X16_SNORM", - "r16g16b16x16_snorm", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16x16_snorm_unpack_rgba_8unorm, - &util_format_r16g16b16x16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16x16_snorm_unpack_rgba_float, - &util_format_r16g16b16x16_snorm_pack_rgba_float, - &util_format_r16g16b16x16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16x16_float_description = { - PIPE_FORMAT_R16G16B16X16_FLOAT, - "PIPE_FORMAT_R16G16B16X16_FLOAT", - "r16g16b16x16_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16g16b16x16_float_unpack_rgba_8unorm, - &util_format_r16g16b16x16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16g16b16x16_float_unpack_rgba_float, - &util_format_r16g16b16x16_float_pack_rgba_float, - &util_format_r16g16b16x16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16x16_uint_description = { - PIPE_FORMAT_R16G16B16X16_UINT, - "PIPE_FORMAT_R16G16B16X16_UINT", - "r16g16b16x16_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16x16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16x16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16x16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16x16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16g16b16x16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16g16b16x16_sint_description = { - PIPE_FORMAT_R16G16B16X16_SINT, - "PIPE_FORMAT_R16G16B16X16_SINT", - "r16g16b16x16_sint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 32}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 16, 48} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16g16b16x16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16g16b16x16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16g16b16x16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16g16b16x16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16g16b16x16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32x32_float_description = { - PIPE_FORMAT_R32G32B32X32_FLOAT, - "PIPE_FORMAT_R32G32B32X32_FLOAT", - "r32g32b32x32_float", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32g32b32x32_float_unpack_rgba_8unorm, - &util_format_r32g32b32x32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32g32b32x32_float_unpack_rgba_float, - &util_format_r32g32b32x32_float_pack_rgba_float, - &util_format_r32g32b32x32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32x32_uint_description = { - PIPE_FORMAT_R32G32B32X32_UINT, - "PIPE_FORMAT_R32G32B32X32_UINT", - "r32g32b32x32_uint", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32x32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32x32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32x32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32x32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32g32b32x32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32g32b32x32_sint_description = { - PIPE_FORMAT_R32G32B32X32_SINT, - "PIPE_FORMAT_R32G32B32X32_SINT", - "r32g32b32x32_sint", - {1, 1, 128}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = g */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 64}, /* z = b */ - {UTIL_FORMAT_TYPE_VOID, FALSE, FALSE, 32, 96} /* w = x */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_1 /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32g32b32x32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32g32b32x32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32g32b32x32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32g32b32x32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32g32b32x32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8a8_snorm_description = { - PIPE_FORMAT_R8A8_SNORM, - "PIPE_FORMAT_R8A8_SNORM", - "r8a8_snorm", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r8a8_snorm_unpack_rgba_8unorm, - &util_format_r8a8_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r8a8_snorm_unpack_rgba_float, - &util_format_r8a8_snorm_pack_rgba_float, - &util_format_r8a8_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16a16_unorm_description = { - PIPE_FORMAT_R16A16_UNORM, - "PIPE_FORMAT_R16A16_UNORM", - "r16a16_unorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16a16_unorm_unpack_rgba_8unorm, - &util_format_r16a16_unorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16a16_unorm_unpack_rgba_float, - &util_format_r16a16_unorm_pack_rgba_float, - &util_format_r16a16_unorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16a16_snorm_description = { - PIPE_FORMAT_R16A16_SNORM, - "PIPE_FORMAT_R16A16_SNORM", - "r16a16_snorm", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, TRUE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16a16_snorm_unpack_rgba_8unorm, - &util_format_r16a16_snorm_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16a16_snorm_unpack_rgba_float, - &util_format_r16a16_snorm_pack_rgba_float, - &util_format_r16a16_snorm_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16a16_float_description = { - PIPE_FORMAT_R16A16_FLOAT, - "PIPE_FORMAT_R16A16_FLOAT", - "r16a16_float", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r16a16_float_unpack_rgba_8unorm, - &util_format_r16a16_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r16a16_float_unpack_rgba_float, - &util_format_r16a16_float_pack_rgba_float, - &util_format_r16a16_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32a32_float_description = { - PIPE_FORMAT_R32A32_FLOAT, - "PIPE_FORMAT_R32A32_FLOAT", - "r32a32_float", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_FLOAT, FALSE, FALSE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - &util_format_r32a32_float_unpack_rgba_8unorm, - &util_format_r32a32_float_pack_rgba_8unorm, - NULL, /* fetch_rgba_8unorm */ - &util_format_r32a32_float_unpack_rgba_float, - &util_format_r32a32_float_pack_rgba_float, - &util_format_r32a32_float_fetch_rgba_float, - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - NULL, /* unpack_rgba_uint */ - NULL, /* pack_rgba_uint */ - NULL, /* unpack_rgba_sint */ - NULL, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8a8_uint_description = { - PIPE_FORMAT_R8A8_UINT, - "PIPE_FORMAT_R8A8_UINT", - "r8a8_uint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8a8_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8a8_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8a8_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8a8_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r8a8_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r8a8_sint_description = { - PIPE_FORMAT_R8A8_SINT, - "PIPE_FORMAT_R8A8_SINT", - "r8a8_sint", - {1, 1, 16}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 8, 8}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r8a8_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r8a8_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r8a8_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r8a8_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r8a8_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16a16_uint_description = { - PIPE_FORMAT_R16A16_UINT, - "PIPE_FORMAT_R16A16_UINT", - "r16a16_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16a16_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16a16_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16a16_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16a16_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r16a16_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r16a16_sint_description = { - PIPE_FORMAT_R16A16_SINT, - "PIPE_FORMAT_R16A16_SINT", - "r16a16_sint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 16, 16}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r16a16_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r16a16_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r16a16_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r16a16_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r16a16_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32a32_uint_description = { - PIPE_FORMAT_R32A32_UINT, - "PIPE_FORMAT_R32A32_UINT", - "r32a32_uint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32a32_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32a32_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32a32_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32a32_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r32a32_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r32a32_sint_description = { - PIPE_FORMAT_R32A32_SINT, - "PIPE_FORMAT_R32A32_SINT", - "r32a32_sint", - {1, 1, 64}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 2, /* nr_channels */ - TRUE, /* is_array */ - FALSE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_SIGNED, FALSE, TRUE, 32, 32}, /* y = a */ - {0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0} - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_0, /* g */ - UTIL_FORMAT_SWIZZLE_0, /* b */ - UTIL_FORMAT_SWIZZLE_Y /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r32a32_sint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r32a32_sint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r32a32_sint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r32a32_sint_pack_signed, /* pack_rgba_sint */ - NULL, /* fetch_rgba_uint */ - &util_format_r32a32_sint_fetch_signed /* fetch_rgba_sint */ -}; - -const struct util_format_description -util_format_r10g10b10a2_uint_description = { - PIPE_FORMAT_R10G10B10A2_UINT, - "PIPE_FORMAT_R10G10B10A2_UINT", - "r10g10b10a2_uint", - {1, 1, 32}, /* block */ - UTIL_FORMAT_LAYOUT_PLAIN, - 4, /* nr_channels */ - FALSE, /* is_array */ - TRUE, /* is_bitmask */ - FALSE, /* is_mixed */ - { - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 0}, /* x = r */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 10}, /* y = g */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 10, 20}, /* z = b */ - {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, TRUE, 2, 30} /* w = a */ - }, - { - UTIL_FORMAT_SWIZZLE_X, /* r */ - UTIL_FORMAT_SWIZZLE_Y, /* g */ - UTIL_FORMAT_SWIZZLE_Z, /* b */ - UTIL_FORMAT_SWIZZLE_W /* a */ - }, - UTIL_FORMAT_COLORSPACE_RGB, - NULL, /* unpack_rgba_8unorm */ - NULL, /* pack_rgba_8unorm */ - NULL, /* fetch_rgba_8unorm */ - NULL, /* unpack_rgba_float */ - NULL, /* pack_rgba_float */ - NULL, /* fetch_rgba_float */ - NULL, /* unpack_z_32unorm */ - NULL, /* pack_z_32unorm */ - NULL, /* unpack_z_float */ - NULL, /* pack_z_float */ - NULL, /* unpack_s_8uint */ - NULL, /* pack_s_8uint */ - &util_format_r10g10b10a2_uint_unpack_unsigned, /* unpack_rgba_uint */ - &util_format_r10g10b10a2_uint_pack_unsigned, /* pack_rgba_uint */ - &util_format_r10g10b10a2_uint_unpack_signed, /* unpack_rgba_sint */ - &util_format_r10g10b10a2_uint_pack_signed, /* pack_rgba_sint */ - &util_format_r10g10b10a2_uint_fetch_unsigned, /* fetch_rgba_uint */ - NULL /* fetch_rgba_sint */ -}; - -const struct util_format_description * -util_format_description(enum pipe_format format) -{ - if (format >= PIPE_FORMAT_COUNT) { - return NULL; - } - - switch (format) { - case PIPE_FORMAT_NONE: - return &util_format_none_description; - case PIPE_FORMAT_B8G8R8A8_UNORM: - return &util_format_b8g8r8a8_unorm_description; - case PIPE_FORMAT_B8G8R8X8_UNORM: - return &util_format_b8g8r8x8_unorm_description; - case PIPE_FORMAT_A8R8G8B8_UNORM: - return &util_format_a8r8g8b8_unorm_description; - case PIPE_FORMAT_X8R8G8B8_UNORM: - return &util_format_x8r8g8b8_unorm_description; - case PIPE_FORMAT_A8B8G8R8_UNORM: - return &util_format_a8b8g8r8_unorm_description; - case PIPE_FORMAT_X8B8G8R8_UNORM: - return &util_format_x8b8g8r8_unorm_description; - case PIPE_FORMAT_R8G8B8X8_UNORM: - return &util_format_r8g8b8x8_unorm_description; - case PIPE_FORMAT_B5G5R5X1_UNORM: - return &util_format_b5g5r5x1_unorm_description; - case PIPE_FORMAT_B5G5R5A1_UNORM: - return &util_format_b5g5r5a1_unorm_description; - case PIPE_FORMAT_B4G4R4A4_UNORM: - return &util_format_b4g4r4a4_unorm_description; - case PIPE_FORMAT_B4G4R4X4_UNORM: - return &util_format_b4g4r4x4_unorm_description; - case PIPE_FORMAT_B5G6R5_UNORM: - return &util_format_b5g6r5_unorm_description; - case PIPE_FORMAT_R10G10B10A2_UNORM: - return &util_format_r10g10b10a2_unorm_description; - case PIPE_FORMAT_B10G10R10A2_UNORM: - return &util_format_b10g10r10a2_unorm_description; - case PIPE_FORMAT_B2G3R3_UNORM: - return &util_format_b2g3r3_unorm_description; - case PIPE_FORMAT_L8_UNORM: - return &util_format_l8_unorm_description; - case PIPE_FORMAT_A8_UNORM: - return &util_format_a8_unorm_description; - case PIPE_FORMAT_I8_UNORM: - return &util_format_i8_unorm_description; - case PIPE_FORMAT_L4A4_UNORM: - return &util_format_l4a4_unorm_description; - case PIPE_FORMAT_L8A8_UNORM: - return &util_format_l8a8_unorm_description; - case PIPE_FORMAT_L16_UNORM: - return &util_format_l16_unorm_description; - case PIPE_FORMAT_A16_UNORM: - return &util_format_a16_unorm_description; - case PIPE_FORMAT_I16_UNORM: - return &util_format_i16_unorm_description; - case PIPE_FORMAT_L16A16_UNORM: - return &util_format_l16a16_unorm_description; - case PIPE_FORMAT_A8_SNORM: - return &util_format_a8_snorm_description; - case PIPE_FORMAT_L8_SNORM: - return &util_format_l8_snorm_description; - case PIPE_FORMAT_L8A8_SNORM: - return &util_format_l8a8_snorm_description; - case PIPE_FORMAT_I8_SNORM: - return &util_format_i8_snorm_description; - case PIPE_FORMAT_A16_SNORM: - return &util_format_a16_snorm_description; - case PIPE_FORMAT_L16_SNORM: - return &util_format_l16_snorm_description; - case PIPE_FORMAT_L16A16_SNORM: - return &util_format_l16a16_snorm_description; - case PIPE_FORMAT_I16_SNORM: - return &util_format_i16_snorm_description; - case PIPE_FORMAT_A16_FLOAT: - return &util_format_a16_float_description; - case PIPE_FORMAT_L16_FLOAT: - return &util_format_l16_float_description; - case PIPE_FORMAT_L16A16_FLOAT: - return &util_format_l16a16_float_description; - case PIPE_FORMAT_I16_FLOAT: - return &util_format_i16_float_description; - case PIPE_FORMAT_A32_FLOAT: - return &util_format_a32_float_description; - case PIPE_FORMAT_L32_FLOAT: - return &util_format_l32_float_description; - case PIPE_FORMAT_L32A32_FLOAT: - return &util_format_l32a32_float_description; - case PIPE_FORMAT_I32_FLOAT: - return &util_format_i32_float_description; - case PIPE_FORMAT_L8_SRGB: - return &util_format_l8_srgb_description; - case PIPE_FORMAT_L8A8_SRGB: - return &util_format_l8a8_srgb_description; - case PIPE_FORMAT_R8G8B8_SRGB: - return &util_format_r8g8b8_srgb_description; - case PIPE_FORMAT_R8G8B8A8_SRGB: - return &util_format_r8g8b8a8_srgb_description; - case PIPE_FORMAT_A8B8G8R8_SRGB: - return &util_format_a8b8g8r8_srgb_description; - case PIPE_FORMAT_X8B8G8R8_SRGB: - return &util_format_x8b8g8r8_srgb_description; - case PIPE_FORMAT_B8G8R8A8_SRGB: - return &util_format_b8g8r8a8_srgb_description; - case PIPE_FORMAT_B8G8R8X8_SRGB: - return &util_format_b8g8r8x8_srgb_description; - case PIPE_FORMAT_A8R8G8B8_SRGB: - return &util_format_a8r8g8b8_srgb_description; - case PIPE_FORMAT_X8R8G8B8_SRGB: - return &util_format_x8r8g8b8_srgb_description; - case PIPE_FORMAT_R8SG8SB8UX8U_NORM: - return &util_format_r8sg8sb8ux8u_norm_description; - case PIPE_FORMAT_R10SG10SB10SA2U_NORM: - return &util_format_r10sg10sb10sa2u_norm_description; - case PIPE_FORMAT_R5SG5SB6U_NORM: - return &util_format_r5sg5sb6u_norm_description; - case PIPE_FORMAT_S8_UINT: - return &util_format_s8_uint_description; - case PIPE_FORMAT_Z16_UNORM: - return &util_format_z16_unorm_description; - case PIPE_FORMAT_Z32_UNORM: - return &util_format_z32_unorm_description; - case PIPE_FORMAT_Z32_FLOAT: - return &util_format_z32_float_description; - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - return &util_format_z24_unorm_s8_uint_description; - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - return &util_format_s8_uint_z24_unorm_description; - case PIPE_FORMAT_X24S8_UINT: - return &util_format_x24s8_uint_description; - case PIPE_FORMAT_S8X24_UINT: - return &util_format_s8x24_uint_description; - case PIPE_FORMAT_Z24X8_UNORM: - return &util_format_z24x8_unorm_description; - case PIPE_FORMAT_X8Z24_UNORM: - return &util_format_x8z24_unorm_description; - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - return &util_format_z32_float_s8x24_uint_description; - case PIPE_FORMAT_X32_S8X24_UINT: - return &util_format_x32_s8x24_uint_description; - case PIPE_FORMAT_UYVY: - return &util_format_uyvy_description; - case PIPE_FORMAT_YUYV: - return &util_format_yuyv_description; - case PIPE_FORMAT_R8G8_B8G8_UNORM: - return &util_format_r8g8_b8g8_unorm_description; - case PIPE_FORMAT_G8R8_G8B8_UNORM: - return &util_format_g8r8_g8b8_unorm_description; - case PIPE_FORMAT_G8R8_B8R8_UNORM: - return &util_format_g8r8_b8r8_unorm_description; - case PIPE_FORMAT_R8G8_R8B8_UNORM: - return &util_format_r8g8_r8b8_unorm_description; - case PIPE_FORMAT_R11G11B10_FLOAT: - return &util_format_r11g11b10_float_description; - case PIPE_FORMAT_R9G9B9E5_FLOAT: - return &util_format_r9g9b9e5_float_description; - case PIPE_FORMAT_R1_UNORM: - return &util_format_r1_unorm_description; - case PIPE_FORMAT_R8G8Bx_SNORM: - return &util_format_r8g8bx_snorm_description; - case PIPE_FORMAT_DXT1_RGB: - return &util_format_dxt1_rgb_description; - case PIPE_FORMAT_DXT1_RGBA: - return &util_format_dxt1_rgba_description; - case PIPE_FORMAT_DXT3_RGBA: - return &util_format_dxt3_rgba_description; - case PIPE_FORMAT_DXT5_RGBA: - return &util_format_dxt5_rgba_description; - case PIPE_FORMAT_DXT1_SRGB: - return &util_format_dxt1_srgb_description; - case PIPE_FORMAT_DXT1_SRGBA: - return &util_format_dxt1_srgba_description; - case PIPE_FORMAT_DXT3_SRGBA: - return &util_format_dxt3_srgba_description; - case PIPE_FORMAT_DXT5_SRGBA: - return &util_format_dxt5_srgba_description; - case PIPE_FORMAT_RGTC1_UNORM: - return &util_format_rgtc1_unorm_description; - case PIPE_FORMAT_RGTC1_SNORM: - return &util_format_rgtc1_snorm_description; - case PIPE_FORMAT_RGTC2_UNORM: - return &util_format_rgtc2_unorm_description; - case PIPE_FORMAT_RGTC2_SNORM: - return &util_format_rgtc2_snorm_description; - case PIPE_FORMAT_LATC1_UNORM: - return &util_format_latc1_unorm_description; - case PIPE_FORMAT_LATC1_SNORM: - return &util_format_latc1_snorm_description; - case PIPE_FORMAT_LATC2_UNORM: - return &util_format_latc2_unorm_description; - case PIPE_FORMAT_LATC2_SNORM: - return &util_format_latc2_snorm_description; - case PIPE_FORMAT_ETC1_RGB8: - return &util_format_etc1_rgb8_description; - case PIPE_FORMAT_R64_FLOAT: - return &util_format_r64_float_description; - case PIPE_FORMAT_R64G64_FLOAT: - return &util_format_r64g64_float_description; - case PIPE_FORMAT_R64G64B64_FLOAT: - return &util_format_r64g64b64_float_description; - case PIPE_FORMAT_R64G64B64A64_FLOAT: - return &util_format_r64g64b64a64_float_description; - case PIPE_FORMAT_R32_FLOAT: - return &util_format_r32_float_description; - case PIPE_FORMAT_R32G32_FLOAT: - return &util_format_r32g32_float_description; - case PIPE_FORMAT_R32G32B32_FLOAT: - return &util_format_r32g32b32_float_description; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - return &util_format_r32g32b32a32_float_description; - case PIPE_FORMAT_R32_UNORM: - return &util_format_r32_unorm_description; - case PIPE_FORMAT_R32G32_UNORM: - return &util_format_r32g32_unorm_description; - case PIPE_FORMAT_R32G32B32_UNORM: - return &util_format_r32g32b32_unorm_description; - case PIPE_FORMAT_R32G32B32A32_UNORM: - return &util_format_r32g32b32a32_unorm_description; - case PIPE_FORMAT_R32_USCALED: - return &util_format_r32_uscaled_description; - case PIPE_FORMAT_R32G32_USCALED: - return &util_format_r32g32_uscaled_description; - case PIPE_FORMAT_R32G32B32_USCALED: - return &util_format_r32g32b32_uscaled_description; - case PIPE_FORMAT_R32G32B32A32_USCALED: - return &util_format_r32g32b32a32_uscaled_description; - case PIPE_FORMAT_R32_SNORM: - return &util_format_r32_snorm_description; - case PIPE_FORMAT_R32G32_SNORM: - return &util_format_r32g32_snorm_description; - case PIPE_FORMAT_R32G32B32_SNORM: - return &util_format_r32g32b32_snorm_description; - case PIPE_FORMAT_R32G32B32A32_SNORM: - return &util_format_r32g32b32a32_snorm_description; - case PIPE_FORMAT_R32_SSCALED: - return &util_format_r32_sscaled_description; - case PIPE_FORMAT_R32G32_SSCALED: - return &util_format_r32g32_sscaled_description; - case PIPE_FORMAT_R32G32B32_SSCALED: - return &util_format_r32g32b32_sscaled_description; - case PIPE_FORMAT_R32G32B32A32_SSCALED: - return &util_format_r32g32b32a32_sscaled_description; - case PIPE_FORMAT_R16_FLOAT: - return &util_format_r16_float_description; - case PIPE_FORMAT_R16G16_FLOAT: - return &util_format_r16g16_float_description; - case PIPE_FORMAT_R16G16B16_FLOAT: - return &util_format_r16g16b16_float_description; - case PIPE_FORMAT_R16G16B16A16_FLOAT: - return &util_format_r16g16b16a16_float_description; - case PIPE_FORMAT_R16_UNORM: - return &util_format_r16_unorm_description; - case PIPE_FORMAT_R16G16_UNORM: - return &util_format_r16g16_unorm_description; - case PIPE_FORMAT_R16G16B16_UNORM: - return &util_format_r16g16b16_unorm_description; - case PIPE_FORMAT_R16G16B16A16_UNORM: - return &util_format_r16g16b16a16_unorm_description; - case PIPE_FORMAT_R16_USCALED: - return &util_format_r16_uscaled_description; - case PIPE_FORMAT_R16G16_USCALED: - return &util_format_r16g16_uscaled_description; - case PIPE_FORMAT_R16G16B16_USCALED: - return &util_format_r16g16b16_uscaled_description; - case PIPE_FORMAT_R16G16B16A16_USCALED: - return &util_format_r16g16b16a16_uscaled_description; - case PIPE_FORMAT_R16_SNORM: - return &util_format_r16_snorm_description; - case PIPE_FORMAT_R16G16_SNORM: - return &util_format_r16g16_snorm_description; - case PIPE_FORMAT_R16G16B16_SNORM: - return &util_format_r16g16b16_snorm_description; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return &util_format_r16g16b16a16_snorm_description; - case PIPE_FORMAT_R16_SSCALED: - return &util_format_r16_sscaled_description; - case PIPE_FORMAT_R16G16_SSCALED: - return &util_format_r16g16_sscaled_description; - case PIPE_FORMAT_R16G16B16_SSCALED: - return &util_format_r16g16b16_sscaled_description; - case PIPE_FORMAT_R16G16B16A16_SSCALED: - return &util_format_r16g16b16a16_sscaled_description; - case PIPE_FORMAT_R8_UNORM: - return &util_format_r8_unorm_description; - case PIPE_FORMAT_R8G8_UNORM: - return &util_format_r8g8_unorm_description; - case PIPE_FORMAT_R8G8B8_UNORM: - return &util_format_r8g8b8_unorm_description; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return &util_format_r8g8b8a8_unorm_description; - case PIPE_FORMAT_R8_USCALED: - return &util_format_r8_uscaled_description; - case PIPE_FORMAT_R8G8_USCALED: - return &util_format_r8g8_uscaled_description; - case PIPE_FORMAT_R8G8B8_USCALED: - return &util_format_r8g8b8_uscaled_description; - case PIPE_FORMAT_R8G8B8A8_USCALED: - return &util_format_r8g8b8a8_uscaled_description; - case PIPE_FORMAT_R8_SNORM: - return &util_format_r8_snorm_description; - case PIPE_FORMAT_R8G8_SNORM: - return &util_format_r8g8_snorm_description; - case PIPE_FORMAT_R8G8B8_SNORM: - return &util_format_r8g8b8_snorm_description; - case PIPE_FORMAT_R8G8B8A8_SNORM: - return &util_format_r8g8b8a8_snorm_description; - case PIPE_FORMAT_R8_SSCALED: - return &util_format_r8_sscaled_description; - case PIPE_FORMAT_R8G8_SSCALED: - return &util_format_r8g8_sscaled_description; - case PIPE_FORMAT_R8G8B8_SSCALED: - return &util_format_r8g8b8_sscaled_description; - case PIPE_FORMAT_R8G8B8A8_SSCALED: - return &util_format_r8g8b8a8_sscaled_description; - case PIPE_FORMAT_R32_FIXED: - return &util_format_r32_fixed_description; - case PIPE_FORMAT_R32G32_FIXED: - return &util_format_r32g32_fixed_description; - case PIPE_FORMAT_R32G32B32_FIXED: - return &util_format_r32g32b32_fixed_description; - case PIPE_FORMAT_R32G32B32A32_FIXED: - return &util_format_r32g32b32a32_fixed_description; - case PIPE_FORMAT_R10G10B10X2_USCALED: - return &util_format_r10g10b10x2_uscaled_description; - case PIPE_FORMAT_R10G10B10X2_SNORM: - return &util_format_r10g10b10x2_snorm_description; - case PIPE_FORMAT_YV12: - return &util_format_yv12_description; - case PIPE_FORMAT_YV16: - return &util_format_yv16_description; - case PIPE_FORMAT_IYUV: - return &util_format_iyuv_description; - case PIPE_FORMAT_NV12: - return &util_format_nv12_description; - case PIPE_FORMAT_NV21: - return &util_format_nv21_description; - case PIPE_FORMAT_R4A4_UNORM: - return &util_format_r4a4_unorm_description; - case PIPE_FORMAT_A4R4_UNORM: - return &util_format_a4r4_unorm_description; - case PIPE_FORMAT_R8A8_UNORM: - return &util_format_r8a8_unorm_description; - case PIPE_FORMAT_A8R8_UNORM: - return &util_format_a8r8_unorm_description; - case PIPE_FORMAT_R10G10B10A2_USCALED: - return &util_format_r10g10b10a2_uscaled_description; - case PIPE_FORMAT_R10G10B10A2_SSCALED: - return &util_format_r10g10b10a2_sscaled_description; - case PIPE_FORMAT_R10G10B10A2_SNORM: - return &util_format_r10g10b10a2_snorm_description; - case PIPE_FORMAT_B10G10R10A2_USCALED: - return &util_format_b10g10r10a2_uscaled_description; - case PIPE_FORMAT_B10G10R10A2_SSCALED: - return &util_format_b10g10r10a2_sscaled_description; - case PIPE_FORMAT_B10G10R10A2_SNORM: - return &util_format_b10g10r10a2_snorm_description; - case PIPE_FORMAT_R8_UINT: - return &util_format_r8_uint_description; - case PIPE_FORMAT_R8G8_UINT: - return &util_format_r8g8_uint_description; - case PIPE_FORMAT_R8G8B8_UINT: - return &util_format_r8g8b8_uint_description; - case PIPE_FORMAT_R8G8B8A8_UINT: - return &util_format_r8g8b8a8_uint_description; - case PIPE_FORMAT_R8_SINT: - return &util_format_r8_sint_description; - case PIPE_FORMAT_R8G8_SINT: - return &util_format_r8g8_sint_description; - case PIPE_FORMAT_R8G8B8_SINT: - return &util_format_r8g8b8_sint_description; - case PIPE_FORMAT_R8G8B8A8_SINT: - return &util_format_r8g8b8a8_sint_description; - case PIPE_FORMAT_R16_UINT: - return &util_format_r16_uint_description; - case PIPE_FORMAT_R16G16_UINT: - return &util_format_r16g16_uint_description; - case PIPE_FORMAT_R16G16B16_UINT: - return &util_format_r16g16b16_uint_description; - case PIPE_FORMAT_R16G16B16A16_UINT: - return &util_format_r16g16b16a16_uint_description; - case PIPE_FORMAT_R16_SINT: - return &util_format_r16_sint_description; - case PIPE_FORMAT_R16G16_SINT: - return &util_format_r16g16_sint_description; - case PIPE_FORMAT_R16G16B16_SINT: - return &util_format_r16g16b16_sint_description; - case PIPE_FORMAT_R16G16B16A16_SINT: - return &util_format_r16g16b16a16_sint_description; - case PIPE_FORMAT_R32_UINT: - return &util_format_r32_uint_description; - case PIPE_FORMAT_R32G32_UINT: - return &util_format_r32g32_uint_description; - case PIPE_FORMAT_R32G32B32_UINT: - return &util_format_r32g32b32_uint_description; - case PIPE_FORMAT_R32G32B32A32_UINT: - return &util_format_r32g32b32a32_uint_description; - case PIPE_FORMAT_R32_SINT: - return &util_format_r32_sint_description; - case PIPE_FORMAT_R32G32_SINT: - return &util_format_r32g32_sint_description; - case PIPE_FORMAT_R32G32B32_SINT: - return &util_format_r32g32b32_sint_description; - case PIPE_FORMAT_R32G32B32A32_SINT: - return &util_format_r32g32b32a32_sint_description; - case PIPE_FORMAT_A8_UINT: - return &util_format_a8_uint_description; - case PIPE_FORMAT_I8_UINT: - return &util_format_i8_uint_description; - case PIPE_FORMAT_L8_UINT: - return &util_format_l8_uint_description; - case PIPE_FORMAT_L8A8_UINT: - return &util_format_l8a8_uint_description; - case PIPE_FORMAT_A8_SINT: - return &util_format_a8_sint_description; - case PIPE_FORMAT_I8_SINT: - return &util_format_i8_sint_description; - case PIPE_FORMAT_L8_SINT: - return &util_format_l8_sint_description; - case PIPE_FORMAT_L8A8_SINT: - return &util_format_l8a8_sint_description; - case PIPE_FORMAT_A16_UINT: - return &util_format_a16_uint_description; - case PIPE_FORMAT_I16_UINT: - return &util_format_i16_uint_description; - case PIPE_FORMAT_L16_UINT: - return &util_format_l16_uint_description; - case PIPE_FORMAT_L16A16_UINT: - return &util_format_l16a16_uint_description; - case PIPE_FORMAT_A16_SINT: - return &util_format_a16_sint_description; - case PIPE_FORMAT_I16_SINT: - return &util_format_i16_sint_description; - case PIPE_FORMAT_L16_SINT: - return &util_format_l16_sint_description; - case PIPE_FORMAT_L16A16_SINT: - return &util_format_l16a16_sint_description; - case PIPE_FORMAT_A32_UINT: - return &util_format_a32_uint_description; - case PIPE_FORMAT_I32_UINT: - return &util_format_i32_uint_description; - case PIPE_FORMAT_L32_UINT: - return &util_format_l32_uint_description; - case PIPE_FORMAT_L32A32_UINT: - return &util_format_l32a32_uint_description; - case PIPE_FORMAT_A32_SINT: - return &util_format_a32_sint_description; - case PIPE_FORMAT_I32_SINT: - return &util_format_i32_sint_description; - case PIPE_FORMAT_L32_SINT: - return &util_format_l32_sint_description; - case PIPE_FORMAT_L32A32_SINT: - return &util_format_l32a32_sint_description; - case PIPE_FORMAT_B10G10R10A2_UINT: - return &util_format_b10g10r10a2_uint_description; - case PIPE_FORMAT_R8G8B8X8_SNORM: - return &util_format_r8g8b8x8_snorm_description; - case PIPE_FORMAT_R8G8B8X8_SRGB: - return &util_format_r8g8b8x8_srgb_description; - case PIPE_FORMAT_R8G8B8X8_UINT: - return &util_format_r8g8b8x8_uint_description; - case PIPE_FORMAT_R8G8B8X8_SINT: - return &util_format_r8g8b8x8_sint_description; - case PIPE_FORMAT_B10G10R10X2_UNORM: - return &util_format_b10g10r10x2_unorm_description; - case PIPE_FORMAT_R16G16B16X16_UNORM: - return &util_format_r16g16b16x16_unorm_description; - case PIPE_FORMAT_R16G16B16X16_SNORM: - return &util_format_r16g16b16x16_snorm_description; - case PIPE_FORMAT_R16G16B16X16_FLOAT: - return &util_format_r16g16b16x16_float_description; - case PIPE_FORMAT_R16G16B16X16_UINT: - return &util_format_r16g16b16x16_uint_description; - case PIPE_FORMAT_R16G16B16X16_SINT: - return &util_format_r16g16b16x16_sint_description; - case PIPE_FORMAT_R32G32B32X32_FLOAT: - return &util_format_r32g32b32x32_float_description; - case PIPE_FORMAT_R32G32B32X32_UINT: - return &util_format_r32g32b32x32_uint_description; - case PIPE_FORMAT_R32G32B32X32_SINT: - return &util_format_r32g32b32x32_sint_description; - case PIPE_FORMAT_R8A8_SNORM: - return &util_format_r8a8_snorm_description; - case PIPE_FORMAT_R16A16_UNORM: - return &util_format_r16a16_unorm_description; - case PIPE_FORMAT_R16A16_SNORM: - return &util_format_r16a16_snorm_description; - case PIPE_FORMAT_R16A16_FLOAT: - return &util_format_r16a16_float_description; - case PIPE_FORMAT_R32A32_FLOAT: - return &util_format_r32a32_float_description; - case PIPE_FORMAT_R8A8_UINT: - return &util_format_r8a8_uint_description; - case PIPE_FORMAT_R8A8_SINT: - return &util_format_r8a8_sint_description; - case PIPE_FORMAT_R16A16_UINT: - return &util_format_r16a16_uint_description; - case PIPE_FORMAT_R16A16_SINT: - return &util_format_r16a16_sint_description; - case PIPE_FORMAT_R32A32_UINT: - return &util_format_r32a32_uint_description; - case PIPE_FORMAT_R32A32_SINT: - return &util_format_r32a32_sint_description; - case PIPE_FORMAT_R10G10B10A2_UINT: - return &util_format_r10g10b10a2_uint_description; - default: - return NULL; - } -} - diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py new file mode 100755 index 0000000..50a78ef --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -0,0 +1,167 @@ +#!/usr/bin/env python + +CopyRight = ''' +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ +''' + + +import sys + +from u_format_parse import * +import u_format_pack + + +def layout_map(layout): + return 'UTIL_FORMAT_LAYOUT_' + str(layout).upper() + + +def colorspace_map(colorspace): + return 'UTIL_FORMAT_COLORSPACE_' + str(colorspace).upper() + + +colorspace_channels_map = { + 'rgb': ['r', 'g', 'b', 'a'], + 'srgb': ['sr', 'sg', 'sb', 'a'], + 'zs': ['z', 's'], + 'yuv': ['y', 'u', 'v'], +} + + +type_map = { + VOID: "UTIL_FORMAT_TYPE_VOID", + UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED", + SIGNED: "UTIL_FORMAT_TYPE_SIGNED", + FIXED: "UTIL_FORMAT_TYPE_FIXED", + FLOAT: "UTIL_FORMAT_TYPE_FLOAT", +} + + +def bool_map(value): + if value: + return "TRUE" + else: + return "FALSE" + + +swizzle_map = { + SWIZZLE_X: "UTIL_FORMAT_SWIZZLE_X", + SWIZZLE_Y: "UTIL_FORMAT_SWIZZLE_Y", + SWIZZLE_Z: "UTIL_FORMAT_SWIZZLE_Z", + SWIZZLE_W: "UTIL_FORMAT_SWIZZLE_W", + SWIZZLE_0: "UTIL_FORMAT_SWIZZLE_0", + SWIZZLE_1: "UTIL_FORMAT_SWIZZLE_1", + SWIZZLE_NONE: "UTIL_FORMAT_SWIZZLE_NONE", +} + + +def write_format_table(formats): + print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */' + print + # This will print the copyright message on the top of this file + print CopyRight.strip() + print + print '#include "u_format.h"' + print + + u_format_pack.generate(formats) + + def do_channel_array(channels, swizzles): + print " {" + for i in range(4): + channel = channels[i] + if i < 3: + sep = "," + else: + sep = "" + if channel.size: + print " {%s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), channel.size, channel.shift, sep, "xyzw"[i], channel.name) + else: + print " {0, 0, 0, 0, 0}%s" % (sep,) + print " }," + + def do_swizzle_array(channels, swizzles): + print " {" + for i in range(4): + swizzle = swizzles[i] + if i < 3: + sep = "," + else: + sep = "" + try: + comment = colorspace_channels_map[format.colorspace][i] + except (KeyError, IndexError): + comment = 'ignored' + print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) + print " }," + + for format in formats: + print 'const struct util_format_description' + print 'util_format_%s_description = {' % (format.short_name(),) + print " %s," % (format.name,) + print " \"%s\"," % (format.name,) + print " \"%s\"," % (format.short_name(),) + print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) + print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) + u_format_pack.print_channels(format, do_channel_array) + u_format_pack.print_channels(format, do_swizzle_array) + print " %s," % (colorspace_map(format.colorspace),) + print "};" + print + + print "const struct util_format_description *" + print "util_format_description(enum pipe_format format)" + print "{" + print " if (format >= PIPE_FORMAT_COUNT) {" + print " return NULL;" + print " }" + print + print " switch (format) {" + for format in formats: + print " case %s:" % format.name + print " return &util_format_%s_description;" % (format.short_name(),) + print " default:" + print " return NULL;" + print " }" + print "}" + print + + +def main(): + + formats = [] + for arg in sys.argv[1:]: + formats.extend(parse(arg)) + write_format_table(formats) + + +if __name__ == '__main__': + main() diff --git a/src/gallium/auxiliary/util/u_format_yuv.c b/src/gallium/auxiliary/util/u_format_yuv.c deleted file mode 100644 index 891d99c..0000000 --- a/src/gallium/auxiliary/util/u_format_yuv.c +++ /dev/null @@ -1,1193 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -/** - * @file - * YUV and RGB subsampled formats conversion. - * - * @author Jose Fonseca - */ - - -#include "util/u_debug.h" -#include "util/u_format_yuv.h" - - -void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - float r, g0, g1, b; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - r = ubyte_to_float((value >> 0) & 0xff); - g0 = ubyte_to_float((value >> 8) & 0xff); - b = ubyte_to_float((value >> 16) & 0xff); - g1 = ubyte_to_float((value >> 24) & 0xff); - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - dst += 4; - - dst[0] = r; /* r */ - dst[1] = g1; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - r = ubyte_to_float((value >> 0) & 0xff); - g0 = ubyte_to_float((value >> 8) & 0xff); - b = ubyte_to_float((value >> 16) & 0xff); - g1 = ubyte_to_float((value >> 24) & 0xff); - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t r, g0, g1, b; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - r = (value >> 0) & 0xff; - g0 = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - g1 = (value >> 24) & 0xff; - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - dst += 4; - - dst[0] = r; /* r */ - dst[1] = g1; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - r = (value >> 0) & 0xff; - g0 = (value >> 8) & 0xff; - b = (value >> 16) & 0xff; - g1 = (value >> 24) & 0xff; - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - float r, g0, g1, b; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - r = 0.5f*(src[0] + src[4]); - g0 = src[1]; - g1 = src[5]; - b = 0.5f*(src[2] + src[6]); - - value = float_to_ubyte(r); - value |= float_to_ubyte(g0) << 8; - value |= float_to_ubyte(b) << 16; - value |= float_to_ubyte(g1) << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - r = src[0]; - g0 = src[1]; - g1 = 0; - b = src[2]; - - value = float_to_ubyte(r); - value |= float_to_ubyte(g0) << 8; - value |= float_to_ubyte(b) << 16; - value |= float_to_ubyte(g1) << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint32_t r, g0, g1, b; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - r = (src[0] + src[4] + 1) >> 1; - g0 = src[1]; - g1 = src[5]; - b = (src[2] + src[6] + 1) >> 1; - - value = r; - value |= g0 << 8; - value |= b << 16; - value |= g1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - r = src[0]; - g0 = src[1]; - g1 = 0; - b = src[2]; - - value = r; - value |= g0 << 8; - value |= b << 16; - value |= g1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - assert(i < 2); - assert(j < 1); - - dst[0] = ubyte_to_float(src[0]); /* r */ - dst[1] = ubyte_to_float(src[1 + 2*i]); /* g */ - dst[2] = ubyte_to_float(src[2]); /* b */ - dst[3] = 1.0f; /* a */ -} - - -void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - float r, g0, g1, b; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - g0 = ubyte_to_float((value >> 0) & 0xff); - r = ubyte_to_float((value >> 8) & 0xff); - g1 = ubyte_to_float((value >> 16) & 0xff); - b = ubyte_to_float((value >> 24) & 0xff); - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - dst += 4; - - dst[0] = r; /* r */ - dst[1] = g1; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - g0 = ubyte_to_float((value >> 0) & 0xff); - r = ubyte_to_float((value >> 8) & 0xff); - g1 = ubyte_to_float((value >> 16) & 0xff); - b = ubyte_to_float((value >> 24) & 0xff); - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 1.0f; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t r, g0, g1, b; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - g0 = (value >> 0) & 0xff; - r = (value >> 8) & 0xff; - g1 = (value >> 16) & 0xff; - b = (value >> 24) & 0xff; - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - dst += 4; - - dst[0] = r; /* r */ - dst[1] = g1; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - g0 = (value >> 0) & 0xff; - r = (value >> 8) & 0xff; - g1 = (value >> 16) & 0xff; - b = (value >> 24) & 0xff; - - dst[0] = r; /* r */ - dst[1] = g0; /* g */ - dst[2] = b; /* b */ - dst[3] = 0xff; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - float r, g0, g1, b; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - r = 0.5f*(src[0] + src[4]); - g0 = src[1]; - g1 = src[5]; - b = 0.5f*(src[2] + src[6]); - - value = float_to_ubyte(g0); - value |= float_to_ubyte(r) << 8; - value |= float_to_ubyte(g1) << 16; - value |= float_to_ubyte(b) << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - r = src[0]; - g0 = src[1]; - g1 = 0; - b = src[2]; - - value = float_to_ubyte(g0); - value |= float_to_ubyte(r) << 8; - value |= float_to_ubyte(g1) << 16; - value |= float_to_ubyte(b) << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint32_t r, g0, g1, b; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - r = (src[0] + src[4] + 1) >> 1; - g0 = src[1]; - g1 = src[5]; - b = (src[2] + src[6] + 1) >> 1; - - value = g0; - value |= r << 8; - value |= g1 << 16; - value |= b << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - r = src[0]; - g0 = src[1]; - g1 = 0; - b = src[2]; - - value = g0; - value |= r << 8; - value |= g1 << 16; - value |= b << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - assert(i < 2); - assert(j < 1); - - dst[0] = ubyte_to_float(src[1]); /* r */ - dst[1] = ubyte_to_float(src[0 + 2*i]); /* g */ - dst[2] = ubyte_to_float(src[3]); /* b */ - dst[3] = 1.0f; /* a */ -} - - -void -util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t y0, y1, u, v; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - u = (value >> 0) & 0xff; - y0 = (value >> 8) & 0xff; - v = (value >> 16) & 0xff; - y1 = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - dst += 4; - - util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - u = (value >> 0) & 0xff; - y0 = (value >> 8) & 0xff; - v = (value >> 16) & 0xff; - y1 = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t y0, y1, u, v; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - u = (value >> 0) & 0xff; - y0 = (value >> 8) & 0xff; - v = (value >> 16) & 0xff; - y1 = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - dst += 4; - - util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - u = (value >> 0) & 0xff; - y0 = (value >> 8) & 0xff; - v = (value >> 16) & 0xff; - y1 = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint8_t y0, y1, u, v; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - uint8_t y0, y1, u0, u1, v0, v1, u, v; - - util_format_rgb_float_to_yuv(src[0], src[1], src[2], - &y0, &u0, &v0); - util_format_rgb_float_to_yuv(src[4], src[5], src[6], - &y1, &u1, &v1); - - u = (u0 + u1 + 1) >> 1; - v = (v0 + v1 + 1) >> 1; - - value = u; - value |= y0 << 8; - value |= v << 16; - value |= y1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - util_format_rgb_float_to_yuv(src[0], src[1], src[2], - &y0, &u, &v); - y1 = 0; - - value = u; - value |= y0 << 8; - value |= v << 16; - value |= y1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint8_t y0, y1, u, v; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - uint8_t y0, y1, u0, u1, v0, v1, u, v; - - util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2], - &y0, &u0, &v0); - util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6], - &y1, &u1, &v1); - - u = (u0 + u1 + 1) >> 1; - v = (v0 + v1 + 1) >> 1; - - value = u; - value |= y0 << 8; - value |= v << 16; - value |= y1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2], - &y0, &u, &v); - y1 = 0; - - value = u; - value |= y0 << 8; - value |= v << 16; - value |= y1 << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - uint8_t y, u, v; - - assert(i < 2); - assert(j < 1); - - y = src[1 + i*2]; - u = src[0]; - v = src[2]; - - util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]); - - dst[3] = 1.0f; -} - - -void -util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t y0, y1, u, v; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - y0 = (value >> 0) & 0xff; - u = (value >> 8) & 0xff; - y1 = (value >> 16) & 0xff; - v = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - dst += 4; - - util_format_yuv_to_rgb_float(y1, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - y0 = (value >> 0) & 0xff; - u = (value >> 8) & 0xff; - y1 = (value >> 16) & 0xff; - v = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_float(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 1.0f; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - uint32_t value; - uint8_t y0, y1, u, v; - - for (x = 0; x + 1 < width; x += 2) { - value = *src++; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - y0 = (value >> 0) & 0xff; - u = (value >> 8) & 0xff; - y1 = (value >> 16) & 0xff; - v = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - dst += 4; - - util_format_yuv_to_rgb_8unorm(y1, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - dst += 4; - } - - if (x < width) { - value = *src; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - y0 = (value >> 0) & 0xff; - u = (value >> 8) & 0xff; - y1 = (value >> 16) & 0xff; - v = (value >> 24) & 0xff; - - util_format_yuv_to_rgb_8unorm(y0, u, v, &dst[0], &dst[1], &dst[2]); - dst[3] = 0xff; /* a */ - } - - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - - -void -util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint8_t y0, y1, u, v; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - uint8_t y0, y1, u0, u1, v0, v1, u, v; - - util_format_rgb_float_to_yuv(src[0], src[1], src[2], - &y0, &u0, &v0); - util_format_rgb_float_to_yuv(src[4], src[5], src[6], - &y1, &u1, &v1); - - u = (u0 + u1 + 1) >> 1; - v = (v0 + v1 + 1) >> 1; - - value = y0; - value |= u << 8; - value |= y1 << 16; - value |= v << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - util_format_rgb_float_to_yuv(src[0], src[1], src[2], - &y0, &u, &v); - y1 = 0; - - value = y0; - value |= u << 8; - value |= y1 << 16; - value |= v << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - - for (y = 0; y < height; y += 1) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - uint8_t y0, y1, u, v; - uint32_t value; - - for (x = 0; x + 1 < width; x += 2) { - uint8_t y0, y1, u0, u1, v0, v1, u, v; - - util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2], - &y0, &u0, &v0); - util_format_rgb_8unorm_to_yuv(src[4], src[5], src[6], - &y1, &u1, &v1); - - u = (u0 + u1 + 1) >> 1; - v = (v0 + v1 + 1) >> 1; - - value = y0; - value |= u << 8; - value |= y1 << 16; - value |= v << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst++ = value; - - src += 8; - } - - if (x < width) { - util_format_rgb_8unorm_to_yuv(src[0], src[1], src[2], - &y0, &u, &v); - y1 = 0; - - value = y0; - value |= u << 8; - value |= y1 << 16; - value |= v << 24; - -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - - *dst = value; - } - - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) -{ - uint8_t y, u, v; - - assert(i < 2); - assert(j < 1); - - y = src[0 + i*2]; - u = src[1]; - v = src[3]; - - util_format_yuv_to_rgb_float(y, u, v, &dst[0], &dst[1], &dst[2]); - - dst[3] = 1.0f; -} - -/* XXX: Stubbed for now */ -void -util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} -void -util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} -void -util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} -void -util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} -void -util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} -void -util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} - -void -util_format_r8g8_r8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_r8g8_r8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_r8g8_r8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_r8g8_r8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} - -void -util_format_g8r8_b8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_g8r8_b8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_g8r8_b8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) {} - -void -util_format_g8r8_b8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j) {} diff --git a/src/gallium/auxiliary/util/u_format_yuv.h b/src/gallium/auxiliary/util/u_format_yuv.h deleted file mode 100644 index 4ec3981..0000000 --- a/src/gallium/auxiliary/util/u_format_yuv.h +++ /dev/null @@ -1,364 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -/** - * @file - * YUV colorspace conversion. - * - * @author Brian Paul - * @author Michal Krol - * @author Jose Fonseca - * - * See also: - * - http://www.fourcc.org/fccyvrgb.php - * - http://msdn.microsoft.com/en-us/library/ms893078 - * - http://en.wikipedia.org/wiki/YUV - */ - - -#ifndef U_FORMAT_YUV_H_ -#define U_FORMAT_YUV_H_ - - -#include "pipe/p_compiler.h" -#include "u_math.h" - - -/* - * TODO: Ensure we use consistent and right floating formulas, with enough - * precision in the coefficients. - */ - -static INLINE void -util_format_rgb_float_to_yuv(float r, float g, float b, - uint8_t *y, uint8_t *u, uint8_t *v) -{ - const float _r = CLAMP(r, 0.0f, 1.0f); - const float _g = CLAMP(g, 0.0f, 1.0f); - const float _b = CLAMP(b, 0.0f, 1.0f); - - const float scale = 255.0f; - - const int _y = scale * ( (0.257f * _r) + (0.504f * _g) + (0.098f * _b)); - const int _u = scale * (-(0.148f * _r) - (0.291f * _g) + (0.439f * _b)); - const int _v = scale * ( (0.439f * _r) - (0.368f * _g) - (0.071f * _b)); - - *y = _y + 16; - *u = _u + 128; - *v = _v + 128; -} - - -static INLINE void -util_format_yuv_to_rgb_float(uint8_t y, uint8_t u, uint8_t v, - float *r, float *g, float *b) -{ - const int _y = y - 16; - const int _u = u - 128; - const int _v = v - 128; - - const float y_factor = 255.0f / 219.0f; - - const float scale = 1.0f / 255.0f; - - *r = scale * (y_factor * _y + 1.596f * _v); - *g = scale * (y_factor * _y - 0.391f * _u - 0.813f * _v); - *b = scale * (y_factor * _y + 2.018f * _u ); -} - - -static INLINE void -util_format_rgb_8unorm_to_yuv(uint8_t r, uint8_t g, uint8_t b, - uint8_t *y, uint8_t *u, uint8_t *v) -{ - *y = (( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16; - *u = (( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128; - *v = (( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128; -} - - -static INLINE void -util_format_yuv_to_rgb_8unorm(uint8_t y, uint8_t u, uint8_t v, - uint8_t *r, uint8_t *g, uint8_t *b) -{ - const int _y = y - 16; - const int _u = u - 128; - const int _v = v - 128; - - const int _r = (298 * _y + 409 * _v + 128) >> 8; - const int _g = (298 * _y - 100 * _u - 208 * _v + 128) >> 8; - const int _b = (298 * _y + 516 * _u + 128) >> 8; - - *r = CLAMP(_r, 0, 255); - *g = CLAMP(_g, 0, 255); - *b = CLAMP(_b, 0, 255); -} - - - -void -util_format_uyvy_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_uyvy_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_uyvy_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_uyvy_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_uyvy_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_yuyv_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_yuyv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_yuyv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_yuyv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_yuyv_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -/* XXX: Stubbed for now */ -void -util_format_yv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv12_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); -void -util_format_yv16_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv16_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv16_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv16_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_yv16_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); -void -util_format_iyuv_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_iyuv_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_iyuv_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_iyuv_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_iyuv_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); -void -util_format_nv12_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv12_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv12_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv12_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv12_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); -void -util_format_nv21_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv21_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv21_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv21_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); -void -util_format_nv21_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); -void -util_format_r8g8_b8g8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_b8g8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_b8g8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_b8g8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_b8g8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_g8r8_g8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_g8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_g8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_g8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_g8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_r8g8_r8b8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_r8b8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_r8b8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_r8b8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_r8g8_r8b8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -void -util_format_g8r8_b8r8_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_b8r8_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_b8r8_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_b8r8_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height); - -void -util_format_g8r8_b8r8_unorm_fetch_rgba_float(float *dst, const uint8_t *src, - unsigned i, unsigned j); - -#endif /* U_FORMAT_YUV_H_ */ diff --git a/src/gallium/auxiliary/util/u_format_zs.c b/src/gallium/auxiliary/util/u_format_zs.c deleted file mode 100644 index ed45c52..0000000 --- a/src/gallium/auxiliary/util/u_format_zs.c +++ /dev/null @@ -1,973 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -#include "u_debug.h" -#include "u_math.h" -#include "u_format_zs.h" - - -/* - * z32_unorm conversion functions - */ - -static INLINE uint16_t -z32_unorm_to_z16_unorm(uint32_t z) -{ - /* z * 0xffff / 0xffffffff */ - return z >> 16; -} - -static INLINE uint32_t -z16_unorm_to_z32_unorm(uint16_t z) -{ - /* z * 0xffffffff / 0xffff */ - return (z << 16) | z; -} - -static INLINE uint32_t -z32_unorm_to_z24_unorm(uint32_t z) -{ - /* z * 0xffffff / 0xffffffff */ - return z >> 8; -} - -static INLINE uint32_t -z24_unorm_to_z32_unorm(uint32_t z) -{ - /* z * 0xffffffff / 0xffffff */ - return (z << 8) | (z >> 16); -} - - -/* - * z32_float conversion functions - */ - -static INLINE uint16_t -z32_float_to_z16_unorm(float z) -{ - const float scale = 0xffff; - return (uint16_t)(z * scale + 0.5f); -} - -static INLINE float -z16_unorm_to_z32_float(uint16_t z) -{ - const float scale = 1.0 / 0xffff; - return (float)(z * scale); -} - -static INLINE uint32_t -z32_float_to_z24_unorm(float z) -{ - const double scale = 0xffffff; - return (uint32_t)(z * scale) & 0xffffff; -} - -static INLINE float -z24_unorm_to_z32_float(uint32_t z) -{ - const double scale = 1.0 / 0xffffff; - return (float)(z * scale); -} - -static INLINE uint32_t -z32_float_to_z32_unorm(float z) -{ - const double scale = 0xffffffff; - return (uint32_t)(z * scale); -} - -static INLINE float -z32_unorm_to_z32_float(uint32_t z) -{ - const double scale = 1.0 / 0xffffffff; - return (float)(z * scale); -} - - -void -util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint16_t *src = (const uint16_t *)src_row; - for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = z16_unorm_to_z32_float(value); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint16_t *dst = (uint16_t *)dst_row; - for(x = 0; x < width; ++x) { - uint16_t value; - value = z32_float_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const uint16_t *src = (const uint16_t *)src_row; - for(x = 0; x < width; ++x) { - uint16_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = z16_unorm_to_z32_unorm(value); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - uint16_t *dst = (uint16_t *)dst_row; - for(x = 0; x < width; ++x) { - uint16_t value; - value = z32_unorm_to_z16_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap16(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z32_unorm_to_z32_float(value); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value; - value = z32_float_to_z32_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width * 4); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width * 4); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width * 4); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned y; - for(y = 0; y < height; ++y) { - memcpy(dst_row, src_row, width * 4); - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const float *src = (const float *)src_row; - for(x = 0; x < width; ++x) { - *dst++ = z32_float_to_z32_unorm(*src++); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - float *dst = (float *)dst_row; - for(x = 0; x < width; ++x) { - *dst++ = z32_unorm_to_z32_float(*src++); - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_float(value & 0xffffff); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0xff000000; - value |= z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value= *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0xff000000; - value |= z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value >> 24; - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0x00ffffff; - value |= *src++ << 24; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_float(value >> 8); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0x000000ff; - value |= z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_unorm(value >> 8); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0x000000ff; - value |= *src++ & 0xffffff00; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint8_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value & 0xff; - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint8_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value = *dst; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - value &= 0xffffff00; - value |= *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_float(value & 0xffffff); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value; - value = z32_float_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_unorm(value & 0xffffff); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value; - value = z32_unorm_to_z24_unorm(*src++); -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const uint32_t *src = (uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_float(value >> 8); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value; - value = z32_float_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const uint32_t *src = (const uint32_t *)src_row; - for(x = 0; x < width; ++x) { - uint32_t value = *src++; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = z24_unorm_to_z32_unorm(value >> 8); - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - uint32_t *dst = (uint32_t *)dst_row; - for(x = 0; x < width; ++x) { - uint32_t value; - value = z32_unorm_to_z24_unorm(*src++) << 8; -#ifdef PIPE_ARCH_BIG_ENDIAN - value = util_bswap32(value); -#endif - *dst++ = value; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - float *dst = dst_row; - const float *src = (const float *)src_row; - for(x = 0; x < width; ++x) { - *dst = *src; - src += 2; - dst += 1; - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, - const float *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const float *src = src_row; - float *dst = (float *)dst_row; - for(x = 0; x < width; ++x) { - *dst = *src; - src += 1; - dst += 2; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint32_t *dst = dst_row; - const float *src = (const float *)src_row; - for(x = 0; x < width; ++x) { - *dst = z32_float_to_z32_unorm(*src); - src += 2; - dst += 1; - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, - const uint32_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint32_t *src = src_row; - float *dst = (float *)dst_row; - for(x = 0; x < width; ++x) { - *dst++ = z32_unorm_to_z32_float(*src++); - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - -void -util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - uint8_t *dst = dst_row; - const uint8_t *src = src_row + 4; - for(x = 0; x < width; ++x) { - *dst = *src; - src += 8; - dst += 1; - } - src_row += src_stride/sizeof(*src_row); - dst_row += dst_stride/sizeof(*dst_row); - } -} - -void -util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - unsigned x, y; - for(y = 0; y < height; ++y) { - const uint8_t *src = src_row; - uint8_t *dst = dst_row + 4; - for(x = 0; x < width; ++x) { - *dst = *src; - src += 1; - dst += 8; - } - dst_row += dst_stride/sizeof(*dst_row); - src_row += src_stride/sizeof(*src_row); - } -} - - -void -util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_z24_unorm_s8_uint_unpack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); -} - -void -util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_z24_unorm_s8_uint_pack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); -} - -void -util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_s8_uint_z24_unorm_unpack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); -} - -void -util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height) -{ - util_format_s8_uint_z24_unorm_pack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); -} - -void -util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_z32_float_s8x24_uint_unpack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); - -} - -void -util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, - const uint8_t *src_row, unsigned src_stride, - unsigned width, unsigned height) -{ - util_format_z32_float_s8x24_uint_pack_s_8uint(dst_row, dst_stride, - src_row, src_stride, - width, height); -} diff --git a/src/gallium/auxiliary/util/u_format_zs.h b/src/gallium/auxiliary/util/u_format_zs.h deleted file mode 100644 index adddfaf..0000000 --- a/src/gallium/auxiliary/util/u_format_zs.h +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - - -#ifndef U_FORMAT_ZS_H_ -#define U_FORMAT_ZS_H_ - - -#include "pipe/p_compiler.h" - - -void -util_format_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z16_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z16_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z16_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z16_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24_unorm_s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_s8_uint_z24_unorm_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24x8_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24x8_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24x8_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z24x8_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_x8z24_unorm_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_x8z24_unorm_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_x8z24_unorm_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_x8z24_unorm_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_unpack_z_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_pack_z_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_unpack_z_32unorm(uint32_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_pack_z_32unorm(uint8_t *dst_row, unsigned dst_stride, const uint32_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - -void -util_format_z32_float_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_x24s8_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_x24s8_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_x32_s8x24_uint_unpack_s_8uint(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_x32_s8x24_uint_pack_s_8uint(uint8_t *dst_row, unsigned dst_sride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); -#endif /* U_FORMAT_ZS_H_ */ diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index e0c9018..24dec46 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -57,570 +57,6 @@ union util_color { double d[4]; }; -/** - * Pack ubyte R,G,B,A into dest pixel. - */ -static INLINE void -util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, - enum pipe_format format, union util_color *uc) -{ - switch (format) { - case PIPE_FORMAT_ABGR8888_UNORM: - { - uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; - } - return; - case PIPE_FORMAT_XBGR8888_UNORM: - { - uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; - } - return; - case PIPE_FORMAT_BGRA8888_UNORM: - { - uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; - } - return; - case PIPE_FORMAT_BGRX8888_UNORM: - { - uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; - } - return; - case PIPE_FORMAT_ARGB8888_UNORM: - { - uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; - } - return; - case PIPE_FORMAT_XRGB8888_UNORM: - { - uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; - } - return; - case PIPE_FORMAT_B5G6R5_UNORM: - { - uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); - } - return; - case PIPE_FORMAT_B5G5R5X1_UNORM: - { - uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); - } - return; - case PIPE_FORMAT_B5G5R5A1_UNORM: - { - uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); - } - return; - case PIPE_FORMAT_B4G4R4A4_UNORM: - { - uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4); - } - return; - case PIPE_FORMAT_A8_UNORM: - { - uc->ub = a; - } - return; - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_I8_UNORM: - { - uc->ub = r; - } - return; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - { - uc->f[0] = (float)r / 255.0f; - uc->f[1] = (float)g / 255.0f; - uc->f[2] = (float)b / 255.0f; - uc->f[3] = (float)a / 255.0f; - } - return; - case PIPE_FORMAT_R32G32B32_FLOAT: - { - uc->f[0] = (float)r / 255.0f; - uc->f[1] = (float)g / 255.0f; - uc->f[2] = (float)b / 255.0f; - } - return; - - /* Handle other cases with a generic function. - */ - default: - { - ubyte src[4]; - - src[0] = r; - src[1] = g; - src[2] = b; - src[3] = a; - util_format_write_4ub(format, src, 0, uc, 0, 0, 0, 1, 1); - } - } -} - - -/** - * Unpack RGBA from a packed pixel, returning values as ubytes in [0,255]. - */ -static INLINE void -util_unpack_color_ub(enum pipe_format format, union util_color *uc, - ubyte *r, ubyte *g, ubyte *b, ubyte *a) -{ - switch (format) { - case PIPE_FORMAT_ABGR8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 24) & 0xff); - *g = (ubyte) ((p >> 16) & 0xff); - *b = (ubyte) ((p >> 8) & 0xff); - *a = (ubyte) ((p >> 0) & 0xff); - } - return; - case PIPE_FORMAT_XBGR8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 24) & 0xff); - *g = (ubyte) ((p >> 16) & 0xff); - *b = (ubyte) ((p >> 8) & 0xff); - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_BGRA8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 16) & 0xff); - *g = (ubyte) ((p >> 8) & 0xff); - *b = (ubyte) ((p >> 0) & 0xff); - *a = (ubyte) ((p >> 24) & 0xff); - } - return; - case PIPE_FORMAT_BGRX8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 16) & 0xff); - *g = (ubyte) ((p >> 8) & 0xff); - *b = (ubyte) ((p >> 0) & 0xff); - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_ARGB8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 8) & 0xff); - *g = (ubyte) ((p >> 16) & 0xff); - *b = (ubyte) ((p >> 24) & 0xff); - *a = (ubyte) ((p >> 0) & 0xff); - } - return; - case PIPE_FORMAT_XRGB8888_UNORM: - { - uint p = uc->ui[0]; - *r = (ubyte) ((p >> 8) & 0xff); - *g = (ubyte) ((p >> 16) & 0xff); - *b = (ubyte) ((p >> 24) & 0xff); - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_B5G6R5_UNORM: - { - ushort p = uc->us; - *r = (ubyte) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7)); - *g = (ubyte) (((p >> 3) & 0xfc) | ((p >> 9) & 0x3)); - *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7)); - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_B5G5R5X1_UNORM: - { - ushort p = uc->us; - *r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7)); - *g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7)); - *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7)); - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_B5G5R5A1_UNORM: - { - ushort p = uc->us; - *r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7)); - *g = (ubyte) (((p >> 2) & 0xf8) | ((p >> 7) & 0x7)); - *b = (ubyte) (((p << 3) & 0xf8) | ((p >> 2) & 0x7)); - *a = (ubyte) (0xff * (p >> 15)); - } - return; - case PIPE_FORMAT_B4G4R4A4_UNORM: - { - ushort p = uc->us; - *r = (ubyte) (((p >> 4) & 0xf0) | ((p >> 8) & 0xf)); - *g = (ubyte) (((p >> 0) & 0xf0) | ((p >> 4) & 0xf)); - *b = (ubyte) (((p << 4) & 0xf0) | ((p >> 0) & 0xf)); - *a = (ubyte) (((p >> 8) & 0xf0) | ((p >> 12) & 0xf)); - } - return; - case PIPE_FORMAT_A8_UNORM: - { - ubyte p = uc->ub; - *r = *g = *b = (ubyte) 0xff; - *a = p; - } - return; - case PIPE_FORMAT_L8_UNORM: - { - ubyte p = uc->ub; - *r = *g = *b = p; - *a = (ubyte) 0xff; - } - return; - case PIPE_FORMAT_I8_UNORM: - { - ubyte p = uc->ub; - *r = *g = *b = *a = p; - } - return; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - { - const float *p = &uc->f[0]; - *r = float_to_ubyte(p[0]); - *g = float_to_ubyte(p[1]); - *b = float_to_ubyte(p[2]); - *a = float_to_ubyte(p[3]); - } - return; - case PIPE_FORMAT_R32G32B32_FLOAT: - { - const float *p = &uc->f[0]; - *r = float_to_ubyte(p[0]); - *g = float_to_ubyte(p[1]); - *b = float_to_ubyte(p[2]); - *a = (ubyte) 0xff; - } - return; - - case PIPE_FORMAT_R32G32_FLOAT: - { - const float *p = &uc->f[0]; - *r = float_to_ubyte(p[0]); - *g = float_to_ubyte(p[1]); - *b = *a = (ubyte) 0xff; - } - return; - - case PIPE_FORMAT_R32_FLOAT: - { - const float *p = &uc->f[0]; - *r = float_to_ubyte(p[0]); - *g = *b = *a = (ubyte) 0xff; - } - return; - - /* Handle other cases with a generic function. - */ - default: - { - ubyte dst[4]; - - util_format_read_4ub(format, dst, 0, uc, 0, 0, 0, 1, 1); - *r = dst[0]; - *g = dst[1]; - *b = dst[2]; - *a = dst[3]; - } - } -} - - -/** - * Note rgba outside [0,1] will be clamped for int pixel formats. - * This will not work (and might not really be useful with float input) - * for pure integer formats (which lack the pack_rgba_float function). - */ -static INLINE void -util_pack_color(const float rgba[4], enum pipe_format format, union util_color *uc) -{ - ubyte r = 0; - ubyte g = 0; - ubyte b = 0; - ubyte a = 0; - - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) <= 8) { - /* format uses 8-bit components or less */ - r = float_to_ubyte(rgba[0]); - g = float_to_ubyte(rgba[1]); - b = float_to_ubyte(rgba[2]); - a = float_to_ubyte(rgba[3]); - } - - switch (format) { - case PIPE_FORMAT_ABGR8888_UNORM: - { - uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | a; - } - return; - case PIPE_FORMAT_XBGR8888_UNORM: - { - uc->ui[0] = (r << 24) | (g << 16) | (b << 8) | 0xff; - } - return; - case PIPE_FORMAT_BGRA8888_UNORM: - { - uc->ui[0] = (a << 24) | (r << 16) | (g << 8) | b; - } - return; - case PIPE_FORMAT_BGRX8888_UNORM: - { - uc->ui[0] = (0xff << 24) | (r << 16) | (g << 8) | b; - } - return; - case PIPE_FORMAT_ARGB8888_UNORM: - { - uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | a; - } - return; - case PIPE_FORMAT_XRGB8888_UNORM: - { - uc->ui[0] = (b << 24) | (g << 16) | (r << 8) | 0xff; - } - return; - case PIPE_FORMAT_B5G6R5_UNORM: - { - uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); - } - return; - case PIPE_FORMAT_B5G5R5X1_UNORM: - { - uc->us = ((0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); - } - return; - case PIPE_FORMAT_B5G5R5A1_UNORM: - { - uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); - } - return; - case PIPE_FORMAT_B4G4R4A4_UNORM: - { - uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4); - } - return; - case PIPE_FORMAT_A8_UNORM: - { - uc->ub = a; - } - return; - case PIPE_FORMAT_L8_UNORM: - case PIPE_FORMAT_I8_UNORM: - { - uc->ub = r; - } - return; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - { - uc->f[0] = rgba[0]; - uc->f[1] = rgba[1]; - uc->f[2] = rgba[2]; - uc->f[3] = rgba[3]; - } - return; - case PIPE_FORMAT_R32G32B32_FLOAT: - { - uc->f[0] = rgba[0]; - uc->f[1] = rgba[1]; - uc->f[2] = rgba[2]; - } - return; - - /* Handle other cases with a generic function. - */ - default: - util_format_write_4f(format, rgba, 0, uc, 0, 0, 0, 1, 1); - } -} - -/* Integer versions of util_pack_z and util_pack_z_stencil - useful for - * constructing clear masks. - */ -static INLINE uint32_t -util_pack_mask_z(enum pipe_format format, uint32_t z) -{ - switch (format) { - case PIPE_FORMAT_Z16_UNORM: - return z & 0xffff; - case PIPE_FORMAT_Z32_UNORM: - case PIPE_FORMAT_Z32_FLOAT: - return z; - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - case PIPE_FORMAT_Z24X8_UNORM: - return z & 0xffffff; - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: - return (z & 0xffffff) << 8; - case PIPE_FORMAT_S8_UINT: - return 0; - default: - debug_print_format("gallium: unhandled format in util_pack_mask_z()", format); - assert(0); - return 0; - } -} - - -static INLINE uint64_t -util_pack64_mask_z(enum pipe_format format, uint32_t z) -{ - switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - return z; - default: - return util_pack_mask_z(format, z); - } -} - - -static INLINE uint32_t -util_pack_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) -{ - uint32_t packed = util_pack_mask_z(format, z); - - switch (format) { - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - packed |= (uint32_t)s << 24; - break; - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - packed |= s; - break; - case PIPE_FORMAT_S8_UINT: - packed |= s; - break; - default: - break; - } - - return packed; -} - - -static INLINE uint64_t -util_pack64_mask_z_stencil(enum pipe_format format, uint32_t z, uint8_t s) -{ - uint64_t packed; - - switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - packed = util_pack64_mask_z(format, z); - packed |= (uint64_t)s << 32ull; - return packed; - default: - return util_pack_mask_z_stencil(format, z, s); - } -} - - -/** - * Note: it's assumed that z is in [0,1] - */ -static INLINE uint32_t -util_pack_z(enum pipe_format format, double z) -{ - union fi fui; - - if (z == 0.0) - return 0; - - switch (format) { - case PIPE_FORMAT_Z16_UNORM: - if (z == 1.0) - return 0xffff; - return (uint32_t) lrint(z * 0xffff); - case PIPE_FORMAT_Z32_UNORM: - /* special-case to avoid overflow */ - if (z == 1.0) - return 0xffffffff; - return (uint32_t) llrint(z * 0xffffffff); - case PIPE_FORMAT_Z32_FLOAT: - fui.f = (float)z; - return fui.ui; - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - case PIPE_FORMAT_Z24X8_UNORM: - if (z == 1.0) - return 0xffffff; - return (uint32_t) lrint(z * 0xffffff); - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: - if (z == 1.0) - return 0xffffff00; - return ((uint32_t) lrint(z * 0xffffff)) << 8; - case PIPE_FORMAT_S8_UINT: - /* this case can get it via util_pack_z_stencil() */ - return 0; - default: - debug_print_format("gallium: unhandled format in util_pack_z()", format); - assert(0); - return 0; - } -} - - -static INLINE uint64_t -util_pack64_z(enum pipe_format format, double z) -{ - union fi fui; - - if (z == 0) - return 0; - - switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - fui.f = (float)z; - return fui.ui; - default: - return util_pack_z(format, z); - } -} - - -/** - * Pack Z and/or stencil values into a 32-bit value described by format. - * Note: it's assumed that z is in [0,1] and s in [0,255] - */ -static INLINE uint32_t -util_pack_z_stencil(enum pipe_format format, double z, uint8_t s) -{ - uint32_t packed = util_pack_z(format, z); - - switch (format) { - case PIPE_FORMAT_Z24_UNORM_S8_UINT: - packed |= (uint32_t)s << 24; - break; - case PIPE_FORMAT_S8_UINT_Z24_UNORM: - packed |= s; - break; - case PIPE_FORMAT_S8_UINT: - packed |= s; - break; - default: - break; - } - - return packed; -} - - -static INLINE uint64_t -util_pack64_z_stencil(enum pipe_format format, double z, uint8_t s) -{ - uint64_t packed; - - switch (format) { - case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT: - packed = util_pack64_z(format, z); - packed |= (uint64_t)s << 32ull; - break; - default: - return util_pack_z_stencil(format, z, s); - } - - return packed; -} - - /** * Pack 4 ubytes into a 4-byte word */ diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 654b5bb..521bfe6 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -325,229 +325,6 @@ no_src_map: #define UBYTE_TO_USHORT(B) ((B) | ((B) << 8)) -/** - * Fallback for pipe->clear_render_target() function. - * XXX this looks too hackish to be really useful. - * cpp > 4 looks like a gross hack at best... - * Plus can't use these transfer fallbacks when clearing - * multisampled surfaces for instance. - * Clears all bound layers. - */ -void -util_clear_render_target(struct pipe_context *pipe, - struct pipe_surface *dst, - const union pipe_color_union *color, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height) -{ - struct pipe_transfer *dst_trans; - ubyte *dst_map; - union util_color uc; - unsigned max_layer; - - assert(dst->texture); - if (!dst->texture) - return; - - if (dst->texture->target == PIPE_BUFFER) { - /* - * The fill naturally works on the surface format, however - * the transfer uses resource format which is just bytes for buffers. - */ - unsigned dx, w; - unsigned pixstride = util_format_get_blocksize(dst->format); - dx = (dst->u.buf.first_element + dstx) * pixstride; - w = width * pixstride; - max_layer = 0; - dst_map = pipe_transfer_map(pipe, - dst->texture, - 0, 0, - PIPE_TRANSFER_WRITE, - dx, 0, w, 1, - &dst_trans); - } - else { - max_layer = dst->u.tex.last_layer - dst->u.tex.first_layer; - dst_map = pipe_transfer_map_3d(pipe, - dst->texture, - dst->u.tex.level, - PIPE_TRANSFER_WRITE, - dstx, dsty, dst->u.tex.first_layer, - width, height, max_layer + 1, &dst_trans); - } - - assert(dst_map); - - if (dst_map) { - enum pipe_format format = dst->format; - assert(dst_trans->stride > 0); - - if (util_format_is_pure_integer(format)) { - /* - * We expect int/uint clear values here, though some APIs - * might disagree (but in any case util_pack_color() - * couldn't handle it)... - */ - if (util_format_is_pure_sint(format)) { - util_format_write_4i(format, color->i, 0, &uc, 0, 0, 0, 1, 1); - } - else { - assert(util_format_is_pure_uint(format)); - util_format_write_4ui(format, color->ui, 0, &uc, 0, 0, 0, 1, 1); - } - } - else { - util_pack_color(color->f, dst->format, &uc); - } - - util_fill_box(dst_map, dst->format, - dst_trans->stride, dst_trans->layer_stride, - 0, 0, 0, width, height, max_layer + 1, &uc); - - pipe->transfer_unmap(pipe, dst_trans); - } -} - -/** - * Fallback for pipe->clear_stencil() function. - * sw fallback doesn't look terribly useful here. - * Plus can't use these transfer fallbacks when clearing - * multisampled surfaces for instance. - * Clears all bound layers. - */ -void -util_clear_depth_stencil(struct pipe_context *pipe, - struct pipe_surface *dst, - unsigned clear_flags, - double depth, - unsigned stencil, - unsigned dstx, unsigned dsty, - unsigned width, unsigned height) -{ - enum pipe_format format = dst->format; - struct pipe_transfer *dst_trans; - ubyte *dst_map; - boolean need_rmw = FALSE; - unsigned max_layer, layer; - - if ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) && - ((clear_flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) && - util_format_is_depth_and_stencil(format)) - need_rmw = TRUE; - - assert(dst->texture); - if (!dst->texture) - return; - - max_layer = dst->u.tex.last_layer - dst->u.tex.first_layer; - dst_map = pipe_transfer_map_3d(pipe, - dst->texture, - dst->u.tex.level, - (need_rmw ? PIPE_TRANSFER_READ_WRITE : - PIPE_TRANSFER_WRITE), - dstx, dsty, dst->u.tex.first_layer, - width, height, max_layer + 1, &dst_trans); - assert(dst_map); - - if (dst_map) { - unsigned dst_stride = dst_trans->stride; - uint64_t zstencil = util_pack64_z_stencil(format, depth, stencil); - ubyte *dst_layer = dst_map; - unsigned i, j; - assert(dst_trans->stride > 0); - - for (layer = 0; layer <= max_layer; layer++) { - dst_map = dst_layer; - - switch (util_format_get_blocksize(format)) { - case 1: - assert(format == PIPE_FORMAT_S8_UINT); - if(dst_stride == width) - memset(dst_map, (uint8_t) zstencil, height * width); - else { - for (i = 0; i < height; i++) { - memset(dst_map, (uint8_t) zstencil, width); - dst_map += dst_stride; - } - } - break; - case 2: - assert(format == PIPE_FORMAT_Z16_UNORM); - for (i = 0; i < height; i++) { - uint16_t *row = (uint16_t *)dst_map; - for (j = 0; j < width; j++) - *row++ = (uint16_t) zstencil; - dst_map += dst_stride; - } - break; - case 4: - if (!need_rmw) { - for (i = 0; i < height; i++) { - uint32_t *row = (uint32_t *)dst_map; - for (j = 0; j < width; j++) - *row++ = (uint32_t) zstencil; - dst_map += dst_stride; - } - } - else { - uint32_t dst_mask; - if (format == PIPE_FORMAT_Z24_UNORM_S8_UINT) - dst_mask = 0x00ffffff; - else { - assert(format == PIPE_FORMAT_S8_UINT_Z24_UNORM); - dst_mask = 0xffffff00; - } - if (clear_flags & PIPE_CLEAR_DEPTH) - dst_mask = ~dst_mask; - for (i = 0; i < height; i++) { - uint32_t *row = (uint32_t *)dst_map; - for (j = 0; j < width; j++) { - uint32_t tmp = *row & dst_mask; - *row++ = tmp | ((uint32_t) zstencil & ~dst_mask); - } - dst_map += dst_stride; - } - } - break; - case 8: - if (!need_rmw) { - for (i = 0; i < height; i++) { - uint64_t *row = (uint64_t *)dst_map; - for (j = 0; j < width; j++) - *row++ = zstencil; - dst_map += dst_stride; - } - } - else { - uint64_t src_mask; - - if (clear_flags & PIPE_CLEAR_DEPTH) - src_mask = 0x00000000ffffffffull; - else - src_mask = 0x000000ff00000000ull; - - for (i = 0; i < height; i++) { - uint64_t *row = (uint64_t *)dst_map; - for (j = 0; j < width; j++) { - uint64_t tmp = *row & ~src_mask; - *row++ = tmp | (zstencil & src_mask); - } - dst_map += dst_stride; - } - } - break; - default: - assert(0); - break; - } - dst_layer += dst_trans->layer_stride; - } - - pipe->transfer_unmap(pipe, dst_trans); - } -} - - /* Return if the box is totally inside the resource. */ static boolean