diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2012-07-13 12:43:36 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2012-07-13 12:43:36 +0000 |
commit | 7d3eb3cd29c542495050f7f2337fa879c1e77392 (patch) | |
tree | c93900e6e1ff6cab75621c6a3ea7546a5532749b /lib | |
parent | 768fd44d7ce6ca834927bcee4902698a2de487b8 (diff) |
Import the infrastructure for building Gallium3D graphics drivers.
Currently only software drivers are supported, looks ok to matthieu.
Diffstat (limited to 'lib')
22 files changed, 40127 insertions, 0 deletions
diff --git a/lib/libGL/gallium/Makefile b/lib/libGL/gallium/Makefile new file mode 100644 index 000000000..6acdc673c --- /dev/null +++ b/lib/libGL/gallium/Makefile @@ -0,0 +1,7 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/13 12:43:30 mpi Exp $ + +SUBDIR= libgallium libmesagallium drivers + +build depend all install clean cleandir: _SUBDIRUSE + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/Makefile.inc b/lib/libGL/gallium/Makefile.inc new file mode 100644 index 000000000..311655ad9 --- /dev/null +++ b/lib/libGL/gallium/Makefile.inc @@ -0,0 +1,49 @@ +# $OpenBSD: Makefile.inc,v 1.1.1.1 2012/07/13 12:43:30 mpi Exp $ + +CPP= cpp -notraditional + +OBJS+= ${SRCS:N*.h:R:S/$/.so/g} + +.SUFFIXES: +.SUFFIXES: .a .c .cpp .o .so + +.c.so: + @echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}" + @${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o + @${LD} -X -r ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +.cpp.so: + @echo "${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}" + @${COMPILE.cc} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o + @${LD} -X -r ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +lib${LIB}_pic.a: ${OBJS} ${DPADD} + @rm -f lib${LIB}_pic.a + @${AR} cq lib${LIB}_pic.a `${LORDER} ${OBJS} | tsort -q` + ${RANLIB} lib${LIB}_pic.a + + +.ifdef XENOCARA_HAVE_LLVM +LLVM_VERSION= 0x301 # 3.1 +LLVM_CONFIG?= /usr/local/bin/llvm-config + +LLVM_CFLAGS!= ${LLVM_CONFIG} --cflags +LLVM_CPPFLAGS!= ${LLVM_CONFIG} --cxxflags +LLVM_LDFLAGS!= ${LLVM_CONFIG} --ldflags +LLVM_LIBS!= ${LLVM_CONFIG} --libs engine + +CFLAGS+= ${LLVM_CFLAGS} -std=gnu99 +CXXFLAGS= ${LLVM_CPPFLAGS} +LDADD+= ${LLVM_LDFLAGS} ${LLVM_LIBS} + +CPPFLAGS+= \ + -DGALLIUM_LLVMPIPE \ + -DHAVE_LLVM=${LLVM_VERSION} +.endif + + +.if ${MACHINE_ARCH} == powerpc || ${MACHINE_ARCH} == sparc +PICFLAG=-fPIC +.endif diff --git a/lib/libGL/gallium/drivers/Makefile b/lib/libGL/gallium/drivers/Makefile new file mode 100644 index 000000000..11265f2a7 --- /dev/null +++ b/lib/libGL/gallium/drivers/Makefile @@ -0,0 +1,11 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +SUBDIR= rbug softpipe trace + +.ifdef XENOCARA_HAVE_LLVM +SUBDIR+= llvmpipe +.endif + +build depend all install clean cleandir: _SUBDIRUSE + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/drivers/Makefile.inc b/lib/libGL/gallium/drivers/Makefile.inc new file mode 100644 index 000000000..974cc3dab --- /dev/null +++ b/lib/libGL/gallium/drivers/Makefile.inc @@ -0,0 +1,23 @@ +# $OpenBSD: Makefile.inc,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +GALLIUM= ${.CURDIR}/../../../../../dist/Mesa/src/gallium + +CPPFLAGS+= \ + -I${GALLIUM}/auxiliary \ + -I${GALLIUM}/include + +all: lib${LIB}_pic.a + +obj: _xenocara_obj + +install: + @echo "Not installing lib${LIB}" + +clean: + rm -f lib${LIB}_pic.a ${OBJS} + +cleandir: clean + +.PATH: ${GALLIUM}/drivers/${LIB} + +.include "../Makefile.inc" diff --git a/lib/libGL/gallium/drivers/llvmpipe/Makefile b/lib/libGL/gallium/drivers/llvmpipe/Makefile new file mode 100644 index 000000000..5953cebaa --- /dev/null +++ b/lib/libGL/gallium/drivers/llvmpipe/Makefile @@ -0,0 +1,56 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +LIB = llvmpipe + +SRCS = \ + lp_bld_alpha.c \ + lp_bld_blend_aos.c \ + lp_bld_blend_logicop.c \ + lp_bld_blend_soa.c \ + lp_bld_depth.c \ + lp_bld_interp.c \ + lp_clear.c \ + lp_context.c \ + lp_draw_arrays.c \ + lp_fence.c \ + lp_flush.c \ + lp_jit.c \ + lp_memory.c \ + lp_perf.c \ + lp_query.c \ + lp_rast.c \ + lp_rast_debug.c \ + lp_rast_tri.c \ + lp_scene.c \ + lp_scene_queue.c \ + lp_screen.c \ + lp_setup.c \ + lp_setup_line.c \ + lp_setup_point.c \ + lp_setup_tri.c \ + lp_setup_vbuf.c \ + lp_state_blend.c \ + lp_state_clip.c \ + lp_state_derived.c \ + lp_state_fs.c \ + lp_state_setup.c \ + lp_state_gs.c \ + lp_state_rasterizer.c \ + lp_state_sampler.c \ + lp_state_so.c \ + lp_state_surface.c \ + lp_state_vertex.c \ + lp_state_vs.c \ + lp_surface.c \ + lp_tex_sample.c \ + lp_texture.c \ + lp_tile_image.c \ + lp_tile_soa.c + +CPPFLAGS+= -I${GALLIUM}/drivers/llvmpipe + +lp_test_sincos.o: sse_mathfun.h + +.include <bsd.xorg.mk> + +.PATH: ${.CURDIR}/generated diff --git a/lib/libGL/gallium/drivers/llvmpipe/generated/Makefile b/lib/libGL/gallium/drivers/llvmpipe/generated/Makefile new file mode 100644 index 000000000..afd593ed7 --- /dev/null +++ b/lib/libGL/gallium/drivers/llvmpipe/generated/Makefile @@ -0,0 +1,30 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +AUX= ${.CURDIR}/../../../../../../dist/Mesa/src/gallium/auxiliary +DEV= ${.CURDIR}/../../../../../../dist/Mesa/src/gallium/drivers + +PYTHON= python${PYTHON_VERSION} +PYTHON_FLAGS= -t -O -O + +GENERATED= lp_tile_soa.c + +all: ${GENERATED} + +obj: + +depend: + +install: + +clean distclean: + rm -f ${GENERATED} + +lp_tile_soa.c: lp_tile_soa.py u_format_parse.py u_format_pack.py u_format.csv + $(PYTHON) $(PYTHON_FLAGS) ${DEV}/llvmpipe/lp_tile_soa.py ${AUX}/util/u_format.csv > $@ + +.SUFFIXES: .py .csv + +.PATH: ${DEV}/llvmpipe +.PATH: ${AUX}/util + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/drivers/llvmpipe/generated/lp_tile_soa.c b/lib/libGL/gallium/drivers/llvmpipe/generated/lp_tile_soa.c new file mode 100644 index 000000000..936bad915 --- /dev/null +++ b/lib/libGL/gallium/drivers/llvmpipe/generated/lp_tile_soa.c @@ -0,0 +1,4936 @@ +/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */ + +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +/** + * @file + * Pixel format accessor functions. + * + * @author Jose Fonseca <jfonseca@vmware.com> + */ + +#include "pipe/p_compiler.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_half.h" +#include "util/u_cpu_detect.h" +#include "lp_tile_soa.h" + +#ifdef DEBUG +unsigned lp_tile_unswizzle_count = 0; +unsigned lp_tile_swizzle_count = 0; +#endif + +const unsigned char +tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = { + { 0, 1, 4, 5}, + { 2, 3, 6, 7}, + { 8, 9, 12, 13}, + { 10, 11, 14, 15} +}; + +/* Note: these lookup tables could be replaced with some + * bit-twiddling code, but this is a little faster. + */ +static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = { + 0, 1, 0, 1, 2, 3, 2, 3, + 0, 1, 0, 1, 2, 3, 2, 3 +}; + +static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = { + 0, 0, 1, 1, 0, 0, 1, 1, + 2, 2, 3, 3, 2, 2, 3, 3 +}; + + +#if defined(PIPE_ARCH_SSE) + +#include "util/u_sse.h" + +static ALWAYS_INLINE void +swz4( const __m128i * restrict x, + const __m128i * restrict y, + const __m128i * restrict z, + const __m128i * restrict w, + __m128i * restrict a, + __m128i * restrict b, + __m128i * restrict c, + __m128i * restrict d) +{ + __m128i i, j, k, l; + __m128i m, n, o, p; + __m128i e, f, g, h; + + m = _mm_unpacklo_epi8(*x,*y); + n = _mm_unpackhi_epi8(*x,*y); + o = _mm_unpacklo_epi8(*z,*w); + p = _mm_unpackhi_epi8(*z,*w); + + i = _mm_unpacklo_epi16(m,n); + j = _mm_unpackhi_epi16(m,n); + k = _mm_unpacklo_epi16(o,p); + l = _mm_unpackhi_epi16(o,p); + + e = _mm_unpacklo_epi8(i,j); + f = _mm_unpackhi_epi8(i,j); + g = _mm_unpacklo_epi8(k,l); + h = _mm_unpackhi_epi8(k,l); + + *a = _mm_unpacklo_epi64(e,g); + *b = _mm_unpackhi_epi64(e,g); + *c = _mm_unpacklo_epi64(f,h); + *d = _mm_unpackhi_epi64(f,h); +} + +static ALWAYS_INLINE void +unswz4( const __m128i * restrict a, + const __m128i * restrict b, + const __m128i * restrict c, + const __m128i * restrict d, + __m128i * restrict x, + __m128i * restrict y, + __m128i * restrict z, + __m128i * restrict w) +{ + __m128i i, j, k, l; + __m128i m, n, o, p; + + i = _mm_unpacklo_epi8(*a,*b); + j = _mm_unpackhi_epi8(*a,*b); + k = _mm_unpacklo_epi8(*c,*d); + l = _mm_unpackhi_epi8(*c,*d); + + m = _mm_unpacklo_epi16(i,k); + n = _mm_unpackhi_epi16(i,k); + o = _mm_unpacklo_epi16(j,l); + p = _mm_unpackhi_epi16(j,l); + + *x = _mm_unpacklo_epi64(m,n); + *y = _mm_unpackhi_epi64(m,n); + *z = _mm_unpacklo_epi64(o,p); + *w = _mm_unpackhi_epi64(o,p); +} + +static void +lp_tile_b8g8r8a8_unorm_swizzle_4ub_sse2(uint8_t * restrict dst, + const uint8_t * restrict src, unsigned src_stride, + unsigned x0, unsigned y0) +{ + __m128i *dst128 = (__m128i *) dst; + unsigned x, y; + + src += y0 * src_stride; + src += x0 * sizeof(uint32_t); + + for (y = 0; y < TILE_SIZE; y += 4) { + const uint8_t *src_row = src; + + for (x = 0; x < TILE_SIZE; x += 4) { + swz4((const __m128i *) (src_row + 0 * src_stride), + (const __m128i *) (src_row + 1 * src_stride), + (const __m128i *) (src_row + 2 * src_stride), + (const __m128i *) (src_row + 3 * src_stride), + dst128 + 2, /* b */ + dst128 + 1, /* g */ + dst128 + 0, /* r */ + dst128 + 3); /* a */ + + dst128 += 4; + src_row += sizeof(__m128i); + } + + src += 4 * src_stride; + } +} + +static void +lp_tile_b8g8r8a8_unorm_unswizzle_4ub_sse2(const uint8_t * restrict src, + uint8_t * restrict dst, unsigned dst_stride, + unsigned x0, unsigned y0) +{ + unsigned int x, y; + const __m128i *src128 = (const __m128i *) src; + + dst += y0 * dst_stride; + dst += x0 * sizeof(uint32_t); + + for (y = 0; y < TILE_SIZE; y += 4) { + const uint8_t *dst_row = dst; + + for (x = 0; x < TILE_SIZE; x += 4) { + unswz4( &src128[2], /* b */ + &src128[1], /* g */ + &src128[0], /* r */ + &src128[3], /* a */ + (__m128i *) (dst_row + 0 * dst_stride), + (__m128i *) (dst_row + 1 * dst_stride), + (__m128i *) (dst_row + 2 * dst_stride), + (__m128i *) (dst_row + 3 * dst_stride)); + + src128 += 4; + dst_row += sizeof(__m128i);; + } + + dst += 4 * dst_stride; + } +} + +#endif /* PIPE_ARCH_SSE */ + +static void +lp_tile_none_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b8g8r8a8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + uint8_t a; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b8g8r8x8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + ++src_pixel; + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_a8r8g8b8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t a; + uint8_t r; + uint8_t g; + uint8_t b; + a = (*src_pixel++); + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_x8r8g8b8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + ++src_pixel; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_a8b8g8r8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t a; + uint8_t b; + uint8_t g; + uint8_t r; + a = (*src_pixel++); + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_x8b8g8r8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + ++src_pixel; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8x8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + ++src_pixel; + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b5g5r5x1_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t b = (uint8_t)(((uint32_t)(pixel & 0x1f)) * 0xff / 0x1f); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 5) & 0x1f)) * 0xff / 0x1f); + uint8_t r = (uint8_t)(((uint32_t)((pixel >> 10) & 0x1f)) * 0xff / 0x1f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b5g5r5a1_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t b = (uint8_t)(((uint32_t)(pixel & 0x1f)) * 0xff / 0x1f); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 5) & 0x1f)) * 0xff / 0x1f); + uint8_t r = (uint8_t)(((uint32_t)((pixel >> 10) & 0x1f)) * 0xff / 0x1f); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 15)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b4g4r4a4_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t b = (uint8_t)(((uint32_t)(pixel & 0xf)) * 0xff / 0xf); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 4) & 0xf)) * 0xff / 0xf); + uint8_t r = (uint8_t)(((uint32_t)((pixel >> 8) & 0xf)) * 0xff / 0xf); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 12)) * 0xff / 0xf); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b4g4r4x4_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t b = (uint8_t)(((uint32_t)(pixel & 0xf)) * 0xff / 0xf); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 4) & 0xf)) * 0xff / 0xf); + uint8_t r = (uint8_t)(((uint32_t)((pixel >> 8) & 0xf)) * 0xff / 0xf); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b5g6r5_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t b = (uint8_t)(((uint32_t)(pixel & 0x1f)) * 0xff / 0x1f); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 5) & 0x3f)) * 0xff / 0x3f); + uint8_t r = (uint8_t)(((uint32_t)(pixel >> 11)) * 0xff / 0x1f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r10g10b10a2_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t r = (uint8_t)((pixel & 0x3ff) >> 2); + uint8_t g = (uint8_t)(((pixel >> 10) & 0x3ff) >> 2); + uint8_t b = (uint8_t)(((pixel >> 20) & 0x3ff) >> 2); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 30)) * 0xff / 0x3); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b10g10r10a2_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t b = (uint8_t)((pixel & 0x3ff) >> 2); + uint8_t g = (uint8_t)(((pixel >> 10) & 0x3ff) >> 2); + uint8_t r = (uint8_t)(((pixel >> 20) & 0x3ff) >> 2); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 30)) * 0xff / 0x3); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgb; + rgb = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_a8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t a; + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = 0; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_i8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgba; + rgba = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = rgba; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgba; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgba; /* b */ + TILE_PIXEL(dst, x, y, 3) = rgba; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l4a4_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t pixel = *src_pixel++; + uint8_t rgb = (uint8_t)(((uint32_t)(pixel & 0xf)) * 0xff / 0xf); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 4)) * 0xff / 0xf); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l8a8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgb; + uint8_t a; + rgb = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l16_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgb; + rgb = (uint8_t)((*src_pixel++) >> 8); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgb; + rgb = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_l8a8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t rgb; + uint8_t a; + rgb = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = rgb; /* r */ + TILE_PIXEL(dst, x, y, 1) = rgb; /* g */ + TILE_PIXEL(dst, x, y, 2) = rgb; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8a8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_a8b8g8r8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t a; + uint8_t b; + uint8_t g; + uint8_t r; + a = (*src_pixel++); + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_x8b8g8r8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + ++src_pixel; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b8g8r8a8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + uint8_t a; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_b8g8r8x8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t b; + uint8_t g; + uint8_t r; + b = (*src_pixel++); + g = (*src_pixel++); + r = (*src_pixel++); + ++src_pixel; + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_a8r8g8b8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t a; + uint8_t r; + uint8_t g; + uint8_t b; + a = (*src_pixel++); + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_x8r8g8b8_srgb_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + ++src_pixel; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8sg8sb8ux8u_norm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + b = (*src_pixel++); + ++src_pixel; + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r10sg10sb10sa2u_norm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t r = (uint8_t)((pixel & 0x3ff) >> 1); + uint8_t g = (uint8_t)(((pixel >> 10) & 0x3ff) >> 1); + uint8_t b = (uint8_t)(((pixel >> 20) & 0x3ff) >> 1); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 30)) * 0xff / 0x3); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r5sg5sb6u_norm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = *src_pixel++; + uint8_t r = (uint8_t)(((uint32_t)(pixel & 0x1f)) * 0xff / 0xf); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 5) & 0x1f)) * 0xff / 0xf); + uint8_t b = (uint8_t)(((uint32_t)(pixel >> 10)) * 0xff / 0x3f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r10g10b10a2_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t r = (uint8_t)(((uint32_t)(pixel & 0x3ff)) * 0xff / 0x1); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 10) & 0x3ff)) * 0xff / 0x1); + uint8_t b = (uint8_t)(((uint32_t)((pixel >> 20) & 0x3ff)) * 0xff / 0x1); + uint8_t a = (uint8_t)(((uint32_t)(pixel >> 30)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r64_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const double *src_pixel = (const double *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)((*src_pixel++) * 0xff); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r64g64_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const double *src_pixel = (const double *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)((*src_pixel++) * 0xff); + g = (uint8_t)((*src_pixel++) * 0xff); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r64g64b64_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const double *src_pixel = (const double *)(src_row + x0*24); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)((*src_pixel++) * 0xff); + g = (uint8_t)((*src_pixel++) * 0xff); + b = (uint8_t)((*src_pixel++) * 0xff); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r64g64b64a64_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const double *src_pixel = (const double *)(src_row + x0*32); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)((*src_pixel++) * 0xff); + g = (uint8_t)((*src_pixel++) * 0xff); + b = (uint8_t)((*src_pixel++) * 0xff); + a = (uint8_t)((*src_pixel++) * 0xff); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const float *src_pixel = (const float *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = float_to_ubyte((*src_pixel++)); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const float *src_pixel = (const float *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = float_to_ubyte((*src_pixel++)); + g = float_to_ubyte((*src_pixel++)); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const float *src_pixel = (const float *)(src_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = float_to_ubyte((*src_pixel++)); + g = float_to_ubyte((*src_pixel++)); + b = float_to_ubyte((*src_pixel++)); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32a32_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const float *src_pixel = (const float *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = float_to_ubyte((*src_pixel++)); + g = float_to_ubyte((*src_pixel++)); + b = float_to_ubyte((*src_pixel++)); + a = float_to_ubyte((*src_pixel++)); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)((*src_pixel++) >> 24); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)((*src_pixel++) >> 24); + g = (uint8_t)((*src_pixel++) >> 24); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)((*src_pixel++) >> 24); + g = (uint8_t)((*src_pixel++) >> 24); + b = (uint8_t)((*src_pixel++) >> 24); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32a32_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)((*src_pixel++) >> 24); + g = (uint8_t)((*src_pixel++) >> 24); + b = (uint8_t)((*src_pixel++) >> 24); + a = (uint8_t)((*src_pixel++) >> 24); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32a32_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)((*src_pixel++) >> 23); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)((*src_pixel++) >> 23); + g = (uint8_t)((*src_pixel++) >> 23); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)((*src_pixel++) >> 23); + g = (uint8_t)((*src_pixel++) >> 23); + b = (uint8_t)((*src_pixel++) >> 23); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32a32_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)((*src_pixel++) >> 23); + g = (uint8_t)((*src_pixel++) >> 23); + b = (uint8_t)((*src_pixel++) >> 23); + a = (uint8_t)((*src_pixel++) >> 23); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r32g32b32a32_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int32_t *src_pixel = (const int32_t *)(src_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint64_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = float_to_ubyte(util_half_to_float((*src_pixel++))); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = float_to_ubyte(util_half_to_float((*src_pixel++))); + g = float_to_ubyte(util_half_to_float((*src_pixel++))); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = float_to_ubyte(util_half_to_float((*src_pixel++))); + g = float_to_ubyte(util_half_to_float((*src_pixel++))); + b = float_to_ubyte(util_half_to_float((*src_pixel++))); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16a16_float_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = float_to_ubyte(util_half_to_float((*src_pixel++))); + g = float_to_ubyte(util_half_to_float((*src_pixel++))); + b = float_to_ubyte(util_half_to_float((*src_pixel++))); + a = float_to_ubyte(util_half_to_float((*src_pixel++))); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)((*src_pixel++) >> 8); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)((*src_pixel++) >> 8); + g = (uint8_t)((*src_pixel++) >> 8); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)((*src_pixel++) >> 8); + g = (uint8_t)((*src_pixel++) >> 8); + b = (uint8_t)((*src_pixel++) >> 8); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16a16_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)((*src_pixel++) >> 8); + g = (uint8_t)((*src_pixel++) >> 8); + b = (uint8_t)((*src_pixel++) >> 8); + a = (uint8_t)((*src_pixel++) >> 8); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16a16_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint16_t *src_pixel = (const uint16_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)((*src_pixel++) >> 7); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)((*src_pixel++) >> 7); + g = (uint8_t)((*src_pixel++) >> 7); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)((*src_pixel++) >> 7); + g = (uint8_t)((*src_pixel++) >> 7); + b = (uint8_t)((*src_pixel++) >> 7); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16a16_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)((*src_pixel++) >> 7); + g = (uint8_t)((*src_pixel++) >> 7); + b = (uint8_t)((*src_pixel++) >> 7); + a = (uint8_t)((*src_pixel++) >> 7); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r16g16b16a16_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int16_t *src_pixel = (const int16_t *)(src_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (*src_pixel++); + g = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8a8_unorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (*src_pixel++); + g = (*src_pixel++); + b = (*src_pixel++); + a = (*src_pixel++); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8a8_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint8_t *src_pixel = (const uint8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8a8_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + a = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x7f); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = 0; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = 0; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r8g8b8a8_sscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const int8_t *src_pixel = (const int8_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint8_t r; + uint8_t g; + uint8_t b; + uint8_t a; + r = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + g = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + b = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + a = (uint8_t)(((uint32_t)(*src_pixel++)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = a; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r10g10b10x2_uscaled_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t r = (uint8_t)(((uint32_t)(pixel & 0x3ff)) * 0xff / 0x1); + uint8_t g = (uint8_t)(((uint32_t)((pixel >> 10) & 0x3ff)) * 0xff / 0x1); + uint8_t b = (uint8_t)(((uint32_t)((pixel >> 20) & 0x3ff)) * 0xff / 0x1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +static void +lp_tile_r10g10b10x2_snorm_swizzle_4ub(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + const uint8_t *src_row = src + y0*src_stride; + for (y = 0; y < TILE_SIZE; ++y) { + const uint32_t *src_pixel = (const uint32_t *)(src_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = *src_pixel++; + uint8_t r = (uint8_t)((pixel & 0x3ff) >> 1); + uint8_t g = (uint8_t)(((pixel >> 10) & 0x3ff) >> 1); + uint8_t b = (uint8_t)(((pixel >> 20) & 0x3ff) >> 1); + TILE_PIXEL(dst, x, y, 0) = r; /* r */ + TILE_PIXEL(dst, x, y, 1) = g; /* g */ + TILE_PIXEL(dst, x, y, 2) = b; /* b */ + TILE_PIXEL(dst, x, y, 3) = 255; /* a */ + } + src_row += src_stride; + } +} + +void +lp_tile_swizzle_4ub(enum pipe_format format, uint8_t *dst, const void *src, unsigned src_stride, unsigned x, unsigned y) +{ + void (*func)(uint8_t *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0); +#ifdef DEBUG + lp_tile_swizzle_count += 1; +#endif + switch(format) { + case PIPE_FORMAT_NONE: + func = lp_tile_none_swizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8A8_UNORM: +#ifdef PIPE_ARCH_SSE + func = util_cpu_caps.has_sse2 ? lp_tile_b8g8r8a8_unorm_swizzle_4ub_sse2 : lp_tile_b8g8r8a8_unorm_swizzle_4ub; +#else + func = lp_tile_b8g8r8a8_unorm_swizzle_4ub; +#endif + break; + case PIPE_FORMAT_B8G8R8X8_UNORM: + func = lp_tile_b8g8r8x8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_A8R8G8B8_UNORM: + func = lp_tile_a8r8g8b8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_X8R8G8B8_UNORM: + func = lp_tile_x8r8g8b8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_A8B8G8R8_UNORM: + func = lp_tile_a8b8g8r8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_X8B8G8R8_UNORM: + func = lp_tile_x8b8g8r8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8X8_UNORM: + func = lp_tile_r8g8b8x8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B5G5R5X1_UNORM: + func = lp_tile_b5g5r5x1_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B5G5R5A1_UNORM: + func = lp_tile_b5g5r5a1_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B4G4R4A4_UNORM: + func = lp_tile_b4g4r4a4_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B4G4R4X4_UNORM: + func = lp_tile_b4g4r4x4_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B5G6R5_UNORM: + func = lp_tile_b5g6r5_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10A2_UNORM: + func = lp_tile_r10g10b10a2_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_B10G10R10A2_UNORM: + func = lp_tile_b10g10r10a2_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_L8_UNORM: + func = lp_tile_l8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_A8_UNORM: + func = lp_tile_a8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_I8_UNORM: + func = lp_tile_i8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_L4A4_UNORM: + func = lp_tile_l4a4_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_L8A8_UNORM: + func = lp_tile_l8a8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_L16_UNORM: + func = lp_tile_l16_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_L8_SRGB: + func = lp_tile_l8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_L8A8_SRGB: + func = lp_tile_l8a8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SRGB: + func = lp_tile_r8g8b8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SRGB: + func = lp_tile_r8g8b8a8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_A8B8G8R8_SRGB: + func = lp_tile_a8b8g8r8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_X8B8G8R8_SRGB: + func = lp_tile_x8b8g8r8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8A8_SRGB: + func = lp_tile_b8g8r8a8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8X8_SRGB: + func = lp_tile_b8g8r8x8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_A8R8G8B8_SRGB: + func = lp_tile_a8r8g8b8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_X8R8G8B8_SRGB: + func = lp_tile_x8r8g8b8_srgb_swizzle_4ub; + break; + case PIPE_FORMAT_R8SG8SB8UX8U_NORM: + func = lp_tile_r8sg8sb8ux8u_norm_swizzle_4ub; + break; + case PIPE_FORMAT_R10SG10SB10SA2U_NORM: + func = lp_tile_r10sg10sb10sa2u_norm_swizzle_4ub; + break; + case PIPE_FORMAT_R5SG5SB6U_NORM: + func = lp_tile_r5sg5sb6u_norm_swizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10A2_USCALED: + func = lp_tile_r10g10b10a2_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R64_FLOAT: + func = lp_tile_r64_float_swizzle_4ub; + break; + case PIPE_FORMAT_R64G64_FLOAT: + func = lp_tile_r64g64_float_swizzle_4ub; + break; + case PIPE_FORMAT_R64G64B64_FLOAT: + func = lp_tile_r64g64b64_float_swizzle_4ub; + break; + case PIPE_FORMAT_R64G64B64A64_FLOAT: + func = lp_tile_r64g64b64a64_float_swizzle_4ub; + break; + case PIPE_FORMAT_R32_FLOAT: + func = lp_tile_r32_float_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32_FLOAT: + func = lp_tile_r32g32_float_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_FLOAT: + func = lp_tile_r32g32b32_float_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + func = lp_tile_r32g32b32a32_float_swizzle_4ub; + break; + case PIPE_FORMAT_R32_UNORM: + func = lp_tile_r32_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32_UNORM: + func = lp_tile_r32g32_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_UNORM: + func = lp_tile_r32g32b32_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_UNORM: + func = lp_tile_r32g32b32a32_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32_USCALED: + func = lp_tile_r32_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32_USCALED: + func = lp_tile_r32g32_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_USCALED: + func = lp_tile_r32g32b32_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_USCALED: + func = lp_tile_r32g32b32a32_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32_SNORM: + func = lp_tile_r32_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32_SNORM: + func = lp_tile_r32g32_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_SNORM: + func = lp_tile_r32g32b32_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_SNORM: + func = lp_tile_r32g32b32a32_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R32_SSCALED: + func = lp_tile_r32_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32_SSCALED: + func = lp_tile_r32g32_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_SSCALED: + func = lp_tile_r32g32b32_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_SSCALED: + func = lp_tile_r32g32b32a32_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16_FLOAT: + func = lp_tile_r16_float_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16_FLOAT: + func = lp_tile_r16g16_float_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_FLOAT: + func = lp_tile_r16g16b16_float_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_FLOAT: + func = lp_tile_r16g16b16a16_float_swizzle_4ub; + break; + case PIPE_FORMAT_R16_UNORM: + func = lp_tile_r16_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16_UNORM: + func = lp_tile_r16g16_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_UNORM: + func = lp_tile_r16g16b16_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_UNORM: + func = lp_tile_r16g16b16a16_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16_USCALED: + func = lp_tile_r16_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16_USCALED: + func = lp_tile_r16g16_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_USCALED: + func = lp_tile_r16g16b16_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_USCALED: + func = lp_tile_r16g16b16a16_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16_SNORM: + func = lp_tile_r16_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16_SNORM: + func = lp_tile_r16g16_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_SNORM: + func = lp_tile_r16g16b16_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_SNORM: + func = lp_tile_r16g16b16a16_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R16_SSCALED: + func = lp_tile_r16_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16_SSCALED: + func = lp_tile_r16g16_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_SSCALED: + func = lp_tile_r16g16b16_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_SSCALED: + func = lp_tile_r16g16b16a16_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8_UNORM: + func = lp_tile_r8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8_UNORM: + func = lp_tile_r8g8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_UNORM: + func = lp_tile_r8g8b8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_UNORM: + func = lp_tile_r8g8b8a8_unorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8_USCALED: + func = lp_tile_r8_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8_USCALED: + func = lp_tile_r8g8_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_USCALED: + func = lp_tile_r8g8b8_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_USCALED: + func = lp_tile_r8g8b8a8_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8_SNORM: + func = lp_tile_r8_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8_SNORM: + func = lp_tile_r8g8_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SNORM: + func = lp_tile_r8g8b8_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SNORM: + func = lp_tile_r8g8b8a8_snorm_swizzle_4ub; + break; + case PIPE_FORMAT_R8_SSCALED: + func = lp_tile_r8_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8_SSCALED: + func = lp_tile_r8g8_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SSCALED: + func = lp_tile_r8g8b8_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SSCALED: + func = lp_tile_r8g8b8a8_sscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10X2_USCALED: + func = lp_tile_r10g10b10x2_uscaled_swizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10X2_SNORM: + func = lp_tile_r10g10b10x2_snorm_swizzle_4ub; + break; + default: + debug_printf("%s: unsupported format %s\n", __FUNCTION__, util_format_name(format)); + return; + } + func(dst, (const uint8_t *)src, src_stride, x, y); +} + +static void +lp_tile_none_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint8_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0); + const uint32_t pixel1 = (((uint8_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b8g8r8a8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((b[i+0]) << 0) | ((g[i+0]) << 8) | ((r[i+0]) << 16) | ((a[i+0]) << 24); + const uint32_t pixel1 = ((b[i+1]) << 0) | ((g[i+1]) << 8) | ((r[i+1]) << 16) | ((a[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b8g8r8x8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((b[i+0]) << 0) | ((g[i+0]) << 8) | ((r[i+0]) << 16); + const uint32_t pixel1 = ((b[i+1]) << 0) | ((g[i+1]) << 8) | ((r[i+1]) << 16); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_a8r8g8b8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((a[i+0]) << 0) | ((r[i+0]) << 8) | ((g[i+0]) << 16) | ((b[i+0]) << 24); + const uint32_t pixel1 = ((a[i+1]) << 0) | ((r[i+1]) << 8) | ((g[i+1]) << 16) | ((b[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_x8r8g8b8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((r[i+0]) << 8) | ((g[i+0]) << 16) | ((b[i+0]) << 24); + const uint32_t pixel1 = ((r[i+1]) << 8) | ((g[i+1]) << 16) | ((b[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_a8b8g8r8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((a[i+0]) << 0) | ((b[i+0]) << 8) | ((g[i+0]) << 16) | ((r[i+0]) << 24); + const uint32_t pixel1 = ((a[i+1]) << 0) | ((b[i+1]) << 8) | ((g[i+1]) << 16) | ((r[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_x8b8g8r8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((b[i+0]) << 8) | ((g[i+0]) << 16) | ((r[i+0]) << 24); + const uint32_t pixel1 = ((b[i+1]) << 8) | ((g[i+1]) << 16) | ((r[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8g8b8x8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((r[i+0]) << 0) | ((g[i+0]) << 8) | ((b[i+0]) << 16); + const uint32_t pixel1 = ((r[i+1]) << 0) | ((g[i+1]) << 8) | ((b[i+1]) << 16); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b5g5r5x1_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(b[i+0] >> 3)) << 0) | (((uint16_t)(g[i+0] >> 3)) << 5) | (((uint16_t)(r[i+0] >> 3)) << 10); + const uint32_t pixel1 = (((uint16_t)(b[i+1] >> 3)) << 0) | (((uint16_t)(g[i+1] >> 3)) << 5) | (((uint16_t)(r[i+1] >> 3)) << 10); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b5g5r5a1_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(b[i+0] >> 3)) << 0) | (((uint16_t)(g[i+0] >> 3)) << 5) | (((uint16_t)(r[i+0] >> 3)) << 10) | (((uint16_t)(a[i+0] >> 7)) << 15); + const uint32_t pixel1 = (((uint16_t)(b[i+1] >> 3)) << 0) | (((uint16_t)(g[i+1] >> 3)) << 5) | (((uint16_t)(r[i+1] >> 3)) << 10) | (((uint16_t)(a[i+1] >> 7)) << 15); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b4g4r4a4_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(b[i+0] >> 4)) << 0) | (((uint16_t)(g[i+0] >> 4)) << 4) | (((uint16_t)(r[i+0] >> 4)) << 8) | (((uint16_t)(a[i+0] >> 4)) << 12); + const uint32_t pixel1 = (((uint16_t)(b[i+1] >> 4)) << 0) | (((uint16_t)(g[i+1] >> 4)) << 4) | (((uint16_t)(r[i+1] >> 4)) << 8) | (((uint16_t)(a[i+1] >> 4)) << 12); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b4g4r4x4_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(b[i+0] >> 4)) << 0) | (((uint16_t)(g[i+0] >> 4)) << 4) | (((uint16_t)(r[i+0] >> 4)) << 8); + const uint32_t pixel1 = (((uint16_t)(b[i+1] >> 4)) << 0) | (((uint16_t)(g[i+1] >> 4)) << 4) | (((uint16_t)(r[i+1] >> 4)) << 8); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b5g6r5_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(b[i+0] >> 3)) << 0) | (((uint16_t)(g[i+0] >> 2)) << 5) | (((uint16_t)(r[i+0] >> 3)) << 11); + const uint32_t pixel1 = (((uint16_t)(b[i+1] >> 3)) << 0) | (((uint16_t)(g[i+1] >> 2)) << 5) | (((uint16_t)(r[i+1] >> 3)) << 11); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r10g10b10a2_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint32_t)r[i+0]) * 0x3ff / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+0]) * 0x3ff / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+0]) * 0x3ff / 0xff)) << 20) | (((uint32_t)(a[i+0] >> 6)) << 30); + const uint32_t pixel1 = (((uint32_t)(((uint32_t)r[i+1]) * 0x3ff / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+1]) * 0x3ff / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+1]) * 0x3ff / 0xff)) << 20) | (((uint32_t)(a[i+1] >> 6)) << 30); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_b10g10r10a2_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint32_t)b[i+0]) * 0x3ff / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+0]) * 0x3ff / 0xff)) << 10) | (((uint32_t)(((uint32_t)r[i+0]) * 0x3ff / 0xff)) << 20) | (((uint32_t)(a[i+0] >> 6)) << 30); + const uint32_t pixel1 = (((uint32_t)(((uint32_t)b[i+1]) * 0x3ff / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+1]) * 0x3ff / 0xff)) << 10) | (((uint32_t)(((uint32_t)r[i+1]) * 0x3ff / 0xff)) << 20) | (((uint32_t)(a[i+1] >> 6)) << 30); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_l8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((b[i+0]) << 0); + const uint32_t pixel1 = ((b[i+1]) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_a8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((a[i+0]) << 0); + const uint32_t pixel1 = ((a[i+1]) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_i8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((a[i+0]) << 0); + const uint32_t pixel1 = ((a[i+1]) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_l4a4_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint8_t)(b[i+0] >> 4)) << 0) | (((uint8_t)(a[i+0] >> 4)) << 4); + const uint32_t pixel1 = (((uint8_t)(b[i+1] >> 4)) << 0) | (((uint8_t)(a[i+1] >> 4)) << 4); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_l8a8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((b[i+0]) << 0) | ((a[i+0]) << 8); + const uint32_t pixel1 = ((b[i+1]) << 0) | ((a[i+1]) << 8); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_l16_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(((uint32_t)b[i+0]) * 0xffff / 0xff)) << 0); + const uint32_t pixel1 = (((uint16_t)(((uint32_t)b[i+1]) * 0xffff / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_l8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_l8a8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 3); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8a8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 3); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_a8b8g8r8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 3); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_x8b8g8r8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + ++dst_pixel; + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_b8g8r8a8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 3); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_b8g8r8x8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + ++dst_pixel; + } + dst_row += dst_stride; + } +} + +static void +lp_tile_a8r8g8b8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 3); + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_x8r8g8b8_srgb_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + ++dst_pixel; + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8sg8sb8ux8u_norm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 0) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 1) >> 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + ++dst_pixel; + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r10sg10sb10sa2u_norm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = 0; + pixel |= (uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1ff / 0xff); + pixel |= ((uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1ff / 0xff) << 10); + pixel |= ((uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1ff / 0xff) << 20); + pixel |= ((uint32_t)(TILE_PIXEL(src, x, y, 3) >> 6) << 30); + *dst_pixel++ = pixel; + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r5sg5sb6u_norm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + uint16_t pixel = 0; + pixel |= (uint16_t)(TILE_PIXEL(src, x, y, 0) >> 4); + pixel |= ((uint16_t)(TILE_PIXEL(src, x, y, 1) >> 4) << 5); + pixel |= ((uint16_t)(TILE_PIXEL(src, x, y, 2) >> 2) << 10); + *dst_pixel++ = pixel; + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r10g10b10a2_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+0]) * 0x1 / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+0]) * 0x1 / 0xff)) << 20) | (((uint32_t)(((uint32_t)a[i+0]) * 0x1 / 0xff)) << 30); + const uint32_t pixel1 = (((uint32_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+1]) * 0x1 / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+1]) * 0x1 / 0xff)) << 20) | (((uint32_t)(((uint32_t)a[i+1]) * 0x1 / 0xff)) << 30); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r64_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + double *dst_pixel = (double *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r64g64_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + double *dst_pixel = (double *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r64g64b64_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + double *dst_pixel = (double *)(dst_row + x0*24); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 2) * (1.0f/0xff)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r64g64b64a64_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + double *dst_pixel = (double *)(dst_row + x0*32); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 2) * (1.0f/0xff)); + *dst_pixel++ = (double)(TILE_PIXEL(src, x, y, 3) * (1.0f/0xff)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + float *dst_pixel = (float *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 0)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + float *dst_pixel = (float *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 0)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 1)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + float *dst_pixel = (float *)(dst_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 0)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 1)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 2)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32a32_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + float *dst_pixel = (float *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 0)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 1)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 2)); + *dst_pixel++ = ubyte_to_float(TILE_PIXEL(src, x, y, 3)); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint64_t)r[i+0]) * 0xffffffff / 0xff)) << 0); + const uint32_t pixel1 = (((uint32_t)(((uint64_t)r[i+1]) * 0xffffffff / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r32g32_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0xffffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0xffffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32a32_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0xffffffff / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 3)) * 0xffffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint64_t)r[i+0]) * 0x1 / 0xff)) << 0); + const uint32_t pixel1 = (((uint32_t)(((uint64_t)r[i+1]) * 0x1 / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r32g32_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32a32_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + *dst_pixel++ = (uint32_t)(((uint64_t)TILE_PIXEL(src, x, y, 3)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x7fffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x7fffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x7fffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32a32_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x7fffffff / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 3)) * 0x7fffffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*12); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r32g32b32a32_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int32_t *dst_pixel = (int32_t *)(dst_row + x0*16); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + *dst_pixel++ = (int32_t)(((uint64_t)TILE_PIXEL(src, x, y, 3)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff))); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff))); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 2) * (1.0f/0xff))); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16a16_float_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 0) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 1) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 2) * (1.0f/0xff))); + *dst_pixel++ = util_float_to_half((float)(TILE_PIXEL(src, x, y, 3) * (1.0f/0xff))); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(((uint32_t)r[i+0]) * 0xffff / 0xff)) << 0); + const uint32_t pixel1 = (((uint16_t)(((uint32_t)r[i+1]) * 0xffff / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r16g16_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(((uint32_t)r[i+0]) * 0xffff / 0xff)) << 0) | (((uint16_t)(((uint32_t)g[i+0]) * 0xffff / 0xff)) << 16); + const uint32_t pixel1 = (((uint16_t)(((uint32_t)r[i+1]) * 0xffff / 0xff)) << 0) | (((uint16_t)(((uint32_t)g[i+1]) * 0xffff / 0xff)) << 16); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r16g16b16_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0xffff / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0xffff / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0xffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16a16_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0xffff / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0xffff / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0xffff / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 3)) * 0xffff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0); + const uint32_t pixel1 = (((uint16_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r16g16_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint16_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0) | (((uint16_t)(((uint32_t)g[i+0]) * 0x1 / 0xff)) << 16); + const uint32_t pixel1 = (((uint16_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0) | (((uint16_t)(((uint32_t)g[i+1]) * 0x1 / 0xff)) << 16); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r16g16b16_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16a16_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint16_t *dst_pixel = (uint16_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + *dst_pixel++ = (uint16_t)(((uint32_t)TILE_PIXEL(src, x, y, 3)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x7fff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x7fff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x7fff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16a16_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x7fff / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 3)) * 0x7fff / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*6); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r16g16b16a16_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int16_t *dst_pixel = (int16_t *)(dst_row + x0*8); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + *dst_pixel++ = (int16_t)(((uint32_t)TILE_PIXEL(src, x, y, 3)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((r[i+0]) << 0); + const uint32_t pixel1 = ((r[i+1]) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8g8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((r[i+0]) << 0) | ((g[i+0]) << 8); + const uint32_t pixel1 = ((r[i+1]) << 0) | ((g[i+1]) << 8); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8g8b8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = TILE_PIXEL(src, x, y, 0); + *dst_pixel++ = TILE_PIXEL(src, x, y, 1); + *dst_pixel++ = TILE_PIXEL(src, x, y, 2); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8a8_unorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = ((r[i+0]) << 0) | ((g[i+0]) << 8) | ((b[i+0]) << 16) | ((a[i+0]) << 24); + const uint32_t pixel1 = ((r[i+1]) << 0) | ((g[i+1]) << 8) | ((b[i+1]) << 16) | ((a[i+1]) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 1; + uint8_t *dstpix = (uint8_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint8_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0); + const uint32_t pixel1 = (((uint8_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8g8_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 2; + uint16_t *dstpix = (uint16_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint8_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0) | (((uint8_t)(((uint32_t)g[i+0]) * 0x1 / 0xff)) << 8); + const uint32_t pixel1 = (((uint8_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0) | (((uint8_t)(((uint32_t)g[i+1]) * 0x1 / 0xff)) << 8); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8g8b8_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint8_t *dst_pixel = (uint8_t *)(dst_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (uint8_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (uint8_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (uint8_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8a8_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint8_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0) | (((uint8_t)(((uint32_t)g[i+0]) * 0x1 / 0xff)) << 8) | (((uint8_t)(((uint32_t)b[i+0]) * 0x1 / 0xff)) << 16) | (((uint8_t)(((uint32_t)a[i+0]) * 0x1 / 0xff)) << 24); + const uint32_t pixel1 = (((uint8_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0) | (((uint8_t)(((uint32_t)g[i+1]) * 0x1 / 0xff)) << 8) | (((uint8_t)(((uint32_t)b[i+1]) * 0x1 / 0xff)) << 16) | (((uint8_t)(((uint32_t)a[i+1]) * 0x1 / 0xff)) << 24); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r8_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 0) >> 1); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 0) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 1) >> 1); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 0) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 1) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 2) >> 1); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8a8_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 0) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 1) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 2) >> 1); + *dst_pixel++ = (int8_t)(TILE_PIXEL(src, x, y, 3) >> 1); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*1); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*2); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*3); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r8g8b8a8_sscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + int8_t *dst_pixel = (int8_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1 / 0xff); + *dst_pixel++ = (int8_t)(((uint32_t)TILE_PIXEL(src, x, y, 3)) * 0x1 / 0xff); + } + dst_row += dst_stride; + } +} + +static void +lp_tile_r10g10b10x2_uscaled_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + const unsigned dstpix_stride = dst_stride / 4; + uint32_t *dstpix = (uint32_t *) dst; + unsigned int qx, qy, i; + + for (qy = 0; qy < TILE_SIZE; qy += TILE_VECTOR_HEIGHT) { + const unsigned py = y0 + qy; + for (qx = 0; qx < TILE_SIZE; qx += TILE_VECTOR_WIDTH) { + const unsigned px = x0 + qx; + const uint8_t *r = src + 0 * TILE_C_STRIDE; + const uint8_t *g = src + 1 * TILE_C_STRIDE; + const uint8_t *b = src + 2 * TILE_C_STRIDE; + const uint8_t *a = src + 3 * TILE_C_STRIDE; + (void) r; (void) g; (void) b; (void) a; /* silence warnings */ + for (i = 0; i < TILE_C_STRIDE; i += 2) { + const uint32_t pixel0 = (((uint32_t)(((uint32_t)r[i+0]) * 0x1 / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+0]) * 0x1 / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+0]) * 0x1 / 0xff)) << 20); + const uint32_t pixel1 = (((uint32_t)(((uint32_t)r[i+1]) * 0x1 / 0xff)) << 0) | (((uint32_t)(((uint32_t)g[i+1]) * 0x1 / 0xff)) << 10) | (((uint32_t)(((uint32_t)b[i+1]) * 0x1 / 0xff)) << 20); + const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]); + dstpix[offset + 0] = pixel0; + dstpix[offset + 1] = pixel1; + } + src += TILE_X_STRIDE; + } + } +} + +static void +lp_tile_r10g10b10x2_snorm_unswizzle_4ub(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0) +{ + unsigned x, y; + uint8_t *dst_row = dst + y0*dst_stride; + for (y = 0; y < TILE_SIZE; ++y) { + uint32_t *dst_pixel = (uint32_t *)(dst_row + x0*4); + for (x = 0; x < TILE_SIZE; ++x) { + uint32_t pixel = 0; + pixel |= (uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 0)) * 0x1ff / 0xff); + pixel |= ((uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 1)) * 0x1ff / 0xff) << 10); + pixel |= ((uint32_t)(((uint32_t)TILE_PIXEL(src, x, y, 2)) * 0x1ff / 0xff) << 20); + *dst_pixel++ = pixel; + } + dst_row += dst_stride; + } +} + +void +lp_tile_unswizzle_4ub(enum pipe_format format, const uint8_t *src, void *dst, unsigned dst_stride, unsigned x, unsigned y) +{ + void (*func)(const uint8_t *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0); +#ifdef DEBUG + lp_tile_unswizzle_count += 1; +#endif + switch(format) { + case PIPE_FORMAT_NONE: + func = lp_tile_none_unswizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8A8_UNORM: +#ifdef PIPE_ARCH_SSE + func = util_cpu_caps.has_sse2 ? lp_tile_b8g8r8a8_unorm_unswizzle_4ub_sse2 : lp_tile_b8g8r8a8_unorm_unswizzle_4ub; +#else + func = lp_tile_b8g8r8a8_unorm_unswizzle_4ub; +#endif + break; + case PIPE_FORMAT_B8G8R8X8_UNORM: + func = lp_tile_b8g8r8x8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_A8R8G8B8_UNORM: + func = lp_tile_a8r8g8b8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_X8R8G8B8_UNORM: + func = lp_tile_x8r8g8b8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_A8B8G8R8_UNORM: + func = lp_tile_a8b8g8r8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_X8B8G8R8_UNORM: + func = lp_tile_x8b8g8r8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8X8_UNORM: + func = lp_tile_r8g8b8x8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B5G5R5X1_UNORM: + func = lp_tile_b5g5r5x1_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B5G5R5A1_UNORM: + func = lp_tile_b5g5r5a1_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B4G4R4A4_UNORM: + func = lp_tile_b4g4r4a4_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B4G4R4X4_UNORM: + func = lp_tile_b4g4r4x4_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B5G6R5_UNORM: + func = lp_tile_b5g6r5_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10A2_UNORM: + func = lp_tile_r10g10b10a2_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_B10G10R10A2_UNORM: + func = lp_tile_b10g10r10a2_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_L8_UNORM: + func = lp_tile_l8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_A8_UNORM: + func = lp_tile_a8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_I8_UNORM: + func = lp_tile_i8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_L4A4_UNORM: + func = lp_tile_l4a4_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_L8A8_UNORM: + func = lp_tile_l8a8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_L16_UNORM: + func = lp_tile_l16_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_L8_SRGB: + func = lp_tile_l8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_L8A8_SRGB: + func = lp_tile_l8a8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SRGB: + func = lp_tile_r8g8b8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SRGB: + func = lp_tile_r8g8b8a8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_A8B8G8R8_SRGB: + func = lp_tile_a8b8g8r8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_X8B8G8R8_SRGB: + func = lp_tile_x8b8g8r8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8A8_SRGB: + func = lp_tile_b8g8r8a8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_B8G8R8X8_SRGB: + func = lp_tile_b8g8r8x8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_A8R8G8B8_SRGB: + func = lp_tile_a8r8g8b8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_X8R8G8B8_SRGB: + func = lp_tile_x8r8g8b8_srgb_unswizzle_4ub; + break; + case PIPE_FORMAT_R8SG8SB8UX8U_NORM: + func = lp_tile_r8sg8sb8ux8u_norm_unswizzle_4ub; + break; + case PIPE_FORMAT_R10SG10SB10SA2U_NORM: + func = lp_tile_r10sg10sb10sa2u_norm_unswizzle_4ub; + break; + case PIPE_FORMAT_R5SG5SB6U_NORM: + func = lp_tile_r5sg5sb6u_norm_unswizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10A2_USCALED: + func = lp_tile_r10g10b10a2_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R64_FLOAT: + func = lp_tile_r64_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R64G64_FLOAT: + func = lp_tile_r64g64_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R64G64B64_FLOAT: + func = lp_tile_r64g64b64_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R64G64B64A64_FLOAT: + func = lp_tile_r64g64b64a64_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R32_FLOAT: + func = lp_tile_r32_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32_FLOAT: + func = lp_tile_r32g32_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_FLOAT: + func = lp_tile_r32g32b32_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + func = lp_tile_r32g32b32a32_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R32_UNORM: + func = lp_tile_r32_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32_UNORM: + func = lp_tile_r32g32_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_UNORM: + func = lp_tile_r32g32b32_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_UNORM: + func = lp_tile_r32g32b32a32_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32_USCALED: + func = lp_tile_r32_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32_USCALED: + func = lp_tile_r32g32_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_USCALED: + func = lp_tile_r32g32b32_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_USCALED: + func = lp_tile_r32g32b32a32_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32_SNORM: + func = lp_tile_r32_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32_SNORM: + func = lp_tile_r32g32_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_SNORM: + func = lp_tile_r32g32b32_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_SNORM: + func = lp_tile_r32g32b32a32_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R32_SSCALED: + func = lp_tile_r32_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32_SSCALED: + func = lp_tile_r32g32_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32_SSCALED: + func = lp_tile_r32g32b32_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R32G32B32A32_SSCALED: + func = lp_tile_r32g32b32a32_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16_FLOAT: + func = lp_tile_r16_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16_FLOAT: + func = lp_tile_r16g16_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_FLOAT: + func = lp_tile_r16g16b16_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_FLOAT: + func = lp_tile_r16g16b16a16_float_unswizzle_4ub; + break; + case PIPE_FORMAT_R16_UNORM: + func = lp_tile_r16_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16_UNORM: + func = lp_tile_r16g16_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_UNORM: + func = lp_tile_r16g16b16_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_UNORM: + func = lp_tile_r16g16b16a16_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16_USCALED: + func = lp_tile_r16_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16_USCALED: + func = lp_tile_r16g16_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_USCALED: + func = lp_tile_r16g16b16_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_USCALED: + func = lp_tile_r16g16b16a16_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16_SNORM: + func = lp_tile_r16_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16_SNORM: + func = lp_tile_r16g16_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_SNORM: + func = lp_tile_r16g16b16_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_SNORM: + func = lp_tile_r16g16b16a16_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R16_SSCALED: + func = lp_tile_r16_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16_SSCALED: + func = lp_tile_r16g16_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16_SSCALED: + func = lp_tile_r16g16b16_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R16G16B16A16_SSCALED: + func = lp_tile_r16g16b16a16_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8_UNORM: + func = lp_tile_r8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8_UNORM: + func = lp_tile_r8g8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_UNORM: + func = lp_tile_r8g8b8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_UNORM: + func = lp_tile_r8g8b8a8_unorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8_USCALED: + func = lp_tile_r8_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8_USCALED: + func = lp_tile_r8g8_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_USCALED: + func = lp_tile_r8g8b8_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_USCALED: + func = lp_tile_r8g8b8a8_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8_SNORM: + func = lp_tile_r8_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8_SNORM: + func = lp_tile_r8g8_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SNORM: + func = lp_tile_r8g8b8_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SNORM: + func = lp_tile_r8g8b8a8_snorm_unswizzle_4ub; + break; + case PIPE_FORMAT_R8_SSCALED: + func = lp_tile_r8_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8_SSCALED: + func = lp_tile_r8g8_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8_SSCALED: + func = lp_tile_r8g8b8_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R8G8B8A8_SSCALED: + func = lp_tile_r8g8b8a8_sscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10X2_USCALED: + func = lp_tile_r10g10b10x2_uscaled_unswizzle_4ub; + break; + case PIPE_FORMAT_R10G10B10X2_SNORM: + func = lp_tile_r10g10b10x2_snorm_unswizzle_4ub; + break; + default: + debug_printf("%s: unsupported format %s\n", __FUNCTION__, util_format_name(format)); + return; + } + func(src, (uint8_t *)dst, dst_stride, x, y); +} + diff --git a/lib/libGL/gallium/drivers/rbug/Makefile b/lib/libGL/gallium/drivers/rbug/Makefile new file mode 100644 index 000000000..b38ab1195 --- /dev/null +++ b/lib/libGL/gallium/drivers/rbug/Makefile @@ -0,0 +1,11 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +LIB = rbug + +SRCS = \ + rbug_core.c \ + rbug_context.c \ + rbug_objects.c \ + rbug_screen.c + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/drivers/softpipe/Makefile b/lib/libGL/gallium/drivers/softpipe/Makefile new file mode 100644 index 000000000..7dd0edc8d --- /dev/null +++ b/lib/libGL/gallium/drivers/softpipe/Makefile @@ -0,0 +1,37 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +LIB = softpipe + +SRCS = \ + sp_fs_exec.c \ + sp_fs_sse.c \ + sp_clear.c \ + sp_fence.c \ + sp_flush.c \ + sp_query.c \ + sp_context.c \ + sp_draw_arrays.c \ + sp_prim_vbuf.c \ + sp_quad_pipe.c \ + sp_quad_stipple.c \ + sp_quad_depth_test.c \ + sp_quad_fs.c \ + sp_quad_blend.c \ + sp_screen.c \ + sp_setup.c \ + sp_state_blend.c \ + sp_state_clip.c \ + sp_state_derived.c \ + sp_state_sampler.c \ + sp_state_shader.c \ + sp_state_so.c \ + sp_state_rasterizer.c \ + sp_state_surface.c \ + sp_state_vertex.c \ + sp_texture.c \ + sp_tex_sample.c \ + sp_tex_tile_cache.c \ + sp_tile_cache.c \ + sp_surface.c + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/drivers/trace/Makefile b/lib/libGL/gallium/drivers/trace/Makefile new file mode 100644 index 000000000..14e36a840 --- /dev/null +++ b/lib/libGL/gallium/drivers/trace/Makefile @@ -0,0 +1,12 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:34 mpi Exp $ + +LIB = trace + +SRCS = \ + tr_context.c \ + tr_dump.c \ + tr_dump_state.c \ + tr_screen.c \ + tr_texture.c + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/libgallium/Makefile b/lib/libGL/gallium/libgallium/Makefile new file mode 100644 index 000000000..ca1023a3b --- /dev/null +++ b/lib/libGL/gallium/libgallium/Makefile @@ -0,0 +1,221 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/13 12:43:30 mpi Exp $ + +LIB= gallium + +GALLIUM= ${.CURDIR}/../../../../dist/Mesa/src/gallium + +CPPFLAGS+= \ + -I${GALLIUM}/include \ + -I${GALLIUM}/auxiliary \ + -I${GALLIUM}/auxiliary/util + +C_SOURCES = \ + cso_cache.c \ + cso_context.c \ + cso_hash.c \ + draw_context.c \ + draw_fs.c \ + draw_gs.c \ + draw_pipe.c \ + draw_pipe_aaline.c \ + draw_pipe_aapoint.c \ + draw_pipe_clip.c \ + draw_pipe_cull.c \ + draw_pipe_flatshade.c \ + draw_pipe_offset.c \ + draw_pipe_pstipple.c \ + draw_pipe_stipple.c \ + draw_pipe_twoside.c \ + draw_pipe_unfilled.c \ + draw_pipe_util.c \ + draw_pipe_validate.c \ + draw_pipe_vbuf.c \ + draw_pipe_wide_line.c \ + draw_pipe_wide_point.c \ + draw_pt.c \ + draw_pt_emit.c \ + draw_pt_fetch.c \ + draw_pt_fetch_emit.c \ + draw_pt_fetch_shade_emit.c \ + draw_pt_fetch_shade_pipeline.c \ + draw_pt_post_vs.c \ + draw_pt_so_emit.c \ + draw_pt_util.c \ + draw_pt_vsplit.c \ + draw_vertex.c \ + draw_vs.c \ + draw_vs_aos.c \ + draw_vs_aos_io.c \ + draw_vs_aos_machine.c \ + draw_vs_exec.c \ + draw_vs_ppc.c \ + draw_vs_sse.c \ + draw_vs_varient.c \ + u_indices_gen.c \ + u_unfilled_gen.c \ + os_misc.c \ + os_stream.c \ + os_stream_log.c \ + os_stream_null.c \ + os_stream_stdc.c \ + os_stream_str.c \ + os_time.c \ + pb_buffer_fenced.c \ + pb_buffer_malloc.c \ + pb_bufmgr_alt.c \ + pb_bufmgr_cache.c \ + pb_bufmgr_debug.c \ + pb_bufmgr_mm.c \ + pb_bufmgr_ondemand.c \ + pb_bufmgr_pool.c \ + pb_bufmgr_slab.c \ + pb_validate.c \ + rbug_connection.c \ + rbug_context.c \ + rbug_core.c \ + rbug_demarshal.c \ + rbug_texture.c \ + rbug_shader.c \ + rtasm_cpu.c \ + rtasm_execmem.c \ + rtasm_ppc.c \ + rtasm_ppc_spe.c \ + rtasm_x86sse.c \ + tgsi_build.c \ + tgsi_dump.c \ + tgsi_exec.c \ + tgsi_info.c \ + tgsi_iterate.c \ + tgsi_parse.c \ + tgsi_ppc.c \ + tgsi_sanity.c \ + tgsi_scan.c \ + tgsi_sse2.c \ + tgsi_text.c \ + tgsi_transform.c \ + tgsi_ureg.c \ + tgsi_util.c \ + translate.c \ + translate_cache.c \ + translate_generic.c \ + translate_sse.c \ + u_debug.c \ + u_debug_describe.c \ + u_debug_refcnt.c \ + u_debug_stack.c \ + u_debug_symbol.c \ + u_dump_defines.c \ + u_dump_state.c \ + u_bitmask.c \ + u_blit.c \ + u_blitter.c \ + u_cache.c \ + u_caps.c \ + u_cpu_detect.c \ + u_dl.c \ + u_draw_quad.c \ + u_format.c \ + u_format_other.c \ + u_format_s3tc.c \ + u_format_srgb.c \ + u_format_table.c \ + u_format_tests.c \ + u_format_yuv.c \ + u_format_zs.c \ + u_framebuffer.c \ + u_gen_mipmap.c \ + u_half.c \ + u_handle_table.c \ + u_hash.c \ + u_hash_table.c \ + u_index_modify.c \ + u_keymap.c \ + u_linear.c \ + u_linkage.c \ + u_network.c \ + u_math.c \ + u_mm.c \ + u_rect.c \ + u_ringbuffer.c \ + u_sampler.c \ + u_simple_shaders.c \ + u_slab.c \ + u_snprintf.c \ + u_staging.c \ + u_surface.c \ + u_surfaces.c \ + u_texture.c \ + u_tile.c \ + u_transfer.c \ + u_resource.c \ + u_upload_mgr.c + +GALLIVM_SOURCES = \ + lp_bld_arit.c \ + lp_bld_assert.c \ + lp_bld_bitarit.c \ + lp_bld_const.c \ + lp_bld_conv.c \ + lp_bld_debug.c \ + lp_bld_flow.c \ + lp_bld_format_aos.c \ + lp_bld_format_soa.c \ + lp_bld_format_yuv.c \ + lp_bld_gather.c \ + lp_bld_init.c \ + lp_bld_intr.c \ + lp_bld_logic.c \ + lp_bld_pack.c \ + lp_bld_printf.c \ + lp_bld_quad.c \ + lp_bld_sample.c \ + lp_bld_sample_aos.c \ + lp_bld_sample_soa.c \ + lp_bld_struct.c \ + lp_bld_swizzle.c \ + lp_bld_tgsi_aos.c \ + lp_bld_tgsi_info.c \ + lp_bld_tgsi_soa.c \ + lp_bld_type.c \ + draw_llvm.c \ + draw_llvm_sample.c \ + draw_llvm_translate.c \ + draw_vs_llvm.c \ + draw_pt_fetch_shade_pipeline_llvm.c + +GALLIVM_CPP_SOURCES = \ + lp_bld_misc.cpp + +SRCS= ${C_SOURCES} + +.ifdef XENOCARA_HAVE_LLVM +SRCS+= ${GALLIVM_SOURCES} \ + ${GALLIVM_CPP_SOURCES} +.endif + +all: lib${LIB}_pic.a + +obj: _xenocara_obj + +install: + @echo "Not installing lib${LIB}" + +clean: + rm -f lib${LIB}_pic.a ${OBJS} + +cleandir: clean + +.include <bsd.xorg.mk> + +.PATH: ${GALLIUM}/auxiliary/cso_cache +.PATH: ${GALLIUM}/auxiliary/draw +.PATH: ${GALLIUM}/auxiliary/indices +.PATH: ${GALLIUM}/auxiliary/os +.PATH: ${GALLIUM}/auxiliary/pipebuffer +.PATH: ${GALLIUM}/auxiliary/rbug +.PATH: ${GALLIUM}/auxiliary/rtasm +.PATH: ${GALLIUM}/auxiliary/tgsi +.PATH: ${GALLIUM}/auxiliary/translate +.PATH: ${GALLIUM}/auxiliary/util +.PATH: ${GALLIUM}/auxiliary/gallivm +.PATH: ${.CURDIR}/generated diff --git a/lib/libGL/gallium/libgallium/generated/Makefile b/lib/libGL/gallium/libgallium/generated/Makefile new file mode 100644 index 000000000..bc047a40c --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/Makefile @@ -0,0 +1,42 @@ +# $OpenBSD: Makefile,v 1.1.1.1 2012/07/13 12:43:30 mpi Exp $ + +AUX= ${.CURDIR}/../../../../../dist/Mesa/src/gallium/auxiliary + +PYTHON= python${PYTHON_VERSION} +PYTHON_FLAGS= -t -O -O + +GENERATED= u_indices_gen.c u_unfilled_gen.c u_format_srgb.c \ + u_format_table.c u_half.c + +all: ${GENERATED} + +obj: + +depend: + +install: + +clean distclean: + rm -f ${GENERATED} + +u_indices_gen.c: u_indices_gen.py + ${PYTHON} ${PYTHON_FLAGS} ${AUX}/indices/u_indices_gen.py > $@ + +u_unfilled_gen.c: u_unfilled_gen.py + ${PYTHON} ${PYTHON_FLAGS} ${AUX}/indices/u_unfilled_gen.py > $@ + +u_format_srgb.c: ${AUX}/util/u_format_srgb.py + ${PYTHON} ${PYTHON_FLAGS} ${AUX}/util/u_format_srgb.py > $@ + +u_format_table.c: u_format_table.py u_format_pack.py u_format_parse.py u_format.csv + ${PYTHON} ${PYTHON_FLAGS} ${AUX}/util/u_format_table.py ${AUX}/util/u_format.csv > $@ + +u_half.c: ${AUX}/util/u_half.py + ${PYTHON} ${PYTHON_FLAGS} ${AUX}/util/u_half.py > $@ + +.SUFFIXES: .py + +.PATH: ${AUX}/indices +.PATH: ${AUX}/util + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/libgallium/generated/u_format_srgb.c b/lib/libGL/gallium/libgallium/generated/u_format_srgb.c new file mode 100644 index 000000000..4ac8c7b48 --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/u_format_srgb.c @@ -0,0 +1,148 @@ +/* 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 <brianp@vmware.com> + * @author Michal Krol <michal@vmware.com> + * @author Jose Fonseca <jfonseca@vmware.com> + */ + +#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, +}; + diff --git a/lib/libGL/gallium/libgallium/generated/u_format_table.c b/lib/libGL/gallium/libgallium/generated/u_format_table.c new file mode 100644 index 000000000..40dd09ebf --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/u_format_table.c @@ -0,0 +1,17561 @@ +/* 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 "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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; + value |= (((uint16_t)(CLAMP(src[1], 0, 1) * 0x1f)) & 0x1f) << 5; + value |= (((uint16_t)(CLAMP(src[0], 0, 1) * 0x1f)) & 0x1f) << 10; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; + value |= (((uint16_t)(CLAMP(src[1], 0, 1) * 0x1f)) & 0x1f) << 5; + value |= (((uint16_t)(CLAMP(src[0], 0, 1) * 0x1f)) & 0x1f) << 10; + value |= ((uint16_t)(CLAMP(src[3], 0, 1) * 0x1)) << 15; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0xf)) & 0xf; + value |= (((uint16_t)(CLAMP(src[1], 0, 1) * 0xf)) & 0xf) << 4; + value |= (((uint16_t)(CLAMP(src[0], 0, 1) * 0xf)) & 0xf) << 8; + value |= ((uint16_t)(CLAMP(src[3], 0, 1) * 0xf)) << 12; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0xf)) & 0xf; + value |= (((uint16_t)(CLAMP(src[1], 0, 1) * 0xf)) & 0xf) << 4; + value |= (((uint16_t)(CLAMP(src[0], 0, 1) * 0xf)) & 0xf) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0x1f)) & 0x1f; + value |= (((uint16_t)(CLAMP(src[1], 0, 1) * 0x3f)) & 0x3f) << 5; + value |= ((uint16_t)(CLAMP(src[0], 0, 1) * 0x1f)) << 11; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff; + value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10; + value |= (((uint32_t)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff) << 20; + value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0x3ff)) & 0x3ff; + value |= (((uint32_t)(CLAMP(src[1], 0, 1) * 0x3ff)) & 0x3ff) << 10; + value |= (((uint32_t)(CLAMP(src[0], 0, 1) * 0x3ff)) & 0x3ff) << 20; + value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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[2]); + *(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[2]; + *(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[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_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[3]; + *(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)(CLAMP(src[2], 0, 1) * 0xf)) & 0xf; + value |= ((uint8_t)(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[2] >> 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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[2])) & 0xff; + value |= (float_to_ubyte(src[3])) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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[2]) & 0xff; + value |= (src[3]) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[2], 0, 1) * 0xffff); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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[2]) * 0xffff / 0xff); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(uint16_t *)dst = value; + src += 4; + dst += 2; + } + 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[2]); + *(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[2]); + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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[2])) & 0xff; + value |= (float_to_ubyte(src[3])) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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[2])) & 0xff; + value |= (src[3]) << 8; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(((int8_t)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; + value |= (uint32_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; + value |= ((float_to_ubyte(src[2])) & 0xff) << 16; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(((int8_t)(src[0] >> 1)) & 0xff) ; + value |= (uint32_t)((((int8_t)(src[1] >> 1)) & 0xff) << 8) ; + value |= ((src[2]) & 0xff) << 16; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ; + value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; + value |= (uint32_t)((((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; + value |= ((uint32_t)(CLAMP(src[3], 0, 1) * 0x3)) << 30; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0xf)) & 0x1f) ; + value |= (uint16_t)((((uint16_t)(CLAMP(src[1], -1, 1) * 0xf)) & 0x1f) << 5) ; + value |= ((uint16_t)(CLAMP(src[2], 0, 1) * 0x3f)) << 10; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE void +util_format_r11g11b10_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE void +util_format_rgtc1_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE void +util_format_rgtc1_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE void +util_format_rgtc2_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +static INLINE void +util_format_rgtc2_snorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j) +{ +} + +static INLINE 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) +{ +} + +static INLINE 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) +{ +} + +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)(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)(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ + dst[1] = (uint8_t)(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)(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ + dst[1] = (uint8_t)(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */ + dst[2] = (uint8_t)(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)(CLAMP(pixel.chan.r, 0, 1) * 0xff); /* r */ + dst[1] = (uint8_t)(CLAMP(pixel.chan.g, 0, 1) * 0xff); /* g */ + dst[2] = (uint8_t)(CLAMP(pixel.chan.b, 0, 1) * 0xff); /* b */ + dst[3] = (uint8_t)(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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); +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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); +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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); +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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); +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[0], 0, 1) * 0xffff); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], 0, 1) * 0xffff)) & 0xffff; + value |= ((uint16_t)(CLAMP(src[1], 0, 1) * 0xffff)) << 16; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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)(CLAMP(src[0], 0, 1) * 0xffff); + pixel.chan.g = (uint16_t)(CLAMP(src[1], 0, 1) * 0xffff); + pixel.chan.b = (uint16_t)(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)(CLAMP(src[0], 0, 1) * 0xffff); + pixel.chan.g = (uint16_t)(CLAMP(src[1], 0, 1) * 0xffff); + pixel.chan.b = (uint16_t)(CLAMP(src[2], 0, 1) * 0xffff); + pixel.chan.a = (uint16_t)(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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); +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x7fff)) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x7fff)) & 0xffff) ; + value |= (uint32_t)(((int16_t)(CLAMP(src[1], -1, 1) * 0x7fff)) << 16) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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)(CLAMP(src[0], -1, 1) * 0x7fff); + pixel.chan.g = (int16_t)(CLAMP(src[1], -1, 1) * 0x7fff); + pixel.chan.b = (int16_t)(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)(CLAMP(src[0], -1, 1) * 0x7fff); + pixel.chan.g = (int16_t)(CLAMP(src[1], -1, 1) * 0x7fff); + pixel.chan.b = (int16_t)(CLAMP(src[2], -1, 1) * 0x7fff); + pixel.chan.a = (int16_t)(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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)(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; + value |= (uint16_t)(((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) << 8) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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)(CLAMP(src[0], -1, 1) * 0x7f); + pixel.chan.g = (int8_t)(CLAMP(src[1], -1, 1) * 0x7f); + pixel.chan.b = (int8_t)(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x7f)) & 0xff) ; + value |= (uint32_t)((((int8_t)(CLAMP(src[1], -1, 1) * 0x7f)) & 0xff) << 8) ; + value |= (uint32_t)((((int8_t)(CLAMP(src[2], -1, 1) * 0x7f)) & 0xff) << 16) ; + value |= (uint32_t)(((int8_t)(CLAMP(src[3], -1, 1) * 0x7f)) << 24) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + 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) ; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap16(value); +#endif + *(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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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)((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)((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ + dst[1] = (uint8_t)((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)((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ + dst[1] = (uint8_t)((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */ + dst[2] = (uint8_t)((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)((CLAMP(pixel.chan.r, 0, 65536) * (1.0/0x10000)) * 0xff); /* r */ + dst[1] = (uint8_t)((CLAMP(pixel.chan.g, 0, 65536) * (1.0/0x10000)) * 0xff); /* g */ + dst[2] = (uint8_t)((CLAMP(pixel.chan.b, 0, 65536) * (1.0/0x10000)) * 0xff); /* b */ + dst[3] = (uint8_t)((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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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)(CLAMP(src[0], -1, 1) * 0x1ff)) & 0x3ff) ; + value |= (uint32_t)((((uint32_t)(CLAMP(src[1], -1, 1) * 0x1ff)) & 0x3ff) << 10) ; + value |= (uint32_t)((((uint32_t)(CLAMP(src[2], -1, 1) * 0x1ff)) & 0x3ff) << 20) ; +#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); + } +} + +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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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; +#ifdef PIPE_ARCH_BIG_ENDIAN + value = util_bswap32(value); +#endif + 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) ; +#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); + } +} + +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, 8}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = r */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = a */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = a */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 5}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 5}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 5}, /* z = r */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 1} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 5}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 5}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 5}, /* z = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 1} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 4}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4}, /* z = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 4}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4}, /* z = r */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 4} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 5}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 6}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 5}, /* z = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 10}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 10}, /* z = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = rgb */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = a */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = rgba */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 4}, /* x = rgb */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 4}, /* y = a */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = rgb */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = a */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = rgb */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = rgb */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = rgb */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = a */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = a */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = r */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = a */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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 */ + TRUE, /* is_array */ + TRUE, /* is_bitmask */ + TRUE, /* is_mixed */ + { + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 10}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 5}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 5}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 6}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +const struct util_format_description +util_format_s8_uscaled_description = { + PIPE_FORMAT_S8_USCALED, + "PIPE_FORMAT_S8_USCALED", + "s8_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, 8}, /* x = s */ + {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_uscaled_unpack_s_8uscaled, + &util_format_s8_uscaled_pack_s_8uscaled +}; + +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, 16}, /* x = z */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = z */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = z */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +const struct util_format_description +util_format_z24_unorm_s8_uscaled_description = { + PIPE_FORMAT_Z24_UNORM_S8_USCALED, + "PIPE_FORMAT_Z24_UNORM_S8_USCALED", + "z24_unorm_s8_uscaled", + {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, 24}, /* x = z */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = s */ + {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_uscaled_unpack_z_32unorm, + &util_format_z24_unorm_s8_uscaled_pack_z_32unorm, + &util_format_z24_unorm_s8_uscaled_unpack_z_float, + &util_format_z24_unorm_s8_uscaled_pack_z_float, + &util_format_z24_unorm_s8_uscaled_unpack_s_8uscaled, + &util_format_z24_unorm_s8_uscaled_pack_s_8uscaled +}; + +const struct util_format_description +util_format_s8_uscaled_z24_unorm_description = { + PIPE_FORMAT_S8_USCALED_Z24_UNORM, + "PIPE_FORMAT_S8_USCALED_Z24_UNORM", + "s8_uscaled_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, 8}, /* x = s */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 24}, /* y = z */ + {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_uscaled_z24_unorm_unpack_z_32unorm, + &util_format_s8_uscaled_z24_unorm_pack_z_32unorm, + &util_format_s8_uscaled_z24_unorm_unpack_z_float, + &util_format_s8_uscaled_z24_unorm_pack_z_float, + &util_format_s8_uscaled_z24_unorm_unpack_s_8uscaled, + &util_format_s8_uscaled_z24_unorm_pack_s_8uscaled +}; + +const struct util_format_description +util_format_x24s8_uscaled_description = { + PIPE_FORMAT_X24S8_USCALED, + "PIPE_FORMAT_X24S8_USCALED", + "x24s8_uscaled", + {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, 24}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = s */ + {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_uscaled_unpack_s_8uscaled, + &util_format_x24s8_uscaled_pack_s_8uscaled +}; + +const struct util_format_description +util_format_s8x24_uscaled_description = { + PIPE_FORMAT_S8X24_USCALED, + "PIPE_FORMAT_S8X24_USCALED", + "s8x24_uscaled", + {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, 8}, /* x = s */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 24}, /* y = x */ + {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_uscaled_unpack_s_8uscaled, + &util_format_s8x24_uscaled_pack_s_8uscaled +}; + +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, 24}, /* x = z */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 8}, /* y = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 24}, /* y = z */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +const struct util_format_description +util_format_z32_float_s8x24_uscaled_description = { + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED, + "PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED", + "z32_float_s8x24_uscaled", + {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, 32}, /* x = z */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = s */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 24}, /* z = x */ + {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_uscaled_unpack_z_32unorm, + &util_format_z32_float_s8x24_uscaled_pack_z_32unorm, + &util_format_z32_float_s8x24_uscaled_unpack_z_float, + &util_format_z32_float_s8x24_uscaled_pack_z_float, + &util_format_z32_float_s8x24_uscaled_unpack_s_8uscaled, + &util_format_z32_float_s8x24_uscaled_pack_s_8uscaled +}; + +const struct util_format_description +util_format_x32_s8x24_uscaled_description = { + PIPE_FORMAT_X32_S8X24_USCALED, + "PIPE_FORMAT_X32_S8X24_USCALED", + "x32_s8x24_uscaled", + {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, 32}, /* x = x */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = s */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 24}, /* z = x */ + {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_uscaled_unpack_s_8uscaled, + &util_format_x32_s8x24_uscaled_pack_s_8uscaled +}; + +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, 32}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 10}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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_PLAIN, + 3, /* nr_channels */ + FALSE, /* is_array */ + FALSE, /* is_bitmask */ + FALSE, /* is_mixed */ + { + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 11}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 11}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 10}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = x */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* y = y */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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, + NULL, /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = x */ + {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, + NULL, /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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, + NULL, /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 128}, /* x = x */ + {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, + NULL, /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 64}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64}, /* z = b */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 64} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16}, /* z = b */ + {UTIL_FORMAT_TYPE_FLOAT, FALSE, 16} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 16} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 16} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 16} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 16}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 16} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 8}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8}, /* z = b */ + {UTIL_FORMAT_TYPE_SIGNED, FALSE, 8} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32}, /* y = g */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32}, /* z = b */ + {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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 32}, /* x = r */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32}, /* y = g */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32}, /* z = b */ + {UTIL_FORMAT_TYPE_FIXED, FALSE, 32} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = r */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_UNSIGNED, FALSE, 10}, /* z = b */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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, 10}, /* x = r */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 10}, /* y = g */ + {UTIL_FORMAT_TYPE_SIGNED, TRUE, 10}, /* z = b */ + {UTIL_FORMAT_TYPE_VOID, FALSE, 2} /* 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_8uscaled */ + NULL /* pack_s_8uscaled */ +}; + +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_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_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_USCALED: + return &util_format_s8_uscaled_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_USCALED: + return &util_format_z24_unorm_s8_uscaled_description; + case PIPE_FORMAT_S8_USCALED_Z24_UNORM: + return &util_format_s8_uscaled_z24_unorm_description; + case PIPE_FORMAT_X24S8_USCALED: + return &util_format_x24s8_uscaled_description; + case PIPE_FORMAT_S8X24_USCALED: + return &util_format_s8x24_uscaled_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_USCALED: + return &util_format_z32_float_s8x24_uscaled_description; + case PIPE_FORMAT_X32_S8X24_USCALED: + return &util_format_x32_s8x24_uscaled_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_R10G10B10A2_USCALED: + return &util_format_r10g10b10a2_uscaled_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_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; + default: + return NULL; + } +} + diff --git a/lib/libGL/gallium/libgallium/generated/u_half.c b/lib/libGL/gallium/libgallium/generated/u_half.c new file mode 100644 index 000000000..fe3146d57 --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/u_half.c @@ -0,0 +1,3217 @@ +/* This file is autogenerated by u_half.py. Do not edit directly. */ +#include "util/u_half.h" + +const uint32_t util_half_to_float_mantissa_table[2048] = { + 0x0, + 0x33800000, + 0x34000000, + 0x34400000, + 0x34800000, + 0x34a00000, + 0x34c00000, + 0x34e00000, + 0x35000000, + 0x35100000, + 0x35200000, + 0x35300000, + 0x35400000, + 0x35500000, + 0x35600000, + 0x35700000, + 0x35800000, + 0x35880000, + 0x35900000, + 0x35980000, + 0x35a00000, + 0x35a80000, + 0x35b00000, + 0x35b80000, + 0x35c00000, + 0x35c80000, + 0x35d00000, + 0x35d80000, + 0x35e00000, + 0x35e80000, + 0x35f00000, + 0x35f80000, + 0x36000000, + 0x36040000, + 0x36080000, + 0x360c0000, + 0x36100000, + 0x36140000, + 0x36180000, + 0x361c0000, + 0x36200000, + 0x36240000, + 0x36280000, + 0x362c0000, + 0x36300000, + 0x36340000, + 0x36380000, + 0x363c0000, + 0x36400000, + 0x36440000, + 0x36480000, + 0x364c0000, + 0x36500000, + 0x36540000, + 0x36580000, + 0x365c0000, + 0x36600000, + 0x36640000, + 0x36680000, + 0x366c0000, + 0x36700000, + 0x36740000, + 0x36780000, + 0x367c0000, + 0x36800000, + 0x36820000, + 0x36840000, + 0x36860000, + 0x36880000, + 0x368a0000, + 0x368c0000, + 0x368e0000, + 0x36900000, + 0x36920000, + 0x36940000, + 0x36960000, + 0x36980000, + 0x369a0000, + 0x369c0000, + 0x369e0000, + 0x36a00000, + 0x36a20000, + 0x36a40000, + 0x36a60000, + 0x36a80000, + 0x36aa0000, + 0x36ac0000, + 0x36ae0000, + 0x36b00000, + 0x36b20000, + 0x36b40000, + 0x36b60000, + 0x36b80000, + 0x36ba0000, + 0x36bc0000, + 0x36be0000, + 0x36c00000, + 0x36c20000, + 0x36c40000, + 0x36c60000, + 0x36c80000, + 0x36ca0000, + 0x36cc0000, + 0x36ce0000, + 0x36d00000, + 0x36d20000, + 0x36d40000, + 0x36d60000, + 0x36d80000, + 0x36da0000, + 0x36dc0000, + 0x36de0000, + 0x36e00000, + 0x36e20000, + 0x36e40000, + 0x36e60000, + 0x36e80000, + 0x36ea0000, + 0x36ec0000, + 0x36ee0000, + 0x36f00000, + 0x36f20000, + 0x36f40000, + 0x36f60000, + 0x36f80000, + 0x36fa0000, + 0x36fc0000, + 0x36fe0000, + 0x37000000, + 0x37010000, + 0x37020000, + 0x37030000, + 0x37040000, + 0x37050000, + 0x37060000, + 0x37070000, + 0x37080000, + 0x37090000, + 0x370a0000, + 0x370b0000, + 0x370c0000, + 0x370d0000, + 0x370e0000, + 0x370f0000, + 0x37100000, + 0x37110000, + 0x37120000, + 0x37130000, + 0x37140000, + 0x37150000, + 0x37160000, + 0x37170000, + 0x37180000, + 0x37190000, + 0x371a0000, + 0x371b0000, + 0x371c0000, + 0x371d0000, + 0x371e0000, + 0x371f0000, + 0x37200000, + 0x37210000, + 0x37220000, + 0x37230000, + 0x37240000, + 0x37250000, + 0x37260000, + 0x37270000, + 0x37280000, + 0x37290000, + 0x372a0000, + 0x372b0000, + 0x372c0000, + 0x372d0000, + 0x372e0000, + 0x372f0000, + 0x37300000, + 0x37310000, + 0x37320000, + 0x37330000, + 0x37340000, + 0x37350000, + 0x37360000, + 0x37370000, + 0x37380000, + 0x37390000, + 0x373a0000, + 0x373b0000, + 0x373c0000, + 0x373d0000, + 0x373e0000, + 0x373f0000, + 0x37400000, + 0x37410000, + 0x37420000, + 0x37430000, + 0x37440000, + 0x37450000, + 0x37460000, + 0x37470000, + 0x37480000, + 0x37490000, + 0x374a0000, + 0x374b0000, + 0x374c0000, + 0x374d0000, + 0x374e0000, + 0x374f0000, + 0x37500000, + 0x37510000, + 0x37520000, + 0x37530000, + 0x37540000, + 0x37550000, + 0x37560000, + 0x37570000, + 0x37580000, + 0x37590000, + 0x375a0000, + 0x375b0000, + 0x375c0000, + 0x375d0000, + 0x375e0000, + 0x375f0000, + 0x37600000, + 0x37610000, + 0x37620000, + 0x37630000, + 0x37640000, + 0x37650000, + 0x37660000, + 0x37670000, + 0x37680000, + 0x37690000, + 0x376a0000, + 0x376b0000, + 0x376c0000, + 0x376d0000, + 0x376e0000, + 0x376f0000, + 0x37700000, + 0x37710000, + 0x37720000, + 0x37730000, + 0x37740000, + 0x37750000, + 0x37760000, + 0x37770000, + 0x37780000, + 0x37790000, + 0x377a0000, + 0x377b0000, + 0x377c0000, + 0x377d0000, + 0x377e0000, + 0x377f0000, + 0x37800000, + 0x37808000, + 0x37810000, + 0x37818000, + 0x37820000, + 0x37828000, + 0x37830000, + 0x37838000, + 0x37840000, + 0x37848000, + 0x37850000, + 0x37858000, + 0x37860000, + 0x37868000, + 0x37870000, + 0x37878000, + 0x37880000, + 0x37888000, + 0x37890000, + 0x37898000, + 0x378a0000, + 0x378a8000, + 0x378b0000, + 0x378b8000, + 0x378c0000, + 0x378c8000, + 0x378d0000, + 0x378d8000, + 0x378e0000, + 0x378e8000, + 0x378f0000, + 0x378f8000, + 0x37900000, + 0x37908000, + 0x37910000, + 0x37918000, + 0x37920000, + 0x37928000, + 0x37930000, + 0x37938000, + 0x37940000, + 0x37948000, + 0x37950000, + 0x37958000, + 0x37960000, + 0x37968000, + 0x37970000, + 0x37978000, + 0x37980000, + 0x37988000, + 0x37990000, + 0x37998000, + 0x379a0000, + 0x379a8000, + 0x379b0000, + 0x379b8000, + 0x379c0000, + 0x379c8000, + 0x379d0000, + 0x379d8000, + 0x379e0000, + 0x379e8000, + 0x379f0000, + 0x379f8000, + 0x37a00000, + 0x37a08000, + 0x37a10000, + 0x37a18000, + 0x37a20000, + 0x37a28000, + 0x37a30000, + 0x37a38000, + 0x37a40000, + 0x37a48000, + 0x37a50000, + 0x37a58000, + 0x37a60000, + 0x37a68000, + 0x37a70000, + 0x37a78000, + 0x37a80000, + 0x37a88000, + 0x37a90000, + 0x37a98000, + 0x37aa0000, + 0x37aa8000, + 0x37ab0000, + 0x37ab8000, + 0x37ac0000, + 0x37ac8000, + 0x37ad0000, + 0x37ad8000, + 0x37ae0000, + 0x37ae8000, + 0x37af0000, + 0x37af8000, + 0x37b00000, + 0x37b08000, + 0x37b10000, + 0x37b18000, + 0x37b20000, + 0x37b28000, + 0x37b30000, + 0x37b38000, + 0x37b40000, + 0x37b48000, + 0x37b50000, + 0x37b58000, + 0x37b60000, + 0x37b68000, + 0x37b70000, + 0x37b78000, + 0x37b80000, + 0x37b88000, + 0x37b90000, + 0x37b98000, + 0x37ba0000, + 0x37ba8000, + 0x37bb0000, + 0x37bb8000, + 0x37bc0000, + 0x37bc8000, + 0x37bd0000, + 0x37bd8000, + 0x37be0000, + 0x37be8000, + 0x37bf0000, + 0x37bf8000, + 0x37c00000, + 0x37c08000, + 0x37c10000, + 0x37c18000, + 0x37c20000, + 0x37c28000, + 0x37c30000, + 0x37c38000, + 0x37c40000, + 0x37c48000, + 0x37c50000, + 0x37c58000, + 0x37c60000, + 0x37c68000, + 0x37c70000, + 0x37c78000, + 0x37c80000, + 0x37c88000, + 0x37c90000, + 0x37c98000, + 0x37ca0000, + 0x37ca8000, + 0x37cb0000, + 0x37cb8000, + 0x37cc0000, + 0x37cc8000, + 0x37cd0000, + 0x37cd8000, + 0x37ce0000, + 0x37ce8000, + 0x37cf0000, + 0x37cf8000, + 0x37d00000, + 0x37d08000, + 0x37d10000, + 0x37d18000, + 0x37d20000, + 0x37d28000, + 0x37d30000, + 0x37d38000, + 0x37d40000, + 0x37d48000, + 0x37d50000, + 0x37d58000, + 0x37d60000, + 0x37d68000, + 0x37d70000, + 0x37d78000, + 0x37d80000, + 0x37d88000, + 0x37d90000, + 0x37d98000, + 0x37da0000, + 0x37da8000, + 0x37db0000, + 0x37db8000, + 0x37dc0000, + 0x37dc8000, + 0x37dd0000, + 0x37dd8000, + 0x37de0000, + 0x37de8000, + 0x37df0000, + 0x37df8000, + 0x37e00000, + 0x37e08000, + 0x37e10000, + 0x37e18000, + 0x37e20000, + 0x37e28000, + 0x37e30000, + 0x37e38000, + 0x37e40000, + 0x37e48000, + 0x37e50000, + 0x37e58000, + 0x37e60000, + 0x37e68000, + 0x37e70000, + 0x37e78000, + 0x37e80000, + 0x37e88000, + 0x37e90000, + 0x37e98000, + 0x37ea0000, + 0x37ea8000, + 0x37eb0000, + 0x37eb8000, + 0x37ec0000, + 0x37ec8000, + 0x37ed0000, + 0x37ed8000, + 0x37ee0000, + 0x37ee8000, + 0x37ef0000, + 0x37ef8000, + 0x37f00000, + 0x37f08000, + 0x37f10000, + 0x37f18000, + 0x37f20000, + 0x37f28000, + 0x37f30000, + 0x37f38000, + 0x37f40000, + 0x37f48000, + 0x37f50000, + 0x37f58000, + 0x37f60000, + 0x37f68000, + 0x37f70000, + 0x37f78000, + 0x37f80000, + 0x37f88000, + 0x37f90000, + 0x37f98000, + 0x37fa0000, + 0x37fa8000, + 0x37fb0000, + 0x37fb8000, + 0x37fc0000, + 0x37fc8000, + 0x37fd0000, + 0x37fd8000, + 0x37fe0000, + 0x37fe8000, + 0x37ff0000, + 0x37ff8000, + 0x38000000, + 0x38004000, + 0x38008000, + 0x3800c000, + 0x38010000, + 0x38014000, + 0x38018000, + 0x3801c000, + 0x38020000, + 0x38024000, + 0x38028000, + 0x3802c000, + 0x38030000, + 0x38034000, + 0x38038000, + 0x3803c000, + 0x38040000, + 0x38044000, + 0x38048000, + 0x3804c000, + 0x38050000, + 0x38054000, + 0x38058000, + 0x3805c000, + 0x38060000, + 0x38064000, + 0x38068000, + 0x3806c000, + 0x38070000, + 0x38074000, + 0x38078000, + 0x3807c000, + 0x38080000, + 0x38084000, + 0x38088000, + 0x3808c000, + 0x38090000, + 0x38094000, + 0x38098000, + 0x3809c000, + 0x380a0000, + 0x380a4000, + 0x380a8000, + 0x380ac000, + 0x380b0000, + 0x380b4000, + 0x380b8000, + 0x380bc000, + 0x380c0000, + 0x380c4000, + 0x380c8000, + 0x380cc000, + 0x380d0000, + 0x380d4000, + 0x380d8000, + 0x380dc000, + 0x380e0000, + 0x380e4000, + 0x380e8000, + 0x380ec000, + 0x380f0000, + 0x380f4000, + 0x380f8000, + 0x380fc000, + 0x38100000, + 0x38104000, + 0x38108000, + 0x3810c000, + 0x38110000, + 0x38114000, + 0x38118000, + 0x3811c000, + 0x38120000, + 0x38124000, + 0x38128000, + 0x3812c000, + 0x38130000, + 0x38134000, + 0x38138000, + 0x3813c000, + 0x38140000, + 0x38144000, + 0x38148000, + 0x3814c000, + 0x38150000, + 0x38154000, + 0x38158000, + 0x3815c000, + 0x38160000, + 0x38164000, + 0x38168000, + 0x3816c000, + 0x38170000, + 0x38174000, + 0x38178000, + 0x3817c000, + 0x38180000, + 0x38184000, + 0x38188000, + 0x3818c000, + 0x38190000, + 0x38194000, + 0x38198000, + 0x3819c000, + 0x381a0000, + 0x381a4000, + 0x381a8000, + 0x381ac000, + 0x381b0000, + 0x381b4000, + 0x381b8000, + 0x381bc000, + 0x381c0000, + 0x381c4000, + 0x381c8000, + 0x381cc000, + 0x381d0000, + 0x381d4000, + 0x381d8000, + 0x381dc000, + 0x381e0000, + 0x381e4000, + 0x381e8000, + 0x381ec000, + 0x381f0000, + 0x381f4000, + 0x381f8000, + 0x381fc000, + 0x38200000, + 0x38204000, + 0x38208000, + 0x3820c000, + 0x38210000, + 0x38214000, + 0x38218000, + 0x3821c000, + 0x38220000, + 0x38224000, + 0x38228000, + 0x3822c000, + 0x38230000, + 0x38234000, + 0x38238000, + 0x3823c000, + 0x38240000, + 0x38244000, + 0x38248000, + 0x3824c000, + 0x38250000, + 0x38254000, + 0x38258000, + 0x3825c000, + 0x38260000, + 0x38264000, + 0x38268000, + 0x3826c000, + 0x38270000, + 0x38274000, + 0x38278000, + 0x3827c000, + 0x38280000, + 0x38284000, + 0x38288000, + 0x3828c000, + 0x38290000, + 0x38294000, + 0x38298000, + 0x3829c000, + 0x382a0000, + 0x382a4000, + 0x382a8000, + 0x382ac000, + 0x382b0000, + 0x382b4000, + 0x382b8000, + 0x382bc000, + 0x382c0000, + 0x382c4000, + 0x382c8000, + 0x382cc000, + 0x382d0000, + 0x382d4000, + 0x382d8000, + 0x382dc000, + 0x382e0000, + 0x382e4000, + 0x382e8000, + 0x382ec000, + 0x382f0000, + 0x382f4000, + 0x382f8000, + 0x382fc000, + 0x38300000, + 0x38304000, + 0x38308000, + 0x3830c000, + 0x38310000, + 0x38314000, + 0x38318000, + 0x3831c000, + 0x38320000, + 0x38324000, + 0x38328000, + 0x3832c000, + 0x38330000, + 0x38334000, + 0x38338000, + 0x3833c000, + 0x38340000, + 0x38344000, + 0x38348000, + 0x3834c000, + 0x38350000, + 0x38354000, + 0x38358000, + 0x3835c000, + 0x38360000, + 0x38364000, + 0x38368000, + 0x3836c000, + 0x38370000, + 0x38374000, + 0x38378000, + 0x3837c000, + 0x38380000, + 0x38384000, + 0x38388000, + 0x3838c000, + 0x38390000, + 0x38394000, + 0x38398000, + 0x3839c000, + 0x383a0000, + 0x383a4000, + 0x383a8000, + 0x383ac000, + 0x383b0000, + 0x383b4000, + 0x383b8000, + 0x383bc000, + 0x383c0000, + 0x383c4000, + 0x383c8000, + 0x383cc000, + 0x383d0000, + 0x383d4000, + 0x383d8000, + 0x383dc000, + 0x383e0000, + 0x383e4000, + 0x383e8000, + 0x383ec000, + 0x383f0000, + 0x383f4000, + 0x383f8000, + 0x383fc000, + 0x38400000, + 0x38404000, + 0x38408000, + 0x3840c000, + 0x38410000, + 0x38414000, + 0x38418000, + 0x3841c000, + 0x38420000, + 0x38424000, + 0x38428000, + 0x3842c000, + 0x38430000, + 0x38434000, + 0x38438000, + 0x3843c000, + 0x38440000, + 0x38444000, + 0x38448000, + 0x3844c000, + 0x38450000, + 0x38454000, + 0x38458000, + 0x3845c000, + 0x38460000, + 0x38464000, + 0x38468000, + 0x3846c000, + 0x38470000, + 0x38474000, + 0x38478000, + 0x3847c000, + 0x38480000, + 0x38484000, + 0x38488000, + 0x3848c000, + 0x38490000, + 0x38494000, + 0x38498000, + 0x3849c000, + 0x384a0000, + 0x384a4000, + 0x384a8000, + 0x384ac000, + 0x384b0000, + 0x384b4000, + 0x384b8000, + 0x384bc000, + 0x384c0000, + 0x384c4000, + 0x384c8000, + 0x384cc000, + 0x384d0000, + 0x384d4000, + 0x384d8000, + 0x384dc000, + 0x384e0000, + 0x384e4000, + 0x384e8000, + 0x384ec000, + 0x384f0000, + 0x384f4000, + 0x384f8000, + 0x384fc000, + 0x38500000, + 0x38504000, + 0x38508000, + 0x3850c000, + 0x38510000, + 0x38514000, + 0x38518000, + 0x3851c000, + 0x38520000, + 0x38524000, + 0x38528000, + 0x3852c000, + 0x38530000, + 0x38534000, + 0x38538000, + 0x3853c000, + 0x38540000, + 0x38544000, + 0x38548000, + 0x3854c000, + 0x38550000, + 0x38554000, + 0x38558000, + 0x3855c000, + 0x38560000, + 0x38564000, + 0x38568000, + 0x3856c000, + 0x38570000, + 0x38574000, + 0x38578000, + 0x3857c000, + 0x38580000, + 0x38584000, + 0x38588000, + 0x3858c000, + 0x38590000, + 0x38594000, + 0x38598000, + 0x3859c000, + 0x385a0000, + 0x385a4000, + 0x385a8000, + 0x385ac000, + 0x385b0000, + 0x385b4000, + 0x385b8000, + 0x385bc000, + 0x385c0000, + 0x385c4000, + 0x385c8000, + 0x385cc000, + 0x385d0000, + 0x385d4000, + 0x385d8000, + 0x385dc000, + 0x385e0000, + 0x385e4000, + 0x385e8000, + 0x385ec000, + 0x385f0000, + 0x385f4000, + 0x385f8000, + 0x385fc000, + 0x38600000, + 0x38604000, + 0x38608000, + 0x3860c000, + 0x38610000, + 0x38614000, + 0x38618000, + 0x3861c000, + 0x38620000, + 0x38624000, + 0x38628000, + 0x3862c000, + 0x38630000, + 0x38634000, + 0x38638000, + 0x3863c000, + 0x38640000, + 0x38644000, + 0x38648000, + 0x3864c000, + 0x38650000, + 0x38654000, + 0x38658000, + 0x3865c000, + 0x38660000, + 0x38664000, + 0x38668000, + 0x3866c000, + 0x38670000, + 0x38674000, + 0x38678000, + 0x3867c000, + 0x38680000, + 0x38684000, + 0x38688000, + 0x3868c000, + 0x38690000, + 0x38694000, + 0x38698000, + 0x3869c000, + 0x386a0000, + 0x386a4000, + 0x386a8000, + 0x386ac000, + 0x386b0000, + 0x386b4000, + 0x386b8000, + 0x386bc000, + 0x386c0000, + 0x386c4000, + 0x386c8000, + 0x386cc000, + 0x386d0000, + 0x386d4000, + 0x386d8000, + 0x386dc000, + 0x386e0000, + 0x386e4000, + 0x386e8000, + 0x386ec000, + 0x386f0000, + 0x386f4000, + 0x386f8000, + 0x386fc000, + 0x38700000, + 0x38704000, + 0x38708000, + 0x3870c000, + 0x38710000, + 0x38714000, + 0x38718000, + 0x3871c000, + 0x38720000, + 0x38724000, + 0x38728000, + 0x3872c000, + 0x38730000, + 0x38734000, + 0x38738000, + 0x3873c000, + 0x38740000, + 0x38744000, + 0x38748000, + 0x3874c000, + 0x38750000, + 0x38754000, + 0x38758000, + 0x3875c000, + 0x38760000, + 0x38764000, + 0x38768000, + 0x3876c000, + 0x38770000, + 0x38774000, + 0x38778000, + 0x3877c000, + 0x38780000, + 0x38784000, + 0x38788000, + 0x3878c000, + 0x38790000, + 0x38794000, + 0x38798000, + 0x3879c000, + 0x387a0000, + 0x387a4000, + 0x387a8000, + 0x387ac000, + 0x387b0000, + 0x387b4000, + 0x387b8000, + 0x387bc000, + 0x387c0000, + 0x387c4000, + 0x387c8000, + 0x387cc000, + 0x387d0000, + 0x387d4000, + 0x387d8000, + 0x387dc000, + 0x387e0000, + 0x387e4000, + 0x387e8000, + 0x387ec000, + 0x387f0000, + 0x387f4000, + 0x387f8000, + 0x387fc000, + 0x0, + 0x2000, + 0x4000, + 0x6000, + 0x8000, + 0xa000, + 0xc000, + 0xe000, + 0x10000, + 0x12000, + 0x14000, + 0x16000, + 0x18000, + 0x1a000, + 0x1c000, + 0x1e000, + 0x20000, + 0x22000, + 0x24000, + 0x26000, + 0x28000, + 0x2a000, + 0x2c000, + 0x2e000, + 0x30000, + 0x32000, + 0x34000, + 0x36000, + 0x38000, + 0x3a000, + 0x3c000, + 0x3e000, + 0x40000, + 0x42000, + 0x44000, + 0x46000, + 0x48000, + 0x4a000, + 0x4c000, + 0x4e000, + 0x50000, + 0x52000, + 0x54000, + 0x56000, + 0x58000, + 0x5a000, + 0x5c000, + 0x5e000, + 0x60000, + 0x62000, + 0x64000, + 0x66000, + 0x68000, + 0x6a000, + 0x6c000, + 0x6e000, + 0x70000, + 0x72000, + 0x74000, + 0x76000, + 0x78000, + 0x7a000, + 0x7c000, + 0x7e000, + 0x80000, + 0x82000, + 0x84000, + 0x86000, + 0x88000, + 0x8a000, + 0x8c000, + 0x8e000, + 0x90000, + 0x92000, + 0x94000, + 0x96000, + 0x98000, + 0x9a000, + 0x9c000, + 0x9e000, + 0xa0000, + 0xa2000, + 0xa4000, + 0xa6000, + 0xa8000, + 0xaa000, + 0xac000, + 0xae000, + 0xb0000, + 0xb2000, + 0xb4000, + 0xb6000, + 0xb8000, + 0xba000, + 0xbc000, + 0xbe000, + 0xc0000, + 0xc2000, + 0xc4000, + 0xc6000, + 0xc8000, + 0xca000, + 0xcc000, + 0xce000, + 0xd0000, + 0xd2000, + 0xd4000, + 0xd6000, + 0xd8000, + 0xda000, + 0xdc000, + 0xde000, + 0xe0000, + 0xe2000, + 0xe4000, + 0xe6000, + 0xe8000, + 0xea000, + 0xec000, + 0xee000, + 0xf0000, + 0xf2000, + 0xf4000, + 0xf6000, + 0xf8000, + 0xfa000, + 0xfc000, + 0xfe000, + 0x100000, + 0x102000, + 0x104000, + 0x106000, + 0x108000, + 0x10a000, + 0x10c000, + 0x10e000, + 0x110000, + 0x112000, + 0x114000, + 0x116000, + 0x118000, + 0x11a000, + 0x11c000, + 0x11e000, + 0x120000, + 0x122000, + 0x124000, + 0x126000, + 0x128000, + 0x12a000, + 0x12c000, + 0x12e000, + 0x130000, + 0x132000, + 0x134000, + 0x136000, + 0x138000, + 0x13a000, + 0x13c000, + 0x13e000, + 0x140000, + 0x142000, + 0x144000, + 0x146000, + 0x148000, + 0x14a000, + 0x14c000, + 0x14e000, + 0x150000, + 0x152000, + 0x154000, + 0x156000, + 0x158000, + 0x15a000, + 0x15c000, + 0x15e000, + 0x160000, + 0x162000, + 0x164000, + 0x166000, + 0x168000, + 0x16a000, + 0x16c000, + 0x16e000, + 0x170000, + 0x172000, + 0x174000, + 0x176000, + 0x178000, + 0x17a000, + 0x17c000, + 0x17e000, + 0x180000, + 0x182000, + 0x184000, + 0x186000, + 0x188000, + 0x18a000, + 0x18c000, + 0x18e000, + 0x190000, + 0x192000, + 0x194000, + 0x196000, + 0x198000, + 0x19a000, + 0x19c000, + 0x19e000, + 0x1a0000, + 0x1a2000, + 0x1a4000, + 0x1a6000, + 0x1a8000, + 0x1aa000, + 0x1ac000, + 0x1ae000, + 0x1b0000, + 0x1b2000, + 0x1b4000, + 0x1b6000, + 0x1b8000, + 0x1ba000, + 0x1bc000, + 0x1be000, + 0x1c0000, + 0x1c2000, + 0x1c4000, + 0x1c6000, + 0x1c8000, + 0x1ca000, + 0x1cc000, + 0x1ce000, + 0x1d0000, + 0x1d2000, + 0x1d4000, + 0x1d6000, + 0x1d8000, + 0x1da000, + 0x1dc000, + 0x1de000, + 0x1e0000, + 0x1e2000, + 0x1e4000, + 0x1e6000, + 0x1e8000, + 0x1ea000, + 0x1ec000, + 0x1ee000, + 0x1f0000, + 0x1f2000, + 0x1f4000, + 0x1f6000, + 0x1f8000, + 0x1fa000, + 0x1fc000, + 0x1fe000, + 0x200000, + 0x202000, + 0x204000, + 0x206000, + 0x208000, + 0x20a000, + 0x20c000, + 0x20e000, + 0x210000, + 0x212000, + 0x214000, + 0x216000, + 0x218000, + 0x21a000, + 0x21c000, + 0x21e000, + 0x220000, + 0x222000, + 0x224000, + 0x226000, + 0x228000, + 0x22a000, + 0x22c000, + 0x22e000, + 0x230000, + 0x232000, + 0x234000, + 0x236000, + 0x238000, + 0x23a000, + 0x23c000, + 0x23e000, + 0x240000, + 0x242000, + 0x244000, + 0x246000, + 0x248000, + 0x24a000, + 0x24c000, + 0x24e000, + 0x250000, + 0x252000, + 0x254000, + 0x256000, + 0x258000, + 0x25a000, + 0x25c000, + 0x25e000, + 0x260000, + 0x262000, + 0x264000, + 0x266000, + 0x268000, + 0x26a000, + 0x26c000, + 0x26e000, + 0x270000, + 0x272000, + 0x274000, + 0x276000, + 0x278000, + 0x27a000, + 0x27c000, + 0x27e000, + 0x280000, + 0x282000, + 0x284000, + 0x286000, + 0x288000, + 0x28a000, + 0x28c000, + 0x28e000, + 0x290000, + 0x292000, + 0x294000, + 0x296000, + 0x298000, + 0x29a000, + 0x29c000, + 0x29e000, + 0x2a0000, + 0x2a2000, + 0x2a4000, + 0x2a6000, + 0x2a8000, + 0x2aa000, + 0x2ac000, + 0x2ae000, + 0x2b0000, + 0x2b2000, + 0x2b4000, + 0x2b6000, + 0x2b8000, + 0x2ba000, + 0x2bc000, + 0x2be000, + 0x2c0000, + 0x2c2000, + 0x2c4000, + 0x2c6000, + 0x2c8000, + 0x2ca000, + 0x2cc000, + 0x2ce000, + 0x2d0000, + 0x2d2000, + 0x2d4000, + 0x2d6000, + 0x2d8000, + 0x2da000, + 0x2dc000, + 0x2de000, + 0x2e0000, + 0x2e2000, + 0x2e4000, + 0x2e6000, + 0x2e8000, + 0x2ea000, + 0x2ec000, + 0x2ee000, + 0x2f0000, + 0x2f2000, + 0x2f4000, + 0x2f6000, + 0x2f8000, + 0x2fa000, + 0x2fc000, + 0x2fe000, + 0x300000, + 0x302000, + 0x304000, + 0x306000, + 0x308000, + 0x30a000, + 0x30c000, + 0x30e000, + 0x310000, + 0x312000, + 0x314000, + 0x316000, + 0x318000, + 0x31a000, + 0x31c000, + 0x31e000, + 0x320000, + 0x322000, + 0x324000, + 0x326000, + 0x328000, + 0x32a000, + 0x32c000, + 0x32e000, + 0x330000, + 0x332000, + 0x334000, + 0x336000, + 0x338000, + 0x33a000, + 0x33c000, + 0x33e000, + 0x340000, + 0x342000, + 0x344000, + 0x346000, + 0x348000, + 0x34a000, + 0x34c000, + 0x34e000, + 0x350000, + 0x352000, + 0x354000, + 0x356000, + 0x358000, + 0x35a000, + 0x35c000, + 0x35e000, + 0x360000, + 0x362000, + 0x364000, + 0x366000, + 0x368000, + 0x36a000, + 0x36c000, + 0x36e000, + 0x370000, + 0x372000, + 0x374000, + 0x376000, + 0x378000, + 0x37a000, + 0x37c000, + 0x37e000, + 0x380000, + 0x382000, + 0x384000, + 0x386000, + 0x388000, + 0x38a000, + 0x38c000, + 0x38e000, + 0x390000, + 0x392000, + 0x394000, + 0x396000, + 0x398000, + 0x39a000, + 0x39c000, + 0x39e000, + 0x3a0000, + 0x3a2000, + 0x3a4000, + 0x3a6000, + 0x3a8000, + 0x3aa000, + 0x3ac000, + 0x3ae000, + 0x3b0000, + 0x3b2000, + 0x3b4000, + 0x3b6000, + 0x3b8000, + 0x3ba000, + 0x3bc000, + 0x3be000, + 0x3c0000, + 0x3c2000, + 0x3c4000, + 0x3c6000, + 0x3c8000, + 0x3ca000, + 0x3cc000, + 0x3ce000, + 0x3d0000, + 0x3d2000, + 0x3d4000, + 0x3d6000, + 0x3d8000, + 0x3da000, + 0x3dc000, + 0x3de000, + 0x3e0000, + 0x3e2000, + 0x3e4000, + 0x3e6000, + 0x3e8000, + 0x3ea000, + 0x3ec000, + 0x3ee000, + 0x3f0000, + 0x3f2000, + 0x3f4000, + 0x3f6000, + 0x3f8000, + 0x3fa000, + 0x3fc000, + 0x3fe000, + 0x400000, + 0x402000, + 0x404000, + 0x406000, + 0x408000, + 0x40a000, + 0x40c000, + 0x40e000, + 0x410000, + 0x412000, + 0x414000, + 0x416000, + 0x418000, + 0x41a000, + 0x41c000, + 0x41e000, + 0x420000, + 0x422000, + 0x424000, + 0x426000, + 0x428000, + 0x42a000, + 0x42c000, + 0x42e000, + 0x430000, + 0x432000, + 0x434000, + 0x436000, + 0x438000, + 0x43a000, + 0x43c000, + 0x43e000, + 0x440000, + 0x442000, + 0x444000, + 0x446000, + 0x448000, + 0x44a000, + 0x44c000, + 0x44e000, + 0x450000, + 0x452000, + 0x454000, + 0x456000, + 0x458000, + 0x45a000, + 0x45c000, + 0x45e000, + 0x460000, + 0x462000, + 0x464000, + 0x466000, + 0x468000, + 0x46a000, + 0x46c000, + 0x46e000, + 0x470000, + 0x472000, + 0x474000, + 0x476000, + 0x478000, + 0x47a000, + 0x47c000, + 0x47e000, + 0x480000, + 0x482000, + 0x484000, + 0x486000, + 0x488000, + 0x48a000, + 0x48c000, + 0x48e000, + 0x490000, + 0x492000, + 0x494000, + 0x496000, + 0x498000, + 0x49a000, + 0x49c000, + 0x49e000, + 0x4a0000, + 0x4a2000, + 0x4a4000, + 0x4a6000, + 0x4a8000, + 0x4aa000, + 0x4ac000, + 0x4ae000, + 0x4b0000, + 0x4b2000, + 0x4b4000, + 0x4b6000, + 0x4b8000, + 0x4ba000, + 0x4bc000, + 0x4be000, + 0x4c0000, + 0x4c2000, + 0x4c4000, + 0x4c6000, + 0x4c8000, + 0x4ca000, + 0x4cc000, + 0x4ce000, + 0x4d0000, + 0x4d2000, + 0x4d4000, + 0x4d6000, + 0x4d8000, + 0x4da000, + 0x4dc000, + 0x4de000, + 0x4e0000, + 0x4e2000, + 0x4e4000, + 0x4e6000, + 0x4e8000, + 0x4ea000, + 0x4ec000, + 0x4ee000, + 0x4f0000, + 0x4f2000, + 0x4f4000, + 0x4f6000, + 0x4f8000, + 0x4fa000, + 0x4fc000, + 0x4fe000, + 0x500000, + 0x502000, + 0x504000, + 0x506000, + 0x508000, + 0x50a000, + 0x50c000, + 0x50e000, + 0x510000, + 0x512000, + 0x514000, + 0x516000, + 0x518000, + 0x51a000, + 0x51c000, + 0x51e000, + 0x520000, + 0x522000, + 0x524000, + 0x526000, + 0x528000, + 0x52a000, + 0x52c000, + 0x52e000, + 0x530000, + 0x532000, + 0x534000, + 0x536000, + 0x538000, + 0x53a000, + 0x53c000, + 0x53e000, + 0x540000, + 0x542000, + 0x544000, + 0x546000, + 0x548000, + 0x54a000, + 0x54c000, + 0x54e000, + 0x550000, + 0x552000, + 0x554000, + 0x556000, + 0x558000, + 0x55a000, + 0x55c000, + 0x55e000, + 0x560000, + 0x562000, + 0x564000, + 0x566000, + 0x568000, + 0x56a000, + 0x56c000, + 0x56e000, + 0x570000, + 0x572000, + 0x574000, + 0x576000, + 0x578000, + 0x57a000, + 0x57c000, + 0x57e000, + 0x580000, + 0x582000, + 0x584000, + 0x586000, + 0x588000, + 0x58a000, + 0x58c000, + 0x58e000, + 0x590000, + 0x592000, + 0x594000, + 0x596000, + 0x598000, + 0x59a000, + 0x59c000, + 0x59e000, + 0x5a0000, + 0x5a2000, + 0x5a4000, + 0x5a6000, + 0x5a8000, + 0x5aa000, + 0x5ac000, + 0x5ae000, + 0x5b0000, + 0x5b2000, + 0x5b4000, + 0x5b6000, + 0x5b8000, + 0x5ba000, + 0x5bc000, + 0x5be000, + 0x5c0000, + 0x5c2000, + 0x5c4000, + 0x5c6000, + 0x5c8000, + 0x5ca000, + 0x5cc000, + 0x5ce000, + 0x5d0000, + 0x5d2000, + 0x5d4000, + 0x5d6000, + 0x5d8000, + 0x5da000, + 0x5dc000, + 0x5de000, + 0x5e0000, + 0x5e2000, + 0x5e4000, + 0x5e6000, + 0x5e8000, + 0x5ea000, + 0x5ec000, + 0x5ee000, + 0x5f0000, + 0x5f2000, + 0x5f4000, + 0x5f6000, + 0x5f8000, + 0x5fa000, + 0x5fc000, + 0x5fe000, + 0x600000, + 0x602000, + 0x604000, + 0x606000, + 0x608000, + 0x60a000, + 0x60c000, + 0x60e000, + 0x610000, + 0x612000, + 0x614000, + 0x616000, + 0x618000, + 0x61a000, + 0x61c000, + 0x61e000, + 0x620000, + 0x622000, + 0x624000, + 0x626000, + 0x628000, + 0x62a000, + 0x62c000, + 0x62e000, + 0x630000, + 0x632000, + 0x634000, + 0x636000, + 0x638000, + 0x63a000, + 0x63c000, + 0x63e000, + 0x640000, + 0x642000, + 0x644000, + 0x646000, + 0x648000, + 0x64a000, + 0x64c000, + 0x64e000, + 0x650000, + 0x652000, + 0x654000, + 0x656000, + 0x658000, + 0x65a000, + 0x65c000, + 0x65e000, + 0x660000, + 0x662000, + 0x664000, + 0x666000, + 0x668000, + 0x66a000, + 0x66c000, + 0x66e000, + 0x670000, + 0x672000, + 0x674000, + 0x676000, + 0x678000, + 0x67a000, + 0x67c000, + 0x67e000, + 0x680000, + 0x682000, + 0x684000, + 0x686000, + 0x688000, + 0x68a000, + 0x68c000, + 0x68e000, + 0x690000, + 0x692000, + 0x694000, + 0x696000, + 0x698000, + 0x69a000, + 0x69c000, + 0x69e000, + 0x6a0000, + 0x6a2000, + 0x6a4000, + 0x6a6000, + 0x6a8000, + 0x6aa000, + 0x6ac000, + 0x6ae000, + 0x6b0000, + 0x6b2000, + 0x6b4000, + 0x6b6000, + 0x6b8000, + 0x6ba000, + 0x6bc000, + 0x6be000, + 0x6c0000, + 0x6c2000, + 0x6c4000, + 0x6c6000, + 0x6c8000, + 0x6ca000, + 0x6cc000, + 0x6ce000, + 0x6d0000, + 0x6d2000, + 0x6d4000, + 0x6d6000, + 0x6d8000, + 0x6da000, + 0x6dc000, + 0x6de000, + 0x6e0000, + 0x6e2000, + 0x6e4000, + 0x6e6000, + 0x6e8000, + 0x6ea000, + 0x6ec000, + 0x6ee000, + 0x6f0000, + 0x6f2000, + 0x6f4000, + 0x6f6000, + 0x6f8000, + 0x6fa000, + 0x6fc000, + 0x6fe000, + 0x700000, + 0x702000, + 0x704000, + 0x706000, + 0x708000, + 0x70a000, + 0x70c000, + 0x70e000, + 0x710000, + 0x712000, + 0x714000, + 0x716000, + 0x718000, + 0x71a000, + 0x71c000, + 0x71e000, + 0x720000, + 0x722000, + 0x724000, + 0x726000, + 0x728000, + 0x72a000, + 0x72c000, + 0x72e000, + 0x730000, + 0x732000, + 0x734000, + 0x736000, + 0x738000, + 0x73a000, + 0x73c000, + 0x73e000, + 0x740000, + 0x742000, + 0x744000, + 0x746000, + 0x748000, + 0x74a000, + 0x74c000, + 0x74e000, + 0x750000, + 0x752000, + 0x754000, + 0x756000, + 0x758000, + 0x75a000, + 0x75c000, + 0x75e000, + 0x760000, + 0x762000, + 0x764000, + 0x766000, + 0x768000, + 0x76a000, + 0x76c000, + 0x76e000, + 0x770000, + 0x772000, + 0x774000, + 0x776000, + 0x778000, + 0x77a000, + 0x77c000, + 0x77e000, + 0x780000, + 0x782000, + 0x784000, + 0x786000, + 0x788000, + 0x78a000, + 0x78c000, + 0x78e000, + 0x790000, + 0x792000, + 0x794000, + 0x796000, + 0x798000, + 0x79a000, + 0x79c000, + 0x79e000, + 0x7a0000, + 0x7a2000, + 0x7a4000, + 0x7a6000, + 0x7a8000, + 0x7aa000, + 0x7ac000, + 0x7ae000, + 0x7b0000, + 0x7b2000, + 0x7b4000, + 0x7b6000, + 0x7b8000, + 0x7ba000, + 0x7bc000, + 0x7be000, + 0x7c0000, + 0x7c2000, + 0x7c4000, + 0x7c6000, + 0x7c8000, + 0x7ca000, + 0x7cc000, + 0x7ce000, + 0x7d0000, + 0x7d2000, + 0x7d4000, + 0x7d6000, + 0x7d8000, + 0x7da000, + 0x7dc000, + 0x7de000, + 0x7e0000, + 0x7e2000, + 0x7e4000, + 0x7e6000, + 0x7e8000, + 0x7ea000, + 0x7ec000, + 0x7ee000, + 0x7f0000, + 0x7f2000, + 0x7f4000, + 0x7f6000, + 0x7f8000, + 0x7fa000, + 0x7fc000, + 0x7fe000, +}; + +const uint32_t util_half_to_float_exponent_table[64] = { + 0x0, + 0x38800000, + 0x39000000, + 0x39800000, + 0x3a000000, + 0x3a800000, + 0x3b000000, + 0x3b800000, + 0x3c000000, + 0x3c800000, + 0x3d000000, + 0x3d800000, + 0x3e000000, + 0x3e800000, + 0x3f000000, + 0x3f800000, + 0x40000000, + 0x40800000, + 0x41000000, + 0x41800000, + 0x42000000, + 0x42800000, + 0x43000000, + 0x43800000, + 0x44000000, + 0x44800000, + 0x45000000, + 0x45800000, + 0x46000000, + 0x46800000, + 0x47000000, + 0x7f800000, + 0x80000000, + 0xb8800000, + 0xb9000000, + 0xb9800000, + 0xba000000, + 0xba800000, + 0xbb000000, + 0xbb800000, + 0xbc000000, + 0xbc800000, + 0xbd000000, + 0xbd800000, + 0xbe000000, + 0xbe800000, + 0xbf000000, + 0xbf800000, + 0xc0000000, + 0xc0800000, + 0xc1000000, + 0xc1800000, + 0xc2000000, + 0xc2800000, + 0xc3000000, + 0xc3800000, + 0xc4000000, + 0xc4800000, + 0xc5000000, + 0xc5800000, + 0xc6000000, + 0xc6800000, + 0xc7000000, + 0xff800000, +}; + +const uint32_t util_half_to_float_offset_table[64] = { + 0x0, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x0, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, + 0x400, +}; + +const uint16_t util_float_to_half_base_table[512] = { + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x0, + 0x1, + 0x2, + 0x4, + 0x8, + 0x10, + 0x20, + 0x40, + 0x80, + 0x100, + 0x200, + 0x400, + 0x800, + 0xc00, + 0x1000, + 0x1400, + 0x1800, + 0x1c00, + 0x2000, + 0x2400, + 0x2800, + 0x2c00, + 0x3000, + 0x3400, + 0x3800, + 0x3c00, + 0x4000, + 0x4400, + 0x4800, + 0x4c00, + 0x5000, + 0x5400, + 0x5800, + 0x5c00, + 0x6000, + 0x6400, + 0x6800, + 0x6c00, + 0x7000, + 0x7400, + 0x7800, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x7c00, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8000, + 0x8001, + 0x8002, + 0x8004, + 0x8008, + 0x8010, + 0x8020, + 0x8040, + 0x8080, + 0x8100, + 0x8200, + 0x8400, + 0x8800, + 0x8c00, + 0x9000, + 0x9400, + 0x9800, + 0x9c00, + 0xa000, + 0xa400, + 0xa800, + 0xac00, + 0xb000, + 0xb400, + 0xb800, + 0xbc00, + 0xc000, + 0xc400, + 0xc800, + 0xcc00, + 0xd000, + 0xd400, + 0xd800, + 0xdc00, + 0xe000, + 0xe400, + 0xe800, + 0xec00, + 0xf000, + 0xf400, + 0xf800, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, + 0xfc00, +}; + +const uint8_t util_float_to_half_shift_table[512] = { + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x17, + 0x16, + 0x15, + 0x14, + 0x13, + 0x12, + 0x11, + 0x10, + 0xf, + 0xe, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0xd, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x17, + 0x16, + 0x15, + 0x14, + 0x13, + 0x12, + 0x11, + 0x10, + 0xf, + 0xe, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0xd, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0x18, + 0xd, +}; diff --git a/lib/libGL/gallium/libgallium/generated/u_indices_gen.c b/lib/libGL/gallium/libgallium/generated/u_indices_gen.c new file mode 100644 index 000000000..3c981e5d7 --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/u_indices_gen.c @@ -0,0 +1,5129 @@ +/* File automatically generated by indices.py */ + +/* + * 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 + * on 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 THEIR 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 + * Functions to translate and generate index lists + */ + +#include "indices/u_indices.h" +#include "indices/u_indices_priv.h" +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "pipe/p_defines.h" +#include "util/u_memory.h" + + +static unsigned out_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return OUT_UINT; + case 2: return OUT_USHORT; + default: assert(0); return OUT_USHORT; + } +} + +static unsigned in_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return IN_UINT; + case 2: return IN_USHORT; + case 1: return IN_UBYTE; + default: assert(0); return IN_UBYTE; + } +} + + +static u_translate_func translate[IN_COUNT][OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; +static u_generate_func generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT]; + + + +static void generate_points_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)(i); + } +} +static void generate_lines_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)(i); + (out+i)[1] = (ushort)(i+1); + } +} +static void generate_linestrip_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1); + } +} +static void generate_lineloop_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1); + } + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(0); +} +static void generate_tris_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)(i); + (out+i)[1] = (ushort)(i+1); + (out+i)[2] = (ushort)(i+2); + } +} +static void generate_tristrip_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1+(i&1)); + (out+j)[2] = (ushort)(i+2-(i&1)); + } +} +static void generate_trifan_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j)[2] = (ushort)(i+2); + } +} +static void generate_quads_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)(i+0); + (out+j+0)[1] = (ushort)(i+1); + (out+j+0)[2] = (ushort)(i+3); + (out+j+3)[0] = (ushort)(i+1); + (out+j+3)[1] = (ushort)(i+2); + (out+j+3)[2] = (ushort)(i+3); + } +} +static void generate_quadstrip_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)(i+2); + (out+j+0)[1] = (ushort)(i+0); + (out+j+0)[2] = (ushort)(i+3); + (out+j+3)[0] = (ushort)(i+0); + (out+j+3)[1] = (ushort)(i+1); + (out+j+3)[2] = (ushort)(i+3); + } +} +static void generate_polygon_ushort_first2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j)[2] = (ushort)(i+2); + } +} +static void generate_points_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)(i); + } +} +static void generate_lines_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)(i+1); + (out+i)[1] = (ushort)(i); + } +} +static void generate_linestrip_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i); + } +} +static void generate_lineloop_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i); + } + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i); +} +static void generate_tris_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)(i+1); + (out+i)[1] = (ushort)(i+2); + (out+i)[2] = (ushort)(i); + } +} +static void generate_tristrip_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+1+(i&1)); + (out+j)[1] = (ushort)(i+2-(i&1)); + (out+j)[2] = (ushort)(i); + } +} +static void generate_trifan_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i+2); + (out+j)[2] = (ushort)(0); + } +} +static void generate_quads_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)(i+1); + (out+j+0)[1] = (ushort)(i+3); + (out+j+0)[2] = (ushort)(i+0); + (out+j+3)[0] = (ushort)(i+2); + (out+j+3)[1] = (ushort)(i+3); + (out+j+3)[2] = (ushort)(i+1); + } +} +static void generate_quadstrip_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)(i+0); + (out+j+0)[1] = (ushort)(i+3); + (out+j+0)[2] = (ushort)(i+2); + (out+j+3)[0] = (ushort)(i+1); + (out+j+3)[1] = (ushort)(i+3); + (out+j+3)[2] = (ushort)(i+0); + } +} +static void generate_polygon_ushort_first2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i+2); + (out+j)[2] = (ushort)(0); + } +} +static void generate_points_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)(i); + } +} +static void generate_lines_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)(i+1); + (out+i)[1] = (ushort)(i); + } +} +static void generate_linestrip_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i); + } +} +static void generate_lineloop_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i); + } + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i); +} +static void generate_tris_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)(i+2); + (out+i)[1] = (ushort)(i); + (out+i)[2] = (ushort)(i+1); + } +} +static void generate_tristrip_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+2); + (out+j)[1] = (ushort)(i+(i&1)); + (out+j)[2] = (ushort)(i+1-(i&1)); + } +} +static void generate_trifan_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+2); + (out+j)[1] = (ushort)(0); + (out+j)[2] = (ushort)(i+1); + } +} +static void generate_quads_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)(i+3); + (out+j+0)[1] = (ushort)(i+0); + (out+j+0)[2] = (ushort)(i+1); + (out+j+3)[0] = (ushort)(i+3); + (out+j+3)[1] = (ushort)(i+1); + (out+j+3)[2] = (ushort)(i+2); + } +} +static void generate_quadstrip_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)(i+3); + (out+j+0)[1] = (ushort)(i+2); + (out+j+0)[2] = (ushort)(i+0); + (out+j+3)[0] = (ushort)(i+3); + (out+j+3)[1] = (ushort)(i+0); + (out+j+3)[2] = (ushort)(i+1); + } +} +static void generate_polygon_ushort_last2first( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j)[2] = (ushort)(i+2); + } +} +static void generate_points_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)(i); + } +} +static void generate_lines_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)(i); + (out+i)[1] = (ushort)(i+1); + } +} +static void generate_linestrip_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1); + } +} +static void generate_lineloop_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1); + } + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(0); +} +static void generate_tris_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)(i); + (out+i)[1] = (ushort)(i+1); + (out+i)[2] = (ushort)(i+2); + } +} +static void generate_tristrip_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+(i&1)); + (out+j)[1] = (ushort)(i+1-(i&1)); + (out+j)[2] = (ushort)(i+2); + } +} +static void generate_trifan_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j)[2] = (ushort)(i+2); + } +} +static void generate_quads_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)(i+0); + (out+j+0)[1] = (ushort)(i+1); + (out+j+0)[2] = (ushort)(i+3); + (out+j+3)[0] = (ushort)(i+1); + (out+j+3)[1] = (ushort)(i+2); + (out+j+3)[2] = (ushort)(i+3); + } +} +static void generate_quadstrip_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)(i+2); + (out+j+0)[1] = (ushort)(i+0); + (out+j+0)[2] = (ushort)(i+3); + (out+j+3)[0] = (ushort)(i+0); + (out+j+3)[1] = (ushort)(i+1); + (out+j+3)[2] = (ushort)(i+3); + } +} +static void generate_polygon_ushort_last2last( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)(i+1); + (out+j)[1] = (ushort)(i+2); + (out+j)[2] = (ushort)(0); + } +} +static void generate_points_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)(i); + } +} +static void generate_lines_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)(i); + (out+i)[1] = (uint)(i+1); + } +} +static void generate_linestrip_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1); + } +} +static void generate_lineloop_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1); + } + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(0); +} +static void generate_tris_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)(i); + (out+i)[1] = (uint)(i+1); + (out+i)[2] = (uint)(i+2); + } +} +static void generate_tristrip_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1+(i&1)); + (out+j)[2] = (uint)(i+2-(i&1)); + } +} +static void generate_trifan_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j)[2] = (uint)(i+2); + } +} +static void generate_quads_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)(i+0); + (out+j+0)[1] = (uint)(i+1); + (out+j+0)[2] = (uint)(i+3); + (out+j+3)[0] = (uint)(i+1); + (out+j+3)[1] = (uint)(i+2); + (out+j+3)[2] = (uint)(i+3); + } +} +static void generate_quadstrip_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)(i+2); + (out+j+0)[1] = (uint)(i+0); + (out+j+0)[2] = (uint)(i+3); + (out+j+3)[0] = (uint)(i+0); + (out+j+3)[1] = (uint)(i+1); + (out+j+3)[2] = (uint)(i+3); + } +} +static void generate_polygon_uint_first2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j)[2] = (uint)(i+2); + } +} +static void generate_points_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)(i); + } +} +static void generate_lines_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)(i+1); + (out+i)[1] = (uint)(i); + } +} +static void generate_linestrip_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i); + } +} +static void generate_lineloop_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i); + } + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i); +} +static void generate_tris_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)(i+1); + (out+i)[1] = (uint)(i+2); + (out+i)[2] = (uint)(i); + } +} +static void generate_tristrip_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+1+(i&1)); + (out+j)[1] = (uint)(i+2-(i&1)); + (out+j)[2] = (uint)(i); + } +} +static void generate_trifan_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i+2); + (out+j)[2] = (uint)(0); + } +} +static void generate_quads_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)(i+1); + (out+j+0)[1] = (uint)(i+3); + (out+j+0)[2] = (uint)(i+0); + (out+j+3)[0] = (uint)(i+2); + (out+j+3)[1] = (uint)(i+3); + (out+j+3)[2] = (uint)(i+1); + } +} +static void generate_quadstrip_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)(i+0); + (out+j+0)[1] = (uint)(i+3); + (out+j+0)[2] = (uint)(i+2); + (out+j+3)[0] = (uint)(i+1); + (out+j+3)[1] = (uint)(i+3); + (out+j+3)[2] = (uint)(i+0); + } +} +static void generate_polygon_uint_first2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i+2); + (out+j)[2] = (uint)(0); + } +} +static void generate_points_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)(i); + } +} +static void generate_lines_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)(i+1); + (out+i)[1] = (uint)(i); + } +} +static void generate_linestrip_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i); + } +} +static void generate_lineloop_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i); + } + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i); +} +static void generate_tris_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)(i+2); + (out+i)[1] = (uint)(i); + (out+i)[2] = (uint)(i+1); + } +} +static void generate_tristrip_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+2); + (out+j)[1] = (uint)(i+(i&1)); + (out+j)[2] = (uint)(i+1-(i&1)); + } +} +static void generate_trifan_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+2); + (out+j)[1] = (uint)(0); + (out+j)[2] = (uint)(i+1); + } +} +static void generate_quads_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)(i+3); + (out+j+0)[1] = (uint)(i+0); + (out+j+0)[2] = (uint)(i+1); + (out+j+3)[0] = (uint)(i+3); + (out+j+3)[1] = (uint)(i+1); + (out+j+3)[2] = (uint)(i+2); + } +} +static void generate_quadstrip_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)(i+3); + (out+j+0)[1] = (uint)(i+2); + (out+j+0)[2] = (uint)(i+0); + (out+j+3)[0] = (uint)(i+3); + (out+j+3)[1] = (uint)(i+0); + (out+j+3)[2] = (uint)(i+1); + } +} +static void generate_polygon_uint_last2first( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j)[2] = (uint)(i+2); + } +} +static void generate_points_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)(i); + } +} +static void generate_lines_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)(i); + (out+i)[1] = (uint)(i+1); + } +} +static void generate_linestrip_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1); + } +} +static void generate_lineloop_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1); + } + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(0); +} +static void generate_tris_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)(i); + (out+i)[1] = (uint)(i+1); + (out+i)[2] = (uint)(i+2); + } +} +static void generate_tristrip_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+(i&1)); + (out+j)[1] = (uint)(i+1-(i&1)); + (out+j)[2] = (uint)(i+2); + } +} +static void generate_trifan_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j)[2] = (uint)(i+2); + } +} +static void generate_quads_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)(i+0); + (out+j+0)[1] = (uint)(i+1); + (out+j+0)[2] = (uint)(i+3); + (out+j+3)[0] = (uint)(i+1); + (out+j+3)[1] = (uint)(i+2); + (out+j+3)[2] = (uint)(i+3); + } +} +static void generate_quadstrip_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)(i+2); + (out+j+0)[1] = (uint)(i+0); + (out+j+0)[2] = (uint)(i+3); + (out+j+3)[0] = (uint)(i+0); + (out+j+3)[1] = (uint)(i+1); + (out+j+3)[2] = (uint)(i+3); + } +} +static void generate_polygon_uint_last2last( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)(i+1); + (out+j)[1] = (uint)(i+2); + (out+j)[2] = (uint)(0); + } +} +static void translate_points_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1+(i&1)]; + (out+j)[2] = (ushort)in[i+2-(i&1)]; + } +} +static void translate_trifan_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_ubyte2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i+2]; + (out+i)[2] = (ushort)in[i]; + } +} +static void translate_tristrip_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1+(i&1)]; + (out+j)[1] = (ushort)in[i+2-(i&1)]; + (out+j)[2] = (ushort)in[i]; + } +} +static void translate_trifan_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_quads_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+1]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+2]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_quadstrip_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+2]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+0]; + } +} +static void translate_polygon_ubyte2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+2]; + (out+i)[1] = (ushort)in[i]; + (out+i)[2] = (ushort)in[i+1]; + } +} +static void translate_tristrip_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+(i&1)]; + (out+j)[2] = (ushort)in[i+1-(i&1)]; + } +} +static void translate_trifan_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[0]; + (out+j)[2] = (ushort)in[i+1]; + } +} +static void translate_quads_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+1]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+2]; + } +} +static void translate_quadstrip_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+2]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+0]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_polygon_ubyte2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+(i&1)]; + (out+j)[1] = (ushort)in[i+1-(i&1)]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_trifan_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_ubyte2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1+(i&1)]; + (out+j)[2] = (uint)in[i+2-(i&1)]; + } +} +static void translate_trifan_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_ubyte2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i+2]; + (out+i)[2] = (uint)in[i]; + } +} +static void translate_tristrip_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1+(i&1)]; + (out+j)[1] = (uint)in[i+2-(i&1)]; + (out+j)[2] = (uint)in[i]; + } +} +static void translate_trifan_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_quads_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+1]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+2]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_quadstrip_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+2]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+0]; + } +} +static void translate_polygon_ubyte2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_points_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+2]; + (out+i)[1] = (uint)in[i]; + (out+i)[2] = (uint)in[i+1]; + } +} +static void translate_tristrip_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+(i&1)]; + (out+j)[2] = (uint)in[i+1-(i&1)]; + } +} +static void translate_trifan_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[0]; + (out+j)[2] = (uint)in[i+1]; + } +} +static void translate_quads_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+1]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+2]; + } +} +static void translate_quadstrip_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+2]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+0]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_polygon_ubyte2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+(i&1)]; + (out+j)[1] = (uint)in[i+1-(i&1)]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_trifan_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_ubyte2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_points_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1+(i&1)]; + (out+j)[2] = (ushort)in[i+2-(i&1)]; + } +} +static void translate_trifan_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_ushort2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i+2]; + (out+i)[2] = (ushort)in[i]; + } +} +static void translate_tristrip_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1+(i&1)]; + (out+j)[1] = (ushort)in[i+2-(i&1)]; + (out+j)[2] = (ushort)in[i]; + } +} +static void translate_trifan_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_quads_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+1]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+2]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_quadstrip_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+2]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+0]; + } +} +static void translate_polygon_ushort2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+2]; + (out+i)[1] = (ushort)in[i]; + (out+i)[2] = (ushort)in[i+1]; + } +} +static void translate_tristrip_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+(i&1)]; + (out+j)[2] = (ushort)in[i+1-(i&1)]; + } +} +static void translate_trifan_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[0]; + (out+j)[2] = (ushort)in[i+1]; + } +} +static void translate_quads_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+1]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+2]; + } +} +static void translate_quadstrip_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+2]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+0]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_polygon_ushort2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+(i&1)]; + (out+j)[1] = (ushort)in[i+1-(i&1)]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_trifan_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_ushort2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1+(i&1)]; + (out+j)[2] = (uint)in[i+2-(i&1)]; + } +} +static void translate_trifan_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_ushort2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i+2]; + (out+i)[2] = (uint)in[i]; + } +} +static void translate_tristrip_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1+(i&1)]; + (out+j)[1] = (uint)in[i+2-(i&1)]; + (out+j)[2] = (uint)in[i]; + } +} +static void translate_trifan_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_quads_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+1]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+2]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_quadstrip_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+2]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+0]; + } +} +static void translate_polygon_ushort2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_points_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+2]; + (out+i)[1] = (uint)in[i]; + (out+i)[2] = (uint)in[i+1]; + } +} +static void translate_tristrip_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+(i&1)]; + (out+j)[2] = (uint)in[i+1-(i&1)]; + } +} +static void translate_trifan_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[0]; + (out+j)[2] = (uint)in[i+1]; + } +} +static void translate_quads_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+1]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+2]; + } +} +static void translate_quadstrip_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+2]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+0]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_polygon_ushort2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+(i&1)]; + (out+j)[1] = (uint)in[i+1-(i&1)]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_trifan_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_ushort2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_points_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1+(i&1)]; + (out+j)[2] = (ushort)in[i+2-(i&1)]; + } +} +static void translate_trifan_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_uint2ushort_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i+2]; + (out+i)[2] = (ushort)in[i]; + } +} +static void translate_tristrip_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1+(i&1)]; + (out+j)[1] = (ushort)in[i+2-(i&1)]; + (out+j)[2] = (ushort)in[i]; + } +} +static void translate_trifan_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_quads_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+1]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+2]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_quadstrip_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+3]; + (out+j+0)[2] = (ushort)in[i+2]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+3]; + (out+j+3)[2] = (ushort)in[i+0]; + } +} +static void translate_polygon_uint2ushort_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i+1]; + (out+i)[1] = (ushort)in[i]; + } +} +static void translate_linestrip_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } +} +static void translate_lineloop_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i]; + } + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i]; +} +static void translate_tris_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i+2]; + (out+i)[1] = (ushort)in[i]; + (out+i)[2] = (ushort)in[i+1]; + } +} +static void translate_tristrip_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+(i&1)]; + (out+j)[2] = (ushort)in[i+1-(i&1)]; + } +} +static void translate_trifan_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[0]; + (out+j)[2] = (ushort)in[i+1]; + } +} +static void translate_quads_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+1]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+2]; + } +} +static void translate_quadstrip_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+3]; + (out+j+0)[1] = (ushort)in[i+2]; + (out+j+0)[2] = (ushort)in[i+0]; + (out+j+3)[0] = (ushort)in[i+3]; + (out+j+3)[1] = (ushort)in[i+0]; + (out+j+3)[2] = (ushort)in[i+1]; + } +} +static void translate_polygon_uint2ushort_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_points_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (ushort)in[i]; + } +} +static void translate_lines_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + } +} +static void translate_linestrip_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } +} +static void translate_lineloop_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + } + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[0]; +} +static void translate_tris_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (ushort)in[i]; + (out+i)[1] = (ushort)in[i+1]; + (out+i)[2] = (ushort)in[i+2]; + } +} +static void translate_tristrip_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+(i&1)]; + (out+j)[1] = (ushort)in[i+1-(i&1)]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_trifan_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j)[2] = (ushort)in[i+2]; + } +} +static void translate_quads_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (ushort)in[i+0]; + (out+j+0)[1] = (ushort)in[i+1]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+1]; + (out+j+3)[1] = (ushort)in[i+2]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_quadstrip_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (ushort)in[i+2]; + (out+j+0)[1] = (ushort)in[i+0]; + (out+j+0)[2] = (ushort)in[i+3]; + (out+j+3)[0] = (ushort)in[i+0]; + (out+j+3)[1] = (ushort)in[i+1]; + (out+j+3)[2] = (ushort)in[i+3]; + } +} +static void translate_polygon_uint2ushort_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (ushort)in[i+1]; + (out+j)[1] = (ushort)in[i+2]; + (out+j)[2] = (ushort)in[0]; + } +} +static void translate_points_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1+(i&1)]; + (out+j)[2] = (uint)in[i+2-(i&1)]; + } +} +static void translate_trifan_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_uint2uint_first2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i+2]; + (out+i)[2] = (uint)in[i]; + } +} +static void translate_tristrip_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1+(i&1)]; + (out+j)[1] = (uint)in[i+2-(i&1)]; + (out+j)[2] = (uint)in[i]; + } +} +static void translate_trifan_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_quads_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+1]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+2]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_quadstrip_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+3]; + (out+j+0)[2] = (uint)in[i+2]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+3]; + (out+j+3)[2] = (uint)in[i+0]; + } +} +static void translate_polygon_uint2uint_first2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +static void translate_points_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i+1]; + (out+i)[1] = (uint)in[i]; + } +} +static void translate_linestrip_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } +} +static void translate_lineloop_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i]; + } + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i]; +} +static void translate_tris_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i+2]; + (out+i)[1] = (uint)in[i]; + (out+i)[2] = (uint)in[i+1]; + } +} +static void translate_tristrip_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+(i&1)]; + (out+j)[2] = (uint)in[i+1-(i&1)]; + } +} +static void translate_trifan_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[0]; + (out+j)[2] = (uint)in[i+1]; + } +} +static void translate_quads_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+1]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+2]; + } +} +static void translate_quadstrip_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+3]; + (out+j+0)[1] = (uint)in[i+2]; + (out+j+0)[2] = (uint)in[i+0]; + (out+j+3)[0] = (uint)in[i+3]; + (out+j+3)[1] = (uint)in[i+0]; + (out+j+3)[2] = (uint)in[i+1]; + } +} +static void translate_polygon_uint2uint_last2first( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_points_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i++) { + (out+i)[0] = (uint)in[i]; + } +} +static void translate_lines_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=2) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + } +} +static void translate_linestrip_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } +} +static void translate_lineloop_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr - 2; j+=2, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + } + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[0]; +} +static void translate_tris_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (i = 0; i < nr; i+=3) { + (out+i)[0] = (uint)in[i]; + (out+i)[1] = (uint)in[i+1]; + (out+i)[2] = (uint)in[i+2]; + } +} +static void translate_tristrip_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+(i&1)]; + (out+j)[1] = (uint)in[i+1-(i&1)]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_trifan_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j)[2] = (uint)in[i+2]; + } +} +static void translate_quads_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=4) { + (out+j+0)[0] = (uint)in[i+0]; + (out+j+0)[1] = (uint)in[i+1]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+1]; + (out+j+3)[1] = (uint)in[i+2]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_quadstrip_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=2) { + (out+j+0)[0] = (uint)in[i+2]; + (out+j+0)[1] = (uint)in[i+0]; + (out+j+0)[2] = (uint)in[i+3]; + (out+j+3)[0] = (uint)in[i+0]; + (out+j+3)[1] = (uint)in[i+1]; + (out+j+3)[2] = (uint)in[i+3]; + } +} +static void translate_polygon_uint2uint_last2last( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=3, i++) { + (out+j)[0] = (uint)in[i+1]; + (out+j)[1] = (uint)in[i+2]; + (out+j)[2] = (uint)in[0]; + } +} +void u_index_init( void ) +{ + static int firsttime = 1; + if (!firsttime) return; + firsttime = 0; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2first; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_first2last; +generate[OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_first2last; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2first; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort_last2last; +generate[OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_ushort_last2last; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2first; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_first2last; +generate[OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_first2last; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = generate_points_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = generate_lines_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = generate_quads_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2first; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = generate_points_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = generate_lines_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = generate_linestrip_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = generate_lineloop_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = generate_tris_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = generate_quads_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint_last2last; +generate[OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = generate_polygon_uint_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2first; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_first2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2first; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort_last2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2first; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_first2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2first; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint_last2last; +translate[IN_UBYTE][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint_last2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2first; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_first2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2first; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort_last2last; +translate[IN_USHORT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort_last2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2first; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_first2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2first; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint_last2last; +translate[IN_USHORT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint_last2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2first; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_first2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2first; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort_last2last; +translate[IN_UINT][OUT_USHORT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort_last2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2first; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_FIRST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_first2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_FIRST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2first; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POINTS] = translate_points_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINES] = translate_lines_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_STRIP] = translate_linestrip_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_LINE_LOOP] = translate_lineloop_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUADS] = translate_quads_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint_last2last; +translate[IN_UINT][OUT_UINT][PV_LAST][PV_LAST][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint_last2last; +} +#include "indices/u_indices.c" diff --git a/lib/libGL/gallium/libgallium/generated/u_unfilled_gen.c b/lib/libGL/gallium/libgallium/generated/u_unfilled_gen.c new file mode 100644 index 000000000..93897c98d --- /dev/null +++ b/lib/libGL/gallium/libgallium/generated/u_unfilled_gen.c @@ -0,0 +1,992 @@ +/* File automatically generated by u_unfilled_gen.py */ + +/* + * 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 + * on 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 THEIR 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 + * Functions to translate and generate index lists + */ + +#include "indices/u_indices.h" +#include "indices/u_indices_priv.h" +#include "pipe/p_compiler.h" +#include "util/u_debug.h" +#include "pipe/p_defines.h" +#include "util/u_memory.h" + + +static unsigned out_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return OUT_UINT; + case 2: return OUT_USHORT; + default: assert(0); return OUT_USHORT; + } +} + +static unsigned in_size_idx( unsigned index_size ) +{ + switch (index_size) { + case 4: return IN_UINT; + case 2: return IN_USHORT; + case 1: return IN_UBYTE; + default: assert(0); return IN_UBYTE; + } +} + + +static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT]; +static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT]; + + +static void generate_tris_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1); + (out+j+2)[0] = (ushort)(i+1); + (out+j+2)[1] = (ushort)(i+2); + (out+j+4)[0] = (ushort)(i+2); + (out+j+4)[1] = (ushort)(i); + } +} +static void generate_tristrip_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)(i); + (out+j)[1] = (ushort)(i+1/*+(i&1)*/); + (out+j+2)[0] = (ushort)(i+1/*+(i&1)*/); + (out+j+2)[1] = (ushort)(i+2/*-(i&1)*/); + (out+j+4)[0] = (ushort)(i+2/*-(i&1)*/); + (out+j+4)[1] = (ushort)(i); + } +} +static void generate_trifan_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j+2)[0] = (ushort)(i+1); + (out+j+2)[1] = (ushort)(i+2); + (out+j+4)[0] = (ushort)(i+2); + (out+j+4)[1] = (ushort)(0); + } +} +static void generate_quads_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (ushort)(i+0); + (out+j)[1] = (ushort)(i+1); + (out+j+2)[0] = (ushort)(i+1); + (out+j+2)[1] = (ushort)(i+2); + (out+j+4)[0] = (ushort)(i+2); + (out+j+4)[1] = (ushort)(i+3); + (out+j+6)[0] = (ushort)(i+3); + (out+j+6)[1] = (ushort)(i+0); + } +} +static void generate_quadstrip_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (ushort)(i+2); + (out+j)[1] = (ushort)(i+0); + (out+j+2)[0] = (ushort)(i+0); + (out+j+2)[1] = (ushort)(i+1); + (out+j+4)[0] = (ushort)(i+1); + (out+j+4)[1] = (ushort)(i+3); + (out+j+6)[0] = (ushort)(i+3); + (out+j+6)[1] = (ushort)(i+2); + } +} +static void generate_polygon_ushort( + unsigned nr, + void *_out ) +{ + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)(0); + (out+j)[1] = (ushort)(i+1); + (out+j+2)[0] = (ushort)(i+1); + (out+j+2)[1] = (ushort)(i+2); + (out+j+4)[0] = (ushort)(i+2); + (out+j+4)[1] = (ushort)(0); + } +} +static void generate_tris_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1); + (out+j+2)[0] = (uint)(i+1); + (out+j+2)[1] = (uint)(i+2); + (out+j+4)[0] = (uint)(i+2); + (out+j+4)[1] = (uint)(i); + } +} +static void generate_tristrip_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)(i); + (out+j)[1] = (uint)(i+1/*+(i&1)*/); + (out+j+2)[0] = (uint)(i+1/*+(i&1)*/); + (out+j+2)[1] = (uint)(i+2/*-(i&1)*/); + (out+j+4)[0] = (uint)(i+2/*-(i&1)*/); + (out+j+4)[1] = (uint)(i); + } +} +static void generate_trifan_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j+2)[0] = (uint)(i+1); + (out+j+2)[1] = (uint)(i+2); + (out+j+4)[0] = (uint)(i+2); + (out+j+4)[1] = (uint)(0); + } +} +static void generate_quads_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (uint)(i+0); + (out+j)[1] = (uint)(i+1); + (out+j+2)[0] = (uint)(i+1); + (out+j+2)[1] = (uint)(i+2); + (out+j+4)[0] = (uint)(i+2); + (out+j+4)[1] = (uint)(i+3); + (out+j+6)[0] = (uint)(i+3); + (out+j+6)[1] = (uint)(i+0); + } +} +static void generate_quadstrip_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (uint)(i+2); + (out+j)[1] = (uint)(i+0); + (out+j+2)[0] = (uint)(i+0); + (out+j+2)[1] = (uint)(i+1); + (out+j+4)[0] = (uint)(i+1); + (out+j+4)[1] = (uint)(i+3); + (out+j+6)[0] = (uint)(i+3); + (out+j+6)[1] = (uint)(i+2); + } +} +static void generate_polygon_uint( + unsigned nr, + void *_out ) +{ + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)(0); + (out+j)[1] = (uint)(i+1); + (out+j+2)[0] = (uint)(i+1); + (out+j+2)[1] = (uint)(i+2); + (out+j+4)[0] = (uint)(i+2); + (out+j+4)[1] = (uint)(0); + } +} +static void translate_tris_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_tristrip_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_trifan_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_quads_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (ushort)in[i+0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+0]; + } +} +static void translate_quadstrip_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+0]; + (out+j+2)[0] = (ushort)in[i+0]; + (out+j+2)[1] = (ushort)in[i+1]; + (out+j+4)[0] = (ushort)in[i+1]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+2]; + } +} +static void translate_polygon_ubyte2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_tris_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_tristrip_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_trifan_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +static void translate_quads_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (uint)in[i+0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+0]; + } +} +static void translate_quadstrip_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+0]; + (out+j+2)[0] = (uint)in[i+0]; + (out+j+2)[1] = (uint)in[i+1]; + (out+j+4)[0] = (uint)in[i+1]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+2]; + } +} +static void translate_polygon_ubyte2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ubyte*in = (const ubyte*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +static void translate_tris_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_tristrip_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_trifan_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_quads_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (ushort)in[i+0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+0]; + } +} +static void translate_quadstrip_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+0]; + (out+j+2)[0] = (ushort)in[i+0]; + (out+j+2)[1] = (ushort)in[i+1]; + (out+j+4)[0] = (ushort)in[i+1]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+2]; + } +} +static void translate_polygon_ushort2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_tris_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_tristrip_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_trifan_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +static void translate_quads_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (uint)in[i+0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+0]; + } +} +static void translate_quadstrip_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+0]; + (out+j+2)[0] = (uint)in[i+0]; + (out+j+2)[1] = (uint)in[i+1]; + (out+j+4)[0] = (uint)in[i+1]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+2]; + } +} +static void translate_polygon_ushort2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const ushort*in = (const ushort*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +static void translate_tris_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_tristrip_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[i]; + (out+j)[1] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (ushort)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (ushort)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (ushort)in[i]; + } +} +static void translate_trifan_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_quads_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (ushort)in[i+0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+0]; + } +} +static void translate_quadstrip_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (ushort)in[i+2]; + (out+j)[1] = (ushort)in[i+0]; + (out+j+2)[0] = (ushort)in[i+0]; + (out+j+2)[1] = (ushort)in[i+1]; + (out+j+4)[0] = (ushort)in[i+1]; + (out+j+4)[1] = (ushort)in[i+3]; + (out+j+6)[0] = (ushort)in[i+3]; + (out+j+6)[1] = (ushort)in[i+2]; + } +} +static void translate_polygon_uint2ushort( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + ushort *out = (ushort*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (ushort)in[0]; + (out+j)[1] = (ushort)in[i+1]; + (out+j+2)[0] = (ushort)in[i+1]; + (out+j+2)[1] = (ushort)in[i+2]; + (out+j+4)[0] = (ushort)in[i+2]; + (out+j+4)[1] = (ushort)in[0]; + } +} +static void translate_tris_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i+=3) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_tristrip_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[i]; + (out+j)[1] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[0] = (uint)in[i+1/*+(i&1)*/]; + (out+j+2)[1] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[0] = (uint)in[i+2/*-(i&1)*/]; + (out+j+4)[1] = (uint)in[i]; + } +} +static void translate_trifan_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +static void translate_quads_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=4) { + (out+j)[0] = (uint)in[i+0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+0]; + } +} +static void translate_quadstrip_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=8, i+=2) { + (out+j)[0] = (uint)in[i+2]; + (out+j)[1] = (uint)in[i+0]; + (out+j+2)[0] = (uint)in[i+0]; + (out+j+2)[1] = (uint)in[i+1]; + (out+j+4)[0] = (uint)in[i+1]; + (out+j+4)[1] = (uint)in[i+3]; + (out+j+6)[0] = (uint)in[i+3]; + (out+j+6)[1] = (uint)in[i+2]; + } +} +static void translate_polygon_uint2uint( + const void * _in, + unsigned nr, + void *_out ) +{ + const uint*in = (const uint*)_in; + uint *out = (uint*)_out; + unsigned i, j; + (void)j; + for (j = i = 0; j < nr; j+=6, i++) { + (out+j)[0] = (uint)in[0]; + (out+j)[1] = (uint)in[i+1]; + (out+j+2)[0] = (uint)in[i+1]; + (out+j+2)[1] = (uint)in[i+2]; + (out+j+4)[0] = (uint)in[i+2]; + (out+j+4)[1] = (uint)in[0]; + } +} +void u_unfilled_init( void ) +{ + static int firsttime = 1; + if (!firsttime) return; + firsttime = 0; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLES] = generate_tris_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_QUADS] = generate_quads_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_ushort; +generate_line[OUT_USHORT][PIPE_PRIM_POLYGON] = generate_polygon_ushort; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLES] = generate_tris_uint; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = generate_trifan_uint; +generate_line[OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = generate_tristrip_uint; +generate_line[OUT_UINT][PIPE_PRIM_QUADS] = generate_quads_uint; +generate_line[OUT_UINT][PIPE_PRIM_QUAD_STRIP] = generate_quadstrip_uint; +generate_line[OUT_UINT][PIPE_PRIM_POLYGON] = generate_polygon_uint; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2ushort; +translate_line[IN_UBYTE][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2ushort; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ubyte2uint; +translate_line[IN_UBYTE][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ubyte2uint; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2ushort; +translate_line[IN_USHORT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2ushort; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_ushort2uint; +translate_line[IN_USHORT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_ushort2uint; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUADS] = translate_quads_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2ushort; +translate_line[IN_UINT][OUT_USHORT][PIPE_PRIM_POLYGON] = translate_polygon_uint2ushort; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLES] = translate_tris_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_FAN] = translate_trifan_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_TRIANGLE_STRIP] = translate_tristrip_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUADS] = translate_quads_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_QUAD_STRIP] = translate_quadstrip_uint2uint; +translate_line[IN_UINT][OUT_UINT][PIPE_PRIM_POLYGON] = translate_polygon_uint2uint; +} +#include "indices/u_unfilled_indices.c" diff --git a/lib/libGL/gallium/libmesagallium/Makefile b/lib/libGL/gallium/libmesagallium/Makefile new file mode 100644 index 000000000..ce9db71d6 --- /dev/null +++ b/lib/libGL/gallium/libmesagallium/Makefile @@ -0,0 +1,310 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/13 12:43:34 mpi Exp $ + +LIB= mesagallium + +MESA= ${.CURDIR}/../../../../dist/Mesa/src/mesa +MAPI= ${.CURDIR}/../../../../dist/Mesa/src/mapi +GLSL= ${.CURDIR}/../../../../dist/Mesa/src/glsl +GALLIUM= ${.CURDIR}/../../../../dist/Mesa/src/gallium + +MESA_INCLUDE= ${.CURDIR}/../../../../dist/Mesa/include + +CPPFLAGS+= \ + -I. \ + -I${MAPI} \ + -I${MESA_INCLUDE} \ + -I${MESA_INCLUDE}/GL/internal \ + -I${MESA} \ + -I${MESA}/main \ + -I${MESA}/math \ + -I${MESA}/drivers/dri/common \ + -I${GLSL} \ + -I${GALLIUM}/auxiliary \ + -I${GALLIUM}/include \ + -I${GALLIUM}/state_trackers/dri/common \ + -I${X11BASE}/include \ + -DPTHREADS \ + -DHAVE_ALIAS \ + -D_REENTRANT \ + -DIN_DRI_DRIVER \ + -DHAVE_POSIX_MEMALIGN \ + -D__NOT_HAVE_DRM_H + +.if ${MACHINE_ARCH} == "i386" +CPPFLAGS += \ + -I${MESA}/x86 \ + -DUSE_X86_ASM \ + -DUSE_MMX_ASM \ + -DUSE_3DNOW_ASM \ + -DUSE_SSE_ASM +.elif ${MACHINE_ARCH} == "amd64" +CPPFLAGS += \ + -I${MESA}/x86 \ + -D__GLX_ALIGN64 -DUSE_X86_64_ASM +.endif + +# this is part of MAIN_SOURCES +MAIN_ES_SOURCES = \ + api_exec_es1.c \ + api_exec_es2.c + +# main +MAIN_SOURCES = \ + api_arrayelt.c \ + api_exec.c \ + api_loopback.c \ + api_noop.c \ + api_validate.c \ + accum.c \ + arbprogram.c \ + atifragshader.c \ + attrib.c \ + arrayobj.c \ + blend.c \ + bufferobj.c \ + buffers.c \ + clear.c \ + clip.c \ + colortab.c \ + condrender.c \ + context.c \ + convolve.c \ + cpuinfo.c \ + debug.c \ + depth.c \ + depthstencil.c \ + dlist.c \ + dlopen.c \ + drawpix.c \ + drawtex.c \ + enable.c \ + enums.c \ + eval.c \ + execmem.c \ + extensions.c \ + fbobject.c \ + feedback.c \ + ffvertex_prog.c \ + fog.c \ + formats.c \ + framebuffer.c \ + get.c \ + getstring.c \ + hash.c \ + hint.c \ + histogram.c \ + image.c \ + imports.c \ + light.c \ + lines.c \ + matrix.c \ + mipmap.c \ + mm.c \ + multisample.c \ + nvprogram.c \ + pack.c \ + pixel.c \ + pixelstore.c \ + pixeltransfer.c \ + points.c \ + polygon.c \ + queryobj.c \ + querymatrix.c \ + rastpos.c \ + readpix.c \ + remap.c \ + renderbuffer.c \ + scissor.c \ + shaderapi.c \ + shaderobj.c \ + shared.c \ + state.c \ + stencil.c \ + syncobj.c \ + texcompress.c \ + texcompress_s3tc.c \ + texcompress_fxt1.c \ + texenv.c \ + texenvprogram.c \ + texfetch.c \ + texformat.c \ + texgen.c \ + texgetimage.c \ + teximage.c \ + texobj.c \ + texpal.c \ + texparam.c \ + texrender.c \ + texstate.c \ + texstore.c \ + transformfeedback.c \ + uniforms.c \ + varray.c \ + version.c \ + viewport.c \ + vtxfmt.c \ + ${MAIN_ES_SOURCES} + +# math +MATH_SOURCES= \ + m_debug_clip.c \ + m_debug_norm.c \ + m_debug_xform.c \ + m_eval.c \ + m_matrix.c \ + m_translate.c \ + m_vector.c + +VBO_SOURCES = \ + vbo_context.c \ + vbo_exec.c \ + vbo_exec_api.c \ + vbo_exec_array.c \ + vbo_exec_draw.c \ + vbo_exec_eval.c \ + vbo_rebase.c \ + vbo_split.c \ + vbo_split_copy.c \ + vbo_split_inplace.c \ + vbo_save.c \ + vbo_save_api.c \ + vbo_save_draw.c \ + vbo_save_loopback.c + +STATETRACKER_SOURCES = \ + st_atom.c \ + st_atom_blend.c \ + st_atom_clip.c \ + st_atom_constbuf.c \ + st_atom_depth.c \ + st_atom_framebuffer.c \ + st_atom_msaa.c \ + st_atom_pixeltransfer.c \ + st_atom_sampler.c \ + st_atom_scissor.c \ + st_atom_shader.c \ + st_atom_rasterizer.c \ + st_atom_stipple.c \ + st_atom_texture.c \ + st_atom_viewport.c \ + st_cb_accum.c \ + st_cb_bitmap.c \ + st_cb_blit.c \ + st_cb_bufferobjects.c \ + st_cb_clear.c \ + st_cb_condrender.c \ + st_cb_flush.c \ + st_cb_drawpixels.c \ + st_cb_drawtex.c \ + st_cb_eglimage.c \ + st_cb_fbo.c \ + st_cb_feedback.c \ + st_cb_program.c \ + st_cb_queryobj.c \ + st_cb_rasterpos.c \ + st_cb_readpixels.c \ + st_cb_strings.c \ + st_cb_texture.c \ + st_cb_viewport.c \ + st_cb_xformfb.c \ + st_context.c \ + st_debug.c \ + st_draw.c \ + st_draw_feedback.c \ + st_extensions.c \ + st_format.c \ + st_gen_mipmap.c \ + st_manager.c \ + st_mesa_to_tgsi.c \ + st_program.c \ + st_texture.c + +PROGRAM_SOURCES = \ + arbprogparse.c \ + hash_table.c \ + lex.yy.c \ + nvfragparse.c \ + nvvertparse.c \ + program.c \ + program_parse.tab.c \ + program_parse_extra.c \ + prog_cache.c \ + prog_execute.c \ + prog_instruction.c \ + prog_noise.c \ + prog_optimize.c \ + prog_parameter.c \ + prog_parameter_layout.c \ + prog_print.c \ + prog_statevars.c \ + prog_uniform.c \ + programopt.c \ + register_allocate.c \ + symbol_table.c + +SHADER_CXX_SOURCES = \ + ir_to_mesa.cpp \ + sampler.cpp + +.if ${MACHINE_ARCH} == i386 +ASM_C_SOURCES= \ + common_x86.c \ +.elif ${MACHINE_ARCH} == powerpc +ASM_C_SOURCES= \ + common_ppc.c +.endif + +# drisw +DRISW_SOURCES = \ + dri_sw_winsys.c \ + dri_context.c \ + dri_screen.c \ + dri_drawable.c \ + drisw.c + +MESAGALLIUM_SOURCES = \ + ${MAIN_SOURCES} \ + ${MATH_SOURCES} \ + ${VBO_SOURCES} \ + ${PROGRAM_SOURCES} \ + ${STATETRACKER_SOURCES} \ + ${ASM_C_SOURCES} \ + ${DRISW_SOURCES} + +MESAGALLIUM_CXX_SOURCES = \ + ${SHADER_CXX_SOURCES} + +SRCS= ${MESAGALLIUM_SOURCES} \ + ${MESAGALLIUM_CXX_SOURCES} \ + ${ASM_SOURCES} \ + _atexit.c + +all: lib${LIB}_pic.a + +obj: _xenocara_obj + +install: + @echo "Not installing lib${LIB}" + +clean: + rm -f lib${LIB}_pic.a ${OBJS} + +cleandir: clean + +.include <bsd.xorg.mk> + +.if ${MACHINE_ARCH} == i386 +.PATH: ${MESA}/x86 +.endif +.if ${MACHINE_ARCH} == powerpc +.PATH: ${MESA}/ppc +.endif +.PATH: ${MESA}/main +.PATH: ${MESA}/math +.PATH: ${MESA}/state_tracker +.PATH: ${MESA}/program +.PATH: ${MESA}/vbo +.PATH: ${GALLIUM}/winsys/sw/dri +.PATH: ${GALLIUM}/state_trackers/dri/sw +.PATH: ${GALLIUM}/state_trackers/dri/common +.PATH: ${.CURDIR}/generated diff --git a/lib/libGL/gallium/libmesagallium/_atexit.c b/lib/libGL/gallium/libmesagallium/_atexit.c new file mode 100644 index 000000000..5e2e7f03f --- /dev/null +++ b/lib/libGL/gallium/libmesagallium/_atexit.c @@ -0,0 +1,12 @@ +/** + ** Hack for OpenBSD atexit + ** Author: Matthew Dempsky <matthew@dempsky.org> + **/ +extern int __cxa_atexit(void (*)(void *), void *, void *); +extern void *__dso_handle; + +int __attribute__((visibility("hidden"))) +atexit(void (*fn)(void)) +{ + return (__cxa_atexit((void (*)(void *))fn, 0, &__dso_handle)); +} diff --git a/lib/libGL/gallium/libmesagallium/generated/Makefile b/lib/libGL/gallium/libmesagallium/generated/Makefile new file mode 100644 index 000000000..4f9ed94a3 --- /dev/null +++ b/lib/libGL/gallium/libmesagallium/generated/Makefile @@ -0,0 +1,31 @@ +# $OpenBSD: Makefile,v 1.1 2012/07/13 12:43:34 mpi Exp $ + +MESA= ${.CURDIR}/../../../../dist/Mesa/src/mesa + +PYTHON= python${PYTHON_VERSION} +PYTHON_FLAGS= -t -O -O + +GENERATED= api_exec_es1.c api_exec_es2.c + +all: ${GENERATED} + +obj: + +depend: + +install: + +clean distclean: + rm -f ${GENERATED} + +api_exec_es1.c: APIspec.xml es_generator.py APIspecutil.py APIspec.py + $(PYTHON) $(PYTHON_FLAGS) ${MESA}/main/es_generator.py -S ${MESA}/main/APIspec.xml -V GLES1.1 > $@ + +api_exec_es2.c: APIspec.xml es_generator.py APIspecutil.py APIspec.py + $(PYTHON) $(PYTHON_FLAGS) ${MESA}/main/es_generator.py -S ${MESA}/main/APIspec.xml -V GLES2.0 > $@ + +.SUFFIXES: .py .xml + +.PATH: ${MESA}/main + +.include <bsd.xorg.mk> diff --git a/lib/libGL/gallium/libmesagallium/generated/api_exec_es1.c b/lib/libGL/gallium/libmesagallium/generated/api_exec_es1.c new file mode 100644 index 000000000..54b3f0d62 --- /dev/null +++ b/lib/libGL/gallium/libmesagallium/generated/api_exec_es1.c @@ -0,0 +1,4821 @@ +/* DO NOT EDIT ************************************************* + * THIS FILE AUTOMATICALLY GENERATED BY THE es_generator.py SCRIPT + * API specification file: /share/OpenBSD/xenocara/lib/libGL/libmesa/generated/../../../../dist/Mesa/src/mesa/main/APIspec.xml + * GLES version: GLES1.1 + * date: 2011-05-15 15:41:33 + */ + + +#include "GLES/gl.h" +#include "GLES/glext.h" +#include "main/mfeatures.h" + +#if FEATURE_ES1 + + +/* These types are needed for the Mesa veneer, but are not defined in + * the standard GLES headers. + */ +typedef double GLdouble; +typedef double GLclampd; + +/* Mesa error handling requires these */ +extern void *_mesa_get_current_context(void); +extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); + +#include "main/compiler.h" +#include "main/api_exec.h" +#include "main/remap.h" + +/* cannot include main/dispatch.h here */ +#ifdef IN_DRI_DRIVER +#define _GLAPI_USE_REMAP_TABLE +#endif +/* glapi uses GLAPIENTRY while GLES headers define GL_APIENTRY */ +#ifndef GLAPIENTRY +#define GLAPIENTRY GL_APIENTRY +#endif +#include "es1api/glapi/glapitable.h" +#include "es1api/glapi/glapioffsets.h" +#include "es1api/glapi/glapidispatch.h" + +#if FEATURE_remap_table + +#if !FEATURE_GL +int driDispatchRemapTable[driDispatchRemapTable_size]; +#endif + +#define need_MESA_remap_table + +#include "es1api/main/remap_helper.h" + +void +_mesa_init_remap_table_es1(void) +{ + _mesa_do_init_remap_table(_mesa_function_pool, + driDispatchRemapTable_size, + MESA_remap_table_functions); +} + +void +_mesa_map_static_functions_es1(void) +{ +} + +#endif + +typedef void (*_glapi_proc)(void); /* generic function pointer */ + +/************************************************************* + * Generated functions begin here + */ + +extern void GL_APIENTRY _mesa_ActiveTextureARB(GLenum texture); +static void GL_APIENTRY _es_ActiveTexture(GLenum texture) +{ + switch(texture) { + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + case GL_TEXTURE8: + case GL_TEXTURE9: + case GL_TEXTURE10: + case GL_TEXTURE11: + case GL_TEXTURE12: + case GL_TEXTURE13: + case GL_TEXTURE14: + case GL_TEXTURE15: + case GL_TEXTURE16: + case GL_TEXTURE17: + case GL_TEXTURE18: + case GL_TEXTURE19: + case GL_TEXTURE20: + case GL_TEXTURE21: + case GL_TEXTURE22: + case GL_TEXTURE23: + case GL_TEXTURE24: + case GL_TEXTURE25: + case GL_TEXTURE26: + case GL_TEXTURE27: + case GL_TEXTURE28: + case GL_TEXTURE29: + case GL_TEXTURE30: + case GL_TEXTURE31: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glActiveTexture(texture=0x%x)", texture); + return; + } + + _mesa_ActiveTextureARB(texture); +} + +extern void GL_APIENTRY _mesa_AlphaFunc(GLenum func, GLclampf ref); +static void GL_APIENTRY _es_AlphaFunc(GLenum func, GLclampf ref) +{ + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glAlphaFunc(func=0x%x)", func); + return; + } + + _mesa_AlphaFunc(func, ref); +} + +extern void GL_APIENTRY _mesa_AlphaFunc(GLenum func, GLclampf ref); +static void GL_APIENTRY _es_AlphaFuncx(GLenum func, GLclampx ref) +{ + GLclampf converted_ref; + + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glAlphaFuncx(func=0x%x)", func); + return; + } + + converted_ref = (GLclampf) (ref / 65536.0f); + + _mesa_AlphaFunc(func, converted_ref); +} + +extern void GL_APIENTRY _mesa_BindBufferARB(GLenum target, GLuint buffer); +static void GL_APIENTRY _es_BindBuffer(GLenum target, GLuint buffer) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindBuffer(target=0x%x)", target); + return; + } + + _mesa_BindBufferARB(target, buffer); +} + +extern void GL_APIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); +static void GL_APIENTRY _es_BindFramebufferOES(GLenum target, GLuint framebuffer) +{ + switch(target) { + case GL_FRAMEBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindFramebufferOES(target=0x%x)", target); + return; + } + + _mesa_BindFramebufferEXT(target, framebuffer); +} + +extern void GL_APIENTRY _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); +static void GL_APIENTRY _es_BindRenderbufferOES(GLenum target, GLuint renderbuffer) +{ + switch(target) { + case GL_RENDERBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindRenderbufferOES(target=0x%x)", target); + return; + } + + _mesa_BindRenderbufferEXT(target, renderbuffer); +} + +extern void GL_APIENTRY _mesa_BindTexture(GLenum target, GLuint texture); +static void GL_APIENTRY _es_BindTexture(GLenum target, GLuint texture) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindTexture(target=0x%x)", target); + return; + } + + _mesa_BindTexture(target, texture); +} + +extern void GL_APIENTRY _mesa_BlendEquation(GLenum mode); +static void GL_APIENTRY _es_BlendEquationOES(GLenum mode) +{ + switch(mode) { + case GL_FUNC_ADD_OES: + case GL_FUNC_SUBTRACT_OES: + case GL_FUNC_REVERSE_SUBTRACT_OES: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquationOES(mode=0x%x)", mode); + return; + } + + _mesa_BlendEquation(mode); +} + +extern void GL_APIENTRY _mesa_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeAlpha); +static void GL_APIENTRY _es_BlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha) +{ + switch(modeRGB) { + case GL_FUNC_ADD_OES: + case GL_FUNC_SUBTRACT_OES: + case GL_FUNC_REVERSE_SUBTRACT_OES: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquationSeparateOES(modeRGB=0x%x)", modeRGB); + return; + } + switch(modeAlpha) { + case GL_FUNC_ADD_OES: + case GL_FUNC_SUBTRACT_OES: + case GL_FUNC_REVERSE_SUBTRACT_OES: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquationSeparateOES(modeAlpha=0x%x)", modeAlpha); + return; + } + + _mesa_BlendEquationSeparateEXT(modeRGB, modeAlpha); +} + +extern void GL_APIENTRY _mesa_BlendFunc(GLenum sfactor, GLenum dfactor); +static void GL_APIENTRY _es_BlendFunc(GLenum sfactor, GLenum dfactor) +{ + switch(sfactor) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFunc(sfactor=0x%x)", sfactor); + return; + } + switch(dfactor) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFunc(dfactor=0x%x)", dfactor); + return; + } + + _mesa_BlendFunc(sfactor, dfactor); +} + +extern void GL_APIENTRY _mesa_BlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +static void GL_APIENTRY _es_BlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + switch(srcRGB) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparateOES(srcRGB=0x%x)", srcRGB); + return; + } + switch(dstRGB) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparateOES(dstRGB=0x%x)", dstRGB); + return; + } + switch(srcAlpha) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparateOES(srcAlpha=0x%x)", srcAlpha); + return; + } + switch(dstAlpha) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparateOES(dstAlpha=0x%x)", dstAlpha); + return; + } + + _mesa_BlendFuncSeparateEXT(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +extern void GL_APIENTRY _mesa_BufferDataARB(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); +static void GL_APIENTRY _es_BufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferData(target=0x%x)", target); + return; + } + switch(usage) { + case GL_STATIC_DRAW: + case GL_DYNAMIC_DRAW: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferData(usage=0x%x)", usage); + return; + } + + _mesa_BufferDataARB(target, size, data, usage); +} + +extern void GL_APIENTRY _mesa_BufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); +static void GL_APIENTRY _es_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferSubData(target=0x%x)", target); + return; + } + + _mesa_BufferSubDataARB(target, offset, size, data); +} + +extern GLenum GL_APIENTRY _mesa_CheckFramebufferStatusEXT(GLenum target); +static GLenum GL_APIENTRY _es_CheckFramebufferStatusOES(GLenum target) +{ + switch(target) { + case GL_FRAMEBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCheckFramebufferStatusOES(target=0x%x)", target); + return (GLenum) 0; + } + + return _mesa_CheckFramebufferStatusEXT(target); +} + +extern void GL_APIENTRY _mesa_Clear(GLbitfield mask); +static void GL_APIENTRY _es_Clear(GLbitfield mask) +{ + switch(mask) { + case 0: + case (GL_COLOR_BUFFER_BIT): + case (GL_DEPTH_BUFFER_BIT): + case (GL_STENCIL_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + case (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glClear(mask=0x%x)", mask); + return; + } + + _mesa_Clear(mask); +} + +extern void GL_APIENTRY _mesa_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#define _es_ClearColor _mesa_ClearColor + +extern void GL_APIENTRY _mesa_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +static void GL_APIENTRY _es_ClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha) +{ + GLclampf converted_red; + GLclampf converted_green; + GLclampf converted_blue; + GLclampf converted_alpha; + + converted_red = (GLclampf) (red / 65536.0f); + converted_green = (GLclampf) (green / 65536.0f); + converted_blue = (GLclampf) (blue / 65536.0f); + converted_alpha = (GLclampf) (alpha / 65536.0f); + + _mesa_ClearColor(converted_red, converted_green, converted_blue, converted_alpha); +} + +extern void GL_APIENTRY _mesa_ClearDepthf(GLclampf depth); +#define _es_ClearDepthf _mesa_ClearDepthf + +extern void GL_APIENTRY _mesa_ClearDepthf(GLclampf depth); +static void GL_APIENTRY _es_ClearDepthx(GLclampx depth) +{ + GLclampf converted_depth; + + converted_depth = (GLclampf) (depth / 65536.0f); + + _mesa_ClearDepthf(converted_depth); +} + +extern void GL_APIENTRY _mesa_ClearStencil(GLint s); +#define _es_ClearStencil _mesa_ClearStencil + +extern void GL_APIENTRY _mesa_ClientActiveTextureARB(GLenum texture); +static void GL_APIENTRY _es_ClientActiveTexture(GLenum texture) +{ + switch(texture) { + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + case GL_TEXTURE8: + case GL_TEXTURE9: + case GL_TEXTURE10: + case GL_TEXTURE11: + case GL_TEXTURE12: + case GL_TEXTURE13: + case GL_TEXTURE14: + case GL_TEXTURE15: + case GL_TEXTURE16: + case GL_TEXTURE17: + case GL_TEXTURE18: + case GL_TEXTURE19: + case GL_TEXTURE20: + case GL_TEXTURE21: + case GL_TEXTURE22: + case GL_TEXTURE23: + case GL_TEXTURE24: + case GL_TEXTURE25: + case GL_TEXTURE26: + case GL_TEXTURE27: + case GL_TEXTURE28: + case GL_TEXTURE29: + case GL_TEXTURE30: + case GL_TEXTURE31: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glClientActiveTexture(texture=0x%x)", texture); + return; + } + + _mesa_ClientActiveTextureARB(texture); +} + +extern void GL_APIENTRY _mesa_ClipPlane(GLenum plane, GLdouble const * equation); +static void GL_APIENTRY _es_ClipPlanef(GLenum plane, const GLfloat *equation) +{ + register unsigned int i; + unsigned int n_equation = 4; + GLdouble converted_equation[4]; + + switch(plane) { + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glClipPlanef(plane=0x%x)", plane); + return; + } + + for (i = 0; i < n_equation; i++) { + converted_equation[i] = (GLdouble) (equation[i]); + } + + _mesa_ClipPlane(plane, converted_equation); +} + +extern void GL_APIENTRY _mesa_ClipPlane(GLenum plane, GLdouble const * equation); +static void GL_APIENTRY _es_ClipPlanex(GLenum plane, const GLfixed *equation) +{ + register unsigned int i; + unsigned int n_equation = 4; + GLdouble converted_equation[4]; + + switch(plane) { + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glClipPlanex(plane=0x%x)", plane); + return; + } + + for (i = 0; i < n_equation; i++) { + converted_equation[i] = (GLdouble) (equation[i] / 65536.0); + } + + _mesa_ClipPlane(plane, converted_equation); +} + +extern void GL_APIENTRY _vbo_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define _es_Color4f _vbo_Color4f + +extern void GL_APIENTRY _vbo_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +static void GL_APIENTRY _es_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + GLfloat converted_red; + GLfloat converted_green; + GLfloat converted_blue; + GLfloat converted_alpha; + + converted_red = (GLfloat) (red / 255.0f); + converted_green = (GLfloat) (green / 255.0f); + converted_blue = (GLfloat) (blue / 255.0f); + converted_alpha = (GLfloat) (alpha / 255.0f); + + _vbo_Color4f(converted_red, converted_green, converted_blue, converted_alpha); +} + +extern void GL_APIENTRY _vbo_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +static void GL_APIENTRY _es_Color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) +{ + GLfloat converted_red; + GLfloat converted_green; + GLfloat converted_blue; + GLfloat converted_alpha; + + converted_red = (GLfloat) (red / 65536.0f); + converted_green = (GLfloat) (green / 65536.0f); + converted_blue = (GLfloat) (blue / 65536.0f); + converted_alpha = (GLfloat) (alpha / 65536.0f); + + _vbo_Color4f(converted_red, converted_green, converted_blue, converted_alpha); +} + +extern void GL_APIENTRY _mesa_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#define _es_ColorMask _mesa_ColorMask + +extern void GL_APIENTRY _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + switch(size) { + case 4: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glColorPointer(size=%d)", size); + return; + } + switch(type) { + case GL_UNSIGNED_BYTE: + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glColorPointer(type=0x%x)", type); + return; + } + + _mesa_ColorPointer(size, type, stride, pointer); +} + +extern void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexImage2D(internalFormat=0x%x)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCompressedTexImage2D(border=%d)", border); + return; + } + + _mesa_CompressedTexImage2DARB(target, level, internalFormat, width, height, border, imageSize, data); +} + +extern void GL_APIENTRY _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexSubImage2D(target=0x%x)", target); + return; + } + + _mesa_CompressedTexSubImage2DARB(target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +extern void GL_APIENTRY _mesa_CopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +static void GL_APIENTRY _es_CopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCopyTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCopyTexImage2D(internalFormat=0x%x)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCopyTexImage2D(border=%d)", border); + return; + } + + _mesa_CopyTexImage2D(target, level, internalFormat, x, y, width, height, border); +} + +extern void GL_APIENTRY _mesa_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +static void GL_APIENTRY _es_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCopyTexSubImage2D(target=0x%x)", target); + return; + } + + _mesa_CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +extern void GL_APIENTRY _mesa_CullFace(GLenum mode); +static void GL_APIENTRY _es_CullFace(GLenum mode) +{ + switch(mode) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCullFace(mode=0x%x)", mode); + return; + } + + _mesa_CullFace(mode); +} + +extern void GL_APIENTRY _mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); +#define _es_DeleteBuffers _mesa_DeleteBuffersARB + +extern void GL_APIENTRY _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers); +#define _es_DeleteFramebuffersOES _mesa_DeleteFramebuffersEXT + +extern void GL_APIENTRY _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers); +#define _es_DeleteRenderbuffersOES _mesa_DeleteRenderbuffersEXT + +extern void GL_APIENTRY _mesa_DeleteTextures(GLsizei n, const GLuint * textures); +#define _es_DeleteTextures _mesa_DeleteTextures + +extern void GL_APIENTRY _mesa_DepthFunc(GLenum func); +static void GL_APIENTRY _es_DepthFunc(GLenum func) +{ + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDepthFunc(func=0x%x)", func); + return; + } + + _mesa_DepthFunc(func); +} + +extern void GL_APIENTRY _mesa_DepthMask(GLboolean flag); +#define _es_DepthMask _mesa_DepthMask + +extern void GL_APIENTRY _mesa_DepthRangef(GLclampf zNear, GLclampf zFar); +#define _es_DepthRangef _mesa_DepthRangef + +extern void GL_APIENTRY _mesa_DepthRangef(GLclampf zNear, GLclampf zFar); +static void GL_APIENTRY _es_DepthRangex(GLclampx zNear, GLclampx zFar) +{ + GLclampf converted_zNear; + GLclampf converted_zFar; + + converted_zNear = (GLclampf) (zNear / 65536.0f); + converted_zFar = (GLclampf) (zFar / 65536.0f); + + _mesa_DepthRangef(converted_zNear, converted_zFar); +} + +extern void GL_APIENTRY _mesa_Disable(GLenum cap); +static void GL_APIENTRY _es_Disable(GLenum cap) +{ + switch(cap) { + case GL_NORMALIZE: + case GL_RESCALE_NORMAL: + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_FOG: + case GL_LIGHTING: + case GL_COLOR_MATERIAL: + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + case GL_POINT_SMOOTH: + case GL_LINE_SMOOTH: + case GL_CULL_FACE: + case GL_POLYGON_OFFSET_FILL: + case GL_MULTISAMPLE: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_ALPHA_TO_ONE: + case GL_SAMPLE_COVERAGE: + case GL_TEXTURE_2D: + case GL_SCISSOR_TEST: + case GL_ALPHA_TEST: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_BLEND: + case GL_DITHER: + case GL_COLOR_LOGIC_OP: + case GL_POINT_SPRITE_OES: + case GL_MATRIX_PALETTE_OES: + case GL_TEXTURE_CUBE_MAP_OES: + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDisable(cap=0x%x)", cap); + return; + } + + _mesa_Disable(cap); +} + +extern void GL_APIENTRY _mesa_DisableClientState(GLenum array); +static void GL_APIENTRY _es_DisableClientState(GLenum array) +{ + switch(array) { + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_MATRIX_INDEX_ARRAY_OES: + case GL_WEIGHT_ARRAY_OES: + case GL_POINT_SIZE_ARRAY_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDisableClientState(array=0x%x)", array); + return; + } + + _mesa_DisableClientState(array); +} + +extern void GL_APIENTRY _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); +static void GL_APIENTRY _es_DrawArrays(GLenum mode, GLint first, GLsizei count) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawArrays(mode=0x%x)", mode); + return; + } + + _mesa_DrawArrays(mode, first, count); +} + +extern void GL_APIENTRY _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices); +static void GL_APIENTRY _es_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawElements(mode=0x%x)", mode); + return; + } + switch(type) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawElements(type=0x%x)", type); + return; + } + + _mesa_DrawElements(mode, count, type, indices); +} + +extern void GL_APIENTRY _mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h); +#define _es_DrawTexfOES _mesa_DrawTexf + +extern void GL_APIENTRY _mesa_DrawTexfv(const GLfloat * coords); +#define _es_DrawTexfvOES _mesa_DrawTexfv + +extern void GL_APIENTRY _mesa_DrawTexi(GLint x, GLint y, GLint z, GLint w, GLint h); +#define _es_DrawTexiOES _mesa_DrawTexi + +extern void GL_APIENTRY _mesa_DrawTexiv(const GLint * coords); +#define _es_DrawTexivOES _mesa_DrawTexiv + +extern void GL_APIENTRY _mesa_DrawTexs(GLshort x, GLshort y, GLshort z, GLshort w, GLshort h); +#define _es_DrawTexsOES _mesa_DrawTexs + +extern void GL_APIENTRY _mesa_DrawTexsv(const GLshort * coords); +#define _es_DrawTexsvOES _mesa_DrawTexsv + +extern void GL_APIENTRY _mesa_DrawTexf(GLfloat x, GLfloat y, GLfloat z, GLfloat w, GLfloat h); +static void GL_APIENTRY _es_DrawTexxOES(GLfixed x, GLfixed y, GLfixed z, GLfixed w, GLfixed h) +{ + GLfloat converted_x; + GLfloat converted_y; + GLfloat converted_z; + GLfloat converted_w; + GLfloat converted_h; + + converted_x = (GLfloat) (x / 65536.0f); + converted_y = (GLfloat) (y / 65536.0f); + converted_z = (GLfloat) (z / 65536.0f); + converted_w = (GLfloat) (w / 65536.0f); + converted_h = (GLfloat) (h / 65536.0f); + + _mesa_DrawTexf(converted_x, converted_y, converted_z, converted_w, converted_h); +} + +extern void GL_APIENTRY _mesa_DrawTexfv(GLfloat const * coords); +static void GL_APIENTRY _es_DrawTexxvOES(const GLfixed *coords) +{ + register unsigned int i; + unsigned int n_coords = 5; + GLfloat converted_coords[5]; + + for (i = 0; i < n_coords; i++) { + converted_coords[i] = (GLfloat) (coords[i] / 65536.0f); + } + + _mesa_DrawTexfv(converted_coords); +} + +extern void GL_APIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); +static void GL_APIENTRY _es_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + switch(target) { + case GL_RENDERBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEGLImageTargetRenderbufferStorageOES(target=0x%x)", target); + return; + } + + _mesa_EGLImageTargetRenderbufferStorageOES(target, image); +} + +extern void GL_APIENTRY _mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); +static void GL_APIENTRY _es_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + switch(target) { + case GL_TEXTURE_2D: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEGLImageTargetTexture2DOES(target=0x%x)", target); + return; + } + + _mesa_EGLImageTargetTexture2DOES(target, image); +} + +extern void GL_APIENTRY _mesa_Enable(GLenum cap); +static void GL_APIENTRY _es_Enable(GLenum cap) +{ + switch(cap) { + case GL_NORMALIZE: + case GL_RESCALE_NORMAL: + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_FOG: + case GL_LIGHTING: + case GL_COLOR_MATERIAL: + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + case GL_POINT_SMOOTH: + case GL_LINE_SMOOTH: + case GL_CULL_FACE: + case GL_POLYGON_OFFSET_FILL: + case GL_MULTISAMPLE: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_ALPHA_TO_ONE: + case GL_SAMPLE_COVERAGE: + case GL_TEXTURE_2D: + case GL_SCISSOR_TEST: + case GL_ALPHA_TEST: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_BLEND: + case GL_DITHER: + case GL_COLOR_LOGIC_OP: + case GL_POINT_SPRITE_OES: + case GL_MATRIX_PALETTE_OES: + case GL_TEXTURE_CUBE_MAP_OES: + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEnable(cap=0x%x)", cap); + return; + } + + _mesa_Enable(cap); +} + +extern void GL_APIENTRY _mesa_EnableClientState(GLenum array); +static void GL_APIENTRY _es_EnableClientState(GLenum array) +{ + switch(array) { + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_MATRIX_INDEX_ARRAY_OES: + case GL_WEIGHT_ARRAY_OES: + case GL_POINT_SIZE_ARRAY_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEnableClientState(array=0x%x)", array); + return; + } + + _mesa_EnableClientState(array); +} + +extern void GL_APIENTRY _mesa_Finish(void); +#define _es_Finish _mesa_Finish + +extern void GL_APIENTRY _mesa_Flush(void); +#define _es_Flush _mesa_Flush + +extern void GL_APIENTRY _mesa_Fogf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Fogf(GLenum pname, GLfloat param) +{ + switch(pname) { + case GL_FOG_MODE: + if (param != GL_EXP && param != GL_EXP2 && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogf(pname=0x%x)", pname); + return; + } + break; + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogf(pname=0x%x)", pname); + return; + } + + _mesa_Fogf(pname, param); +} + +extern void GL_APIENTRY _mesa_Fogfv(GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_Fogfv(GLenum pname, const GLfloat *params) +{ + switch(pname) { + case GL_FOG_MODE: /* size 1 */ + if (params[0] != GL_EXP && params[0] != GL_EXP2 && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogfv(pname=0x%x)", pname); + return; + } + break; + case GL_FOG_COLOR: /* size 4 */ + case GL_FOG_DENSITY: /* size 1 */ + case GL_FOG_START: /* size 1 */ + case GL_FOG_END: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogfv(pname=0x%x)", pname); + return; + } + + _mesa_Fogfv(pname, params); +} + +extern void GL_APIENTRY _mesa_Fogf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Fogx(GLenum pname, GLfixed param) +{ + GLfloat converted_param; + int convert_param_value = 1; + + switch(pname) { + case GL_FOG_MODE: + if (param != GL_EXP && param != GL_EXP2 && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogx(pname=0x%x)", pname); + return; + } + + if (convert_param_value) { + converted_param = (GLfloat) (param / 65536.0f); + } else { + converted_param = (GLfloat) param; + } + + _mesa_Fogf(pname, converted_param); +} + +extern void GL_APIENTRY _mesa_Fogfv(GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_Fogxv(GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(pname) { + case GL_FOG_MODE: + if (params[0] != GL_EXP && params[0] != GL_EXP2 && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_FOG_COLOR: + n_params = 4; + break; + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFogxv(pname=0x%x)", pname); + return; + } + + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + } else { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + } + + _mesa_Fogfv(pname, converted_params); +} + +extern void GL_APIENTRY _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +static void GL_APIENTRY _es_FramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + switch(target) { + case GL_FRAMEBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbufferOES(target=0x%x)", target); + return; + } + switch(attachment) { + case GL_COLOR_ATTACHMENT0_OES: + case GL_DEPTH_ATTACHMENT_OES: + case GL_STENCIL_ATTACHMENT_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbufferOES(attachment=0x%x)", attachment); + return; + } + switch(renderbuffertarget) { + case GL_RENDERBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbufferOES(renderbuffertarget=0x%x)", renderbuffertarget); + return; + } + + _mesa_FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +} + +extern void GL_APIENTRY _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +static void GL_APIENTRY _es_FramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + switch(target) { + case GL_FRAMEBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture2DOES(target=0x%x)", target); + return; + } + switch(attachment) { + case GL_COLOR_ATTACHMENT0_OES: + case GL_DEPTH_ATTACHMENT_OES: + case GL_STENCIL_ATTACHMENT_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture2DOES(attachment=0x%x)", attachment); + return; + } + switch(textarget) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glFramebufferTexture2DOES(textarget=0x%x)", textarget); + return; + } + + _mesa_FramebufferTexture2DEXT(target, attachment, textarget, texture, level); +} + +extern void GL_APIENTRY _mesa_FrontFace(GLenum mode); +static void GL_APIENTRY _es_FrontFace(GLenum mode) +{ + switch(mode) { + case GL_CW: + case GL_CCW: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFrontFace(mode=0x%x)", mode); + return; + } + + _mesa_FrontFace(mode); +} + +extern void GL_APIENTRY _mesa_Frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +static void GL_APIENTRY _es_Frustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GLdouble converted_left; + GLdouble converted_right; + GLdouble converted_bottom; + GLdouble converted_top; + GLdouble converted_zNear; + GLdouble converted_zFar; + + converted_left = (GLdouble) (left); + converted_right = (GLdouble) (right); + converted_bottom = (GLdouble) (bottom); + converted_top = (GLdouble) (top); + converted_zNear = (GLdouble) (zNear); + converted_zFar = (GLdouble) (zFar); + + _mesa_Frustum(converted_left, converted_right, converted_bottom, converted_top, converted_zNear, converted_zFar); +} + +extern void GL_APIENTRY _mesa_Frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +static void GL_APIENTRY _es_Frustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GLdouble converted_left; + GLdouble converted_right; + GLdouble converted_bottom; + GLdouble converted_top; + GLdouble converted_zNear; + GLdouble converted_zFar; + + converted_left = (GLdouble) (left / 65536.0); + converted_right = (GLdouble) (right / 65536.0); + converted_bottom = (GLdouble) (bottom / 65536.0); + converted_top = (GLdouble) (top / 65536.0); + converted_zNear = (GLdouble) (zNear / 65536.0); + converted_zFar = (GLdouble) (zFar / 65536.0); + + _mesa_Frustum(converted_left, converted_right, converted_bottom, converted_top, converted_zNear, converted_zFar); +} + +extern void GL_APIENTRY _mesa_GenBuffersARB(GLsizei n, GLuint * buffer); +#define _es_GenBuffers _mesa_GenBuffersARB + +extern void GL_APIENTRY _mesa_GenFramebuffersEXT(GLsizei n, GLuint * ids); +#define _es_GenFramebuffersOES _mesa_GenFramebuffersEXT + +extern void GL_APIENTRY _mesa_GenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers); +#define _es_GenRenderbuffersOES _mesa_GenRenderbuffersEXT + +extern void GL_APIENTRY _mesa_GenTextures(GLsizei n, GLuint * textures); +#define _es_GenTextures _mesa_GenTextures + +extern void GL_APIENTRY _mesa_GenerateMipmapEXT(GLenum target); +static void GL_APIENTRY _es_GenerateMipmapOES(GLenum target) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGenerateMipmapOES(target=0x%x)", target); + return; + } + + _mesa_GenerateMipmapEXT(target); +} + +extern void GL_APIENTRY _mesa_GetBooleanv(GLenum pname, GLboolean * params); +#define _es_GetBooleanv _mesa_GetBooleanv + +extern void GL_APIENTRY _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_BUFFER_SIZE: + case GL_BUFFER_USAGE: + case GL_BUFFER_ACCESS_OES: + case GL_BUFFER_MAPPED_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetBufferParameterivARB(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid ** params); +static void GL_APIENTRY _es_GetBufferPointervOES(GLenum target, GLenum pname, GLvoid **params) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferPointervOES(target=0x%x)", target); + return; + } + switch(pname) { + case GL_BUFFER_MAP_POINTER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferPointervOES(pname=0x%x)", pname); + return; + } + + _mesa_GetBufferPointervARB(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetClipPlane(GLenum plane, GLdouble * equation); +static void GL_APIENTRY _es_GetClipPlanef(GLenum plane, GLfloat *equation) +{ + register unsigned int i; + unsigned int n_equation = 4; + GLdouble converted_equation[4]; + + switch(plane) { + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetClipPlanef(plane=0x%x)", plane); + return; + } + + _mesa_GetClipPlane(plane, converted_equation); + for (i = 0; i < n_equation; i++) { + equation[i] = (GLfloat) (converted_equation[i]); + } +} + +extern void GL_APIENTRY _mesa_GetClipPlane(GLenum plane, GLdouble * equation); +static void GL_APIENTRY _es_GetClipPlanex(GLenum plane, GLfixed *equation) +{ + register unsigned int i; + unsigned int n_equation = 4; + GLdouble converted_equation[4]; + + switch(plane) { + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetClipPlanex(plane=0x%x)", plane); + return; + } + + _mesa_GetClipPlane(plane, converted_equation); + for (i = 0; i < n_equation; i++) { + equation[i] = (GLfixed) (converted_equation[i] * 65536); + } +} + +extern GLenum GL_APIENTRY _mesa_GetError(void); +#define _es_GetError _mesa_GetError + +extern void GL_APIENTRY _mesa_GetFixedv(GLenum pname, GLfixed * params); +#define _es_GetFixedv _mesa_GetFixedv + +extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat * params); +#define _es_GetFloatv _mesa_GetFloatv + +extern void GL_APIENTRY _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint *params) +{ + switch(target) { + case GL_FRAMEBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetFramebufferAttachmentParameterivOES(target=0x%x)", target); + return; + } + switch(pname) { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_OES: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetFramebufferAttachmentParameterivOES(pname=0x%x)", pname); + return; + } + + _mesa_GetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); +} + +extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint * params); +#define _es_GetIntegerv _mesa_GetIntegerv + +extern void GL_APIENTRY _mesa_GetLightfv(GLenum light, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetLightfv(GLenum light, GLenum pname, GLfloat *params) +{ + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetLightfv(light=0x%x)", light); + return; + } + switch(pname) { + case GL_AMBIENT: /* size 4 */ + case GL_DIFFUSE: /* size 4 */ + case GL_SPECULAR: /* size 4 */ + case GL_POSITION: /* size 4 */ + case GL_SPOT_DIRECTION: /* size 3 */ + case GL_SPOT_EXPONENT: /* size 1 */ + case GL_SPOT_CUTOFF: /* size 1 */ + case GL_CONSTANT_ATTENUATION: /* size 1 */ + case GL_LINEAR_ATTENUATION: /* size 1 */ + case GL_QUADRATIC_ATTENUATION: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetLightfv(pname=0x%x)", pname); + return; + } + + _mesa_GetLightfv(light, pname, params); +} + +extern void GL_APIENTRY _mesa_GetLightfv(GLenum light, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetLightxv(GLenum light, GLenum pname, GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetLightxv(light=0x%x)", light); + return; + } + switch(pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_POSITION: + n_params = 4; + break; + case GL_SPOT_DIRECTION: + n_params = 3; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetLightxv(pname=0x%x)", pname); + return; + } + + _mesa_GetLightfv(light, pname, converted_params); + for (i = 0; i < n_params; i++) { + params[i] = (GLint) (converted_params[i] * 65536); + } +} + +extern void GL_APIENTRY _mesa_GetMaterialfv(GLenum face, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params) +{ + switch(face) { + case GL_FRONT: + case GL_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetMaterialfv(face=0x%x)", face); + return; + } + switch(pname) { + case GL_SHININESS: /* size 1 */ + case GL_AMBIENT: /* size 4 */ + case GL_DIFFUSE: /* size 4 */ + case GL_AMBIENT_AND_DIFFUSE: /* size 4 */ + case GL_SPECULAR: /* size 4 */ + case GL_EMISSION: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetMaterialfv(pname=0x%x)", pname); + return; + } + + _mesa_GetMaterialfv(face, pname, params); +} + +extern void GL_APIENTRY _mesa_GetMaterialfv(GLenum face, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetMaterialxv(GLenum face, GLenum pname, GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + + switch(face) { + case GL_FRONT: + case GL_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetMaterialxv(face=0x%x)", face); + return; + } + switch(pname) { + case GL_SHININESS: + n_params = 1; + break; + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_AMBIENT_AND_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + n_params = 4; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetMaterialxv(pname=0x%x)", pname); + return; + } + + _mesa_GetMaterialfv(face, pname, converted_params); + for (i = 0; i < n_params; i++) { + params[i] = (GLint) (converted_params[i] * 65536); + } +} + +extern void GL_APIENTRY _mesa_GetPointerv(GLenum pname, GLvoid ** params); +static void GL_APIENTRY _es_GetPointerv(GLenum pname, GLvoid **params) +{ + switch(pname) { + case GL_VERTEX_ARRAY_POINTER: + case GL_NORMAL_ARRAY_POINTER: + case GL_COLOR_ARRAY_POINTER: + case GL_TEXTURE_COORD_ARRAY_POINTER: + case GL_MATRIX_INDEX_ARRAY_POINTER_OES: + case GL_WEIGHT_ARRAY_POINTER_OES: + case GL_POINT_SIZE_ARRAY_POINTER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetPointerv(pname=0x%x)", pname); + return; + } + + _mesa_GetPointerv(pname, params); +} + +extern void GL_APIENTRY _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_RENDERBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetRenderbufferParameterivOES(target=0x%x)", target); + return; + } + switch(pname) { + case GL_RENDERBUFFER_WIDTH_OES: /* size 1 */ + case GL_RENDERBUFFER_HEIGHT_OES: /* size 1 */ + case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: /* size 1 */ + case GL_RENDERBUFFER_RED_SIZE_OES: /* size 1 */ + case GL_RENDERBUFFER_GREEN_SIZE_OES: /* size 1 */ + case GL_RENDERBUFFER_BLUE_SIZE_OES: /* size 1 */ + case GL_RENDERBUFFER_ALPHA_SIZE_OES: /* size 1 */ + case GL_RENDERBUFFER_DEPTH_SIZE_OES: /* size 1 */ + case GL_RENDERBUFFER_STENCIL_SIZE_OES: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetRenderbufferParameterivOES(pname=0x%x)", pname); + return; + } + + _mesa_GetRenderbufferParameterivEXT(target, pname, params); +} + +extern const GLubyte * GL_APIENTRY _mesa_GetString(GLenum name); +static const GLubyte * GL_APIENTRY _es_GetString(GLenum name) +{ + switch(name) { + case GL_VENDOR: + case GL_RENDERER: + case GL_VERSION: + case GL_EXTENSIONS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetString(name=0x%x)", name); + return (const GLubyte *) 0; + } + + return _mesa_GetString(name); +} + +extern void GL_APIENTRY _mesa_GetTexEnvfv(GLenum target, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvfv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvfv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_COLOR && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvfv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: /* size 1 */ + break; + case GL_TEXTURE_LOD_BIAS_EXT: /* size 1 */ + case GL_TEXTURE_ENV_COLOR: /* size 4 */ + case GL_RGB_SCALE: /* size 1 */ + case GL_ALPHA_SCALE: /* size 1 */ + break; + case GL_TEXTURE_ENV_MODE: /* size 1 */ + case GL_COMBINE_RGB: /* size 1 */ + case GL_COMBINE_ALPHA: /* size 1 */ + case GL_SRC0_RGB: /* size 1 */ + case GL_SRC1_RGB: /* size 1 */ + case GL_SRC2_RGB: /* size 1 */ + case GL_SRC0_ALPHA: /* size 1 */ + case GL_SRC1_ALPHA: /* size 1 */ + case GL_SRC2_ALPHA: /* size 1 */ + case GL_OPERAND0_RGB: /* size 1 */ + case GL_OPERAND1_RGB: /* size 1 */ + case GL_OPERAND2_RGB: /* size 1 */ + case GL_OPERAND0_ALPHA: /* size 1 */ + case GL_OPERAND1_ALPHA: /* size 1 */ + case GL_OPERAND2_ALPHA: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvfv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexEnvfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetTexEnviv(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetTexEnviv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnviv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnviv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_COLOR && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnviv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnviv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: /* size 1 */ + break; + case GL_TEXTURE_LOD_BIAS_EXT: /* size 1 */ + case GL_TEXTURE_ENV_COLOR: /* size 4 */ + case GL_RGB_SCALE: /* size 1 */ + case GL_ALPHA_SCALE: /* size 1 */ + break; + case GL_TEXTURE_ENV_MODE: /* size 1 */ + case GL_COMBINE_RGB: /* size 1 */ + case GL_COMBINE_ALPHA: /* size 1 */ + case GL_SRC0_RGB: /* size 1 */ + case GL_SRC1_RGB: /* size 1 */ + case GL_SRC2_RGB: /* size 1 */ + case GL_SRC0_ALPHA: /* size 1 */ + case GL_SRC1_ALPHA: /* size 1 */ + case GL_SRC2_ALPHA: /* size 1 */ + case GL_OPERAND0_RGB: /* size 1 */ + case GL_OPERAND1_RGB: /* size 1 */ + case GL_OPERAND2_RGB: /* size 1 */ + case GL_OPERAND0_ALPHA: /* size 1 */ + case GL_OPERAND1_ALPHA: /* size 1 */ + case GL_OPERAND2_ALPHA: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnviv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexEnviv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetTexEnvfv(GLenum target, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetTexEnvxv(GLenum target, GLenum pname, GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvxv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvxv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_COLOR && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvxv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvxv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_LOD_BIAS_EXT: + n_params = 1; + break; + case GL_TEXTURE_ENV_COLOR: + n_params = 4; + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + n_params = 1; + break; + case GL_TEXTURE_ENV_MODE: + case GL_COMBINE_RGB: + case GL_COMBINE_ALPHA: + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + convert_params_value = 0; + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexEnvxv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexEnvfv(target, pname, converted_params); + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + params[i] = (GLint) (converted_params[i] * 65536); + } + } else { + for (i = 0; i < n_params; i++) { + params[i] = (GLfixed) converted_params[i]; + } + } +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat * params); +static void GL_APIENTRY _check_GetTexGenfvOES(GLenum coord, GLenum pname, GLfloat *params) +{ + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenfvOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenfvOES(pname=0x%x)", pname); + return; + } + + _es_GetTexGenfv(coord, pname, params); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat * params); +static void GL_APIENTRY _check_GetTexGenivOES(GLenum coord, GLenum pname, GLint *params) +{ + register unsigned int i; + unsigned int n_params = 1; + GLfloat converted_params[1]; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenivOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenivOES(pname=0x%x)", pname); + return; + } + + _es_GetTexGenfv(coord, pname, converted_params); + for (i = 0; i < n_params; i++) { + params[i] = (GLfloat) converted_params[i]; + } +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_GetTexGenfv(GLenum coord, GLenum pname, GLfloat * params); +static void GL_APIENTRY _check_GetTexGenxvOES(GLenum coord, GLenum pname, GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 1; + GLfloat converted_params[1]; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenxvOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexGenxvOES(pname=0x%x)", pname); + return; + } + + _es_GetTexGenfv(coord, pname, converted_params); + for (i = 0; i < n_params; i++) { + params[i] = (GLfloat) converted_params[i]; + } +} + +extern void GL_APIENTRY _mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + case GL_GENERATE_MIPMAP: /* size 1 */ + break; + case GL_TEXTURE_CROP_RECT_OES: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexParameterfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetTexParameteriv(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + case GL_GENERATE_MIPMAP: /* size 1 */ + break; + case GL_TEXTURE_CROP_RECT_OES: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexParameteriv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetTexParameterxv(GLenum target, GLenum pname, GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterxv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_GENERATE_MIPMAP: + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_CROP_RECT_OES: + n_params = 4; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterxv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexParameterfv(target, pname, converted_params); + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + params[i] = (GLint) (converted_params[i] * 65536); + } + } else { + for (i = 0; i < n_params; i++) { + params[i] = (GLfixed) converted_params[i]; + } + } +} + +extern void GL_APIENTRY _mesa_Hint(GLenum target, GLenum mode); +static void GL_APIENTRY _es_Hint(GLenum target, GLenum mode) +{ + switch(target) { + case GL_FOG_HINT: + case GL_LINE_SMOOTH_HINT: + case GL_PERSPECTIVE_CORRECTION_HINT: + case GL_POINT_SMOOTH_HINT: + case GL_GENERATE_MIPMAP_HINT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glHint(target=0x%x)", target); + return; + } + switch(mode) { + case GL_FASTEST: + case GL_NICEST: + case GL_DONT_CARE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glHint(mode=0x%x)", mode); + return; + } + + _mesa_Hint(target, mode); +} + +extern GLboolean GL_APIENTRY _mesa_IsBufferARB(GLuint buffer); +#define _es_IsBuffer _mesa_IsBufferARB + +extern GLboolean GL_APIENTRY _mesa_IsEnabled(GLenum cap); +static GLboolean GL_APIENTRY _es_IsEnabled(GLenum cap) +{ + switch(cap) { + case GL_NORMALIZE: + case GL_RESCALE_NORMAL: + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_FOG: + case GL_LIGHTING: + case GL_COLOR_MATERIAL: + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + case GL_POINT_SMOOTH: + case GL_LINE_SMOOTH: + case GL_CULL_FACE: + case GL_POLYGON_OFFSET_FILL: + case GL_MULTISAMPLE: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_ALPHA_TO_ONE: + case GL_SAMPLE_COVERAGE: + case GL_TEXTURE_2D: + case GL_SCISSOR_TEST: + case GL_ALPHA_TEST: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_BLEND: + case GL_DITHER: + case GL_COLOR_LOGIC_OP: + case GL_POINT_SPRITE_OES: + case GL_TEXTURE_CUBE_MAP_OES: + case GL_TEXTURE_GEN_STR_OES: + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_MATRIX_INDEX_ARRAY_OES: + case GL_WEIGHT_ARRAY_OES: + case GL_POINT_SIZE_ARRAY_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glIsEnabled(cap=0x%x)", cap); + return GL_FALSE; + } + + return _mesa_IsEnabled(cap); +} + +extern GLboolean GL_APIENTRY _mesa_IsFramebufferEXT(GLuint framebuffer); +#define _es_IsFramebufferOES _mesa_IsFramebufferEXT + +extern GLboolean GL_APIENTRY _mesa_IsRenderbufferEXT(GLuint renderbuffer); +#define _es_IsRenderbufferOES _mesa_IsRenderbufferEXT + +extern GLboolean GL_APIENTRY _mesa_IsTexture(GLuint texture); +#define _es_IsTexture _mesa_IsTexture + +extern void GL_APIENTRY _mesa_LightModelf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_LightModelf(GLenum pname, GLfloat param) +{ + switch(pname) { + case GL_LIGHT_MODEL_TWO_SIDE: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelf(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelf(pname=0x%x)", pname); + return; + } + + _mesa_LightModelf(pname, param); +} + +extern void GL_APIENTRY _mesa_LightModelfv(GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_LightModelfv(GLenum pname, const GLfloat *params) +{ + switch(pname) { + case GL_LIGHT_MODEL_AMBIENT: /* size 4 */ + break; + case GL_LIGHT_MODEL_TWO_SIDE: /* size 1 */ + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelfv(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelfv(pname=0x%x)", pname); + return; + } + + _mesa_LightModelfv(pname, params); +} + +extern void GL_APIENTRY _mesa_LightModelf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_LightModelx(GLenum pname, GLfixed param) +{ + GLfloat converted_param; + + switch(pname) { + case GL_LIGHT_MODEL_TWO_SIDE: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelx(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelx(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) param; + + _mesa_LightModelf(pname, converted_param); +} + +extern void GL_APIENTRY _mesa_LightModelfv(GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_LightModelxv(GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(pname) { + case GL_LIGHT_MODEL_AMBIENT: + n_params = 4; + break; + case GL_LIGHT_MODEL_TWO_SIDE: + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightModelxv(pname=0x%x)", pname); + return; + } + + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + } else { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + } + + _mesa_LightModelfv(pname, converted_params); +} + +extern void GL_APIENTRY _mesa_Lightf(GLenum light, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Lightf(GLenum light, GLenum pname, GLfloat param) +{ + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightf(light=0x%x)", light); + return; + } + switch(pname) { + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightf(pname=0x%x)", pname); + return; + } + + _mesa_Lightf(light, pname, param); +} + +extern void GL_APIENTRY _mesa_Lightfv(GLenum light, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_Lightfv(GLenum light, GLenum pname, const GLfloat *params) +{ + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightfv(light=0x%x)", light); + return; + } + switch(pname) { + case GL_AMBIENT: /* size 4 */ + case GL_DIFFUSE: /* size 4 */ + case GL_SPECULAR: /* size 4 */ + case GL_POSITION: /* size 4 */ + case GL_SPOT_DIRECTION: /* size 3 */ + case GL_SPOT_EXPONENT: /* size 1 */ + case GL_SPOT_CUTOFF: /* size 1 */ + case GL_CONSTANT_ATTENUATION: /* size 1 */ + case GL_LINEAR_ATTENUATION: /* size 1 */ + case GL_QUADRATIC_ATTENUATION: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightfv(pname=0x%x)", pname); + return; + } + + _mesa_Lightfv(light, pname, params); +} + +extern void GL_APIENTRY _mesa_Lightf(GLenum light, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Lightx(GLenum light, GLenum pname, GLfixed param) +{ + GLfloat converted_param; + + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightx(light=0x%x)", light); + return; + } + switch(pname) { + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightx(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) (param / 65536.0f); + + _mesa_Lightf(light, pname, converted_param); +} + +extern void GL_APIENTRY _mesa_Lightfv(GLenum light, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_Lightxv(GLenum light, GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + + switch(light) { + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightxv(light=0x%x)", light); + return; + } + switch(pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_POSITION: + n_params = 4; + break; + case GL_SPOT_DIRECTION: + n_params = 3; + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLightxv(pname=0x%x)", pname); + return; + } + + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + + _mesa_Lightfv(light, pname, converted_params); +} + +extern void GL_APIENTRY _mesa_LineWidth(GLfloat width); +#define _es_LineWidth _mesa_LineWidth + +extern void GL_APIENTRY _mesa_LineWidth(GLfloat width); +static void GL_APIENTRY _es_LineWidthx(GLfixed width) +{ + GLfloat converted_width; + + converted_width = (GLfloat) (width / 65536.0f); + + _mesa_LineWidth(converted_width); +} + +extern void GL_APIENTRY _mesa_LoadIdentity(void); +#define _es_LoadIdentity _mesa_LoadIdentity + +extern void GL_APIENTRY _mesa_LoadMatrixf(const GLfloat * m); +#define _es_LoadMatrixf _mesa_LoadMatrixf + +extern void GL_APIENTRY _mesa_LoadMatrixf(GLfloat const * m); +static void GL_APIENTRY _es_LoadMatrixx(const GLfixed *m) +{ + register unsigned int i; + unsigned int n_m = 16; + GLfloat converted_m[16]; + + for (i = 0; i < n_m; i++) { + converted_m[i] = (GLfloat) (m[i] / 65536.0f); + } + + _mesa_LoadMatrixf(converted_m); +} + +extern void GL_APIENTRY _mesa_LogicOp(GLenum opcode); +static void GL_APIENTRY _es_LogicOp(GLenum opcode) +{ + switch(opcode) { + case GL_CLEAR: + case GL_SET: + case GL_COPY: + case GL_COPY_INVERTED: + case GL_NOOP: + case GL_INVERT: + case GL_AND: + case GL_NAND: + case GL_OR: + case GL_NOR: + case GL_XOR: + case GL_EQUIV: + case GL_AND_REVERSE: + case GL_AND_INVERTED: + case GL_OR_REVERSE: + case GL_OR_INVERTED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glLogicOp(opcode=0x%x)", opcode); + return; + } + + _mesa_LogicOp(opcode); +} + +extern void * GL_APIENTRY _mesa_MapBufferARB(GLenum target, GLenum access); +static void * GL_APIENTRY _es_MapBufferOES(GLenum target, GLenum access) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMapBufferOES(target=0x%x)", target); + return (void *) 0; + } + switch(access) { + case GL_WRITE_ONLY_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMapBufferOES(access=0x%x)", access); + return (void *) 0; + } + + return _mesa_MapBufferARB(target, access); +} + +extern void GL_APIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Materialf(GLenum face, GLenum pname, GLfloat param) +{ + switch(face) { + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialf(face=0x%x)", face); + return; + } + switch(pname) { + case GL_SHININESS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialf(pname=0x%x)", pname); + return; + } + + _vbo_Materialf(face, pname, param); +} + +extern void GL_APIENTRY _vbo_Materialfv(GLenum face, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_Materialfv(GLenum face, GLenum pname, const GLfloat *params) +{ + switch(face) { + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialfv(face=0x%x)", face); + return; + } + switch(pname) { + case GL_AMBIENT: /* size 4 */ + case GL_DIFFUSE: /* size 4 */ + case GL_AMBIENT_AND_DIFFUSE: /* size 4 */ + case GL_SPECULAR: /* size 4 */ + case GL_EMISSION: /* size 4 */ + case GL_SHININESS: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialfv(pname=0x%x)", pname); + return; + } + + _vbo_Materialfv(face, pname, params); +} + +extern void GL_APIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_Materialx(GLenum face, GLenum pname, GLfixed param) +{ + GLfloat converted_param; + + switch(face) { + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialx(face=0x%x)", face); + return; + } + switch(pname) { + case GL_SHININESS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialx(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) (param / 65536.0f); + + _vbo_Materialf(face, pname, converted_param); +} + +extern void GL_APIENTRY _vbo_Materialfv(GLenum face, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_Materialxv(GLenum face, GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + + switch(face) { + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialxv(face=0x%x)", face); + return; + } + switch(pname) { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_AMBIENT_AND_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + n_params = 4; + break; + case GL_SHININESS: + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMaterialxv(pname=0x%x)", pname); + return; + } + + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + + _vbo_Materialfv(face, pname, converted_params); +} + +extern void GL_APIENTRY _mesa_MatrixMode(GLenum mode); +static void GL_APIENTRY _es_MatrixMode(GLenum mode) +{ + switch(mode) { + case GL_MODELVIEW: + case GL_PROJECTION: + case GL_TEXTURE: + case GL_MATRIX_PALETTE_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMatrixMode(mode=0x%x)", mode); + return; + } + + _mesa_MatrixMode(mode); +} + +extern void GL_APIENTRY _mesa_MultMatrixf(const GLfloat * m); +#define _es_MultMatrixf _mesa_MultMatrixf + +extern void GL_APIENTRY _mesa_MultMatrixf(GLfloat const * m); +static void GL_APIENTRY _es_MultMatrixx(const GLfixed *m) +{ + register unsigned int i; + unsigned int n_m = 16; + GLfloat converted_m[16]; + + for (i = 0; i < n_m; i++) { + converted_m[i] = (GLfloat) (m[i] / 65536.0f); + } + + _mesa_MultMatrixf(converted_m); +} + +extern void GL_APIENTRY _mesa_MultiDrawArraysEXT(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount); +static void GL_APIENTRY _es_MultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawArraysEXT(mode=0x%x)", mode); + return; + } + + _mesa_MultiDrawArraysEXT(mode, first, count, primcount); +} + +extern void GL_APIENTRY _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); +static void GL_APIENTRY _es_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawElementsEXT(mode=0x%x)", mode); + return; + } + switch(type) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawElementsEXT(type=0x%x)", type); + return; + } + + _mesa_MultiDrawElementsEXT(mode, count, type, indices, primcount); +} + +extern void GL_APIENTRY _vbo_MultiTexCoord4f(GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +static void GL_APIENTRY _es_MultiTexCoord4f(GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + switch(texture) { + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + case GL_TEXTURE8: + case GL_TEXTURE9: + case GL_TEXTURE10: + case GL_TEXTURE11: + case GL_TEXTURE12: + case GL_TEXTURE13: + case GL_TEXTURE14: + case GL_TEXTURE15: + case GL_TEXTURE16: + case GL_TEXTURE17: + case GL_TEXTURE18: + case GL_TEXTURE19: + case GL_TEXTURE20: + case GL_TEXTURE21: + case GL_TEXTURE22: + case GL_TEXTURE23: + case GL_TEXTURE24: + case GL_TEXTURE25: + case GL_TEXTURE26: + case GL_TEXTURE27: + case GL_TEXTURE28: + case GL_TEXTURE29: + case GL_TEXTURE30: + case GL_TEXTURE31: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiTexCoord4f(texture=0x%x)", texture); + return; + } + + _vbo_MultiTexCoord4f(texture, s, t, r, q); +} + +extern void GL_APIENTRY _vbo_MultiTexCoord4f(GLenum texture, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +static void GL_APIENTRY _es_MultiTexCoord4x(GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q) +{ + GLfloat converted_s; + GLfloat converted_t; + GLfloat converted_r; + GLfloat converted_q; + + switch(texture) { + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + case GL_TEXTURE8: + case GL_TEXTURE9: + case GL_TEXTURE10: + case GL_TEXTURE11: + case GL_TEXTURE12: + case GL_TEXTURE13: + case GL_TEXTURE14: + case GL_TEXTURE15: + case GL_TEXTURE16: + case GL_TEXTURE17: + case GL_TEXTURE18: + case GL_TEXTURE19: + case GL_TEXTURE20: + case GL_TEXTURE21: + case GL_TEXTURE22: + case GL_TEXTURE23: + case GL_TEXTURE24: + case GL_TEXTURE25: + case GL_TEXTURE26: + case GL_TEXTURE27: + case GL_TEXTURE28: + case GL_TEXTURE29: + case GL_TEXTURE30: + case GL_TEXTURE31: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiTexCoord4x(texture=0x%x)", texture); + return; + } + + converted_s = (GLfloat) (s / 65536.0f); + converted_t = (GLfloat) (t / 65536.0f); + converted_r = (GLfloat) (r / 65536.0f); + converted_q = (GLfloat) (q / 65536.0f); + + _vbo_MultiTexCoord4f(texture, converted_s, converted_t, converted_r, converted_q); +} + +extern void GL_APIENTRY _vbo_Normal3f(GLfloat nx, GLfloat ny, GLfloat nz); +#define _es_Normal3f _vbo_Normal3f + +extern void GL_APIENTRY _vbo_Normal3f(GLfloat nx, GLfloat ny, GLfloat nz); +static void GL_APIENTRY _es_Normal3x(GLfixed nx, GLfixed ny, GLfixed nz) +{ + GLfloat converted_nx; + GLfloat converted_ny; + GLfloat converted_nz; + + converted_nx = (GLfloat) (nx / 65536.0f); + converted_ny = (GLfloat) (ny / 65536.0f); + converted_nz = (GLfloat) (nz / 65536.0f); + + _vbo_Normal3f(converted_nx, converted_ny, converted_nz); +} + +extern void GL_APIENTRY _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + switch(type) { + case GL_BYTE: + case GL_SHORT: + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glNormalPointer(type=0x%x)", type); + return; + } + + _mesa_NormalPointer(type, stride, pointer); +} + +extern void GL_APIENTRY _mesa_Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +static void GL_APIENTRY _es_Orthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) +{ + GLdouble converted_left; + GLdouble converted_right; + GLdouble converted_bottom; + GLdouble converted_top; + GLdouble converted_zNear; + GLdouble converted_zFar; + + converted_left = (GLdouble) (left); + converted_right = (GLdouble) (right); + converted_bottom = (GLdouble) (bottom); + converted_top = (GLdouble) (top); + converted_zNear = (GLdouble) (zNear); + converted_zFar = (GLdouble) (zFar); + + _mesa_Ortho(converted_left, converted_right, converted_bottom, converted_top, converted_zNear, converted_zFar); +} + +extern void GL_APIENTRY _mesa_Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +static void GL_APIENTRY _es_Orthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) +{ + GLdouble converted_left; + GLdouble converted_right; + GLdouble converted_bottom; + GLdouble converted_top; + GLdouble converted_zNear; + GLdouble converted_zFar; + + converted_left = (GLdouble) (left / 65536.0); + converted_right = (GLdouble) (right / 65536.0); + converted_bottom = (GLdouble) (bottom / 65536.0); + converted_top = (GLdouble) (top / 65536.0); + converted_zNear = (GLdouble) (zNear / 65536.0); + converted_zFar = (GLdouble) (zFar / 65536.0); + + _mesa_Ortho(converted_left, converted_right, converted_bottom, converted_top, converted_zNear, converted_zFar); +} + +extern void GL_APIENTRY _mesa_PixelStorei(GLenum pname, GLint param); +static void GL_APIENTRY _es_PixelStorei(GLenum pname, GLint param) +{ + switch(pname) { + case GL_PACK_ALIGNMENT: + case GL_UNPACK_ALIGNMENT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPixelStorei(pname=0x%x)", pname); + return; + } + switch(param) { + case 1: + case 2: + case 4: + case 8: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glPixelStorei(param=%d)", param); + return; + } + + _mesa_PixelStorei(pname, param); +} + +extern void GL_APIENTRY _mesa_PointParameterf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_PointParameterf(GLenum pname, GLfloat param) +{ + switch(pname) { + case GL_POINT_SIZE_MIN: + case GL_POINT_SIZE_MAX: + case GL_POINT_FADE_THRESHOLD_SIZE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPointParameterf(pname=0x%x)", pname); + return; + } + + _mesa_PointParameterf(pname, param); +} + +extern void GL_APIENTRY _mesa_PointParameterfv(GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_PointParameterfv(GLenum pname, const GLfloat *params) +{ + switch(pname) { + case GL_POINT_SIZE_MIN: /* size 1 */ + case GL_POINT_SIZE_MAX: /* size 1 */ + case GL_POINT_FADE_THRESHOLD_SIZE: /* size 1 */ + case GL_POINT_DISTANCE_ATTENUATION: /* size 3 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPointParameterfv(pname=0x%x)", pname); + return; + } + + _mesa_PointParameterfv(pname, params); +} + +extern void GL_APIENTRY _mesa_PointParameterf(GLenum pname, GLfloat param); +static void GL_APIENTRY _es_PointParameterx(GLenum pname, GLfixed param) +{ + GLfloat converted_param; + + switch(pname) { + case GL_POINT_SIZE_MIN: + case GL_POINT_SIZE_MAX: + case GL_POINT_FADE_THRESHOLD_SIZE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPointParameterx(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) (param / 65536.0f); + + _mesa_PointParameterf(pname, converted_param); +} + +extern void GL_APIENTRY _mesa_PointParameterfv(GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_PointParameterxv(GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 3; + GLfloat converted_params[3]; + + switch(pname) { + case GL_POINT_SIZE_MIN: + case GL_POINT_SIZE_MAX: + case GL_POINT_FADE_THRESHOLD_SIZE: + n_params = 1; + break; + case GL_POINT_DISTANCE_ATTENUATION: + n_params = 3; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPointParameterxv(pname=0x%x)", pname); + return; + } + + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + + _mesa_PointParameterfv(pname, converted_params); +} + +extern void GL_APIENTRY _mesa_PointSize(GLfloat size); +#define _es_PointSize _mesa_PointSize + +extern void GL_APIENTRY _mesa_PointSizePointer(GLenum type, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + switch(type) { + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPointSizePointerOES(type=0x%x)", type); + return; + } + + _mesa_PointSizePointer(type, stride, pointer); +} + +extern void GL_APIENTRY _mesa_PointSize(GLfloat size); +static void GL_APIENTRY _es_PointSizex(GLfixed size) +{ + GLfloat converted_size; + + converted_size = (GLfloat) (size / 65536.0f); + + _mesa_PointSize(converted_size); +} + +extern void GL_APIENTRY _mesa_PolygonOffset(GLfloat factor, GLfloat units); +#define _es_PolygonOffset _mesa_PolygonOffset + +extern void GL_APIENTRY _mesa_PolygonOffset(GLfloat factor, GLfloat units); +static void GL_APIENTRY _es_PolygonOffsetx(GLfixed factor, GLfixed units) +{ + GLfloat converted_factor; + GLfloat converted_units; + + converted_factor = (GLfloat) (factor / 65536.0f); + converted_units = (GLfloat) (units / 65536.0f); + + _mesa_PolygonOffset(converted_factor, converted_units); +} + +extern void GL_APIENTRY _mesa_PopMatrix(void); +#define _es_PopMatrix _mesa_PopMatrix + +extern void GL_APIENTRY _mesa_PushMatrix(void); +#define _es_PushMatrix _mesa_PushMatrix + +/* this function is special and is defined elsewhere */ +extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed * mantissa, GLint * exponent); +#define _check_QueryMatrixxOES _es_QueryMatrixxOES + +extern void GL_APIENTRY _mesa_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels); +static void GL_APIENTRY _es_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + + _mesa_ReadPixels(x, y, width, height, format, type, pixels); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); +static void GL_APIENTRY _check_RenderbufferStorageOES(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) +{ + switch(target) { + case GL_RENDERBUFFER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glRenderbufferStorageOES(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_DEPTH_COMPONENT16_OES: + case GL_RGBA4_OES: + case GL_RGB5_A1_OES: + case GL_RGB565_OES: + case GL_STENCIL_INDEX8_OES: + case GL_DEPTH_COMPONENT24_OES: + case GL_DEPTH_COMPONENT32_OES: + case GL_RGB8_OES: + case GL_RGBA8_OES: + case GL_STENCIL_INDEX1_OES: + case GL_STENCIL_INDEX4_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glRenderbufferStorageOES(internalFormat=0x%x)", internalFormat); + return; + } + + _es_RenderbufferStorageEXT(target, internalFormat, width, height); +} + +extern void GL_APIENTRY _mesa_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +#define _es_Rotatef _mesa_Rotatef + +extern void GL_APIENTRY _mesa_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +static void GL_APIENTRY _es_Rotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) +{ + GLfloat converted_angle; + GLfloat converted_x; + GLfloat converted_y; + GLfloat converted_z; + + converted_angle = (GLfloat) (angle / 65536.0f); + converted_x = (GLfloat) (x / 65536.0f); + converted_y = (GLfloat) (y / 65536.0f); + converted_z = (GLfloat) (z / 65536.0f); + + _mesa_Rotatef(converted_angle, converted_x, converted_y, converted_z); +} + +extern void GL_APIENTRY _mesa_SampleCoverageARB(GLclampf value, GLboolean invert); +#define _es_SampleCoverage _mesa_SampleCoverageARB + +extern void GL_APIENTRY _mesa_SampleCoverageARB(GLclampf value, GLboolean invert); +static void GL_APIENTRY _es_SampleCoveragex(GLclampx value, GLboolean invert) +{ + GLclampf converted_value; + + converted_value = (GLclampf) (value / 65536.0f); + + _mesa_SampleCoverageARB(converted_value, invert); +} + +extern void GL_APIENTRY _mesa_Scalef(GLfloat x, GLfloat y, GLfloat z); +#define _es_Scalef _mesa_Scalef + +extern void GL_APIENTRY _mesa_Scalef(GLfloat x, GLfloat y, GLfloat z); +static void GL_APIENTRY _es_Scalex(GLfixed x, GLfixed y, GLfixed z) +{ + GLfloat converted_x; + GLfloat converted_y; + GLfloat converted_z; + + converted_x = (GLfloat) (x / 65536.0f); + converted_y = (GLfloat) (y / 65536.0f); + converted_z = (GLfloat) (z / 65536.0f); + + _mesa_Scalef(converted_x, converted_y, converted_z); +} + +extern void GL_APIENTRY _mesa_Scissor(GLint x, GLint y, GLsizei width, GLsizei height); +#define _es_Scissor _mesa_Scissor + +extern void GL_APIENTRY _mesa_ShadeModel(GLenum mode); +static void GL_APIENTRY _es_ShadeModel(GLenum mode) +{ + switch(mode) { + case GL_FLAT: + case GL_SMOOTH: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glShadeModel(mode=0x%x)", mode); + return; + } + + _mesa_ShadeModel(mode); +} + +extern void GL_APIENTRY _mesa_StencilFunc(GLenum func, GLint ref, GLuint mask); +static void GL_APIENTRY _es_StencilFunc(GLenum func, GLint ref, GLuint mask) +{ + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilFunc(func=0x%x)", func); + return; + } + + _mesa_StencilFunc(func, ref, mask); +} + +extern void GL_APIENTRY _mesa_StencilMask(GLuint mask); +#define _es_StencilMask _mesa_StencilMask + +extern void GL_APIENTRY _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass); +static void GL_APIENTRY _es_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + switch(fail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP_OES: + case GL_DECR_WRAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(fail=0x%x)", fail); + return; + } + switch(zfail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP_OES: + case GL_DECR_WRAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(zfail=0x%x)", zfail); + return; + } + switch(zpass) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP_OES: + case GL_DECR_WRAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(zpass=0x%x)", zpass); + return; + } + + _mesa_StencilOp(fail, zfail, zpass); +} + +extern void GL_APIENTRY _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + switch(size) { + case 2: + case 3: + case 4: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexCoordPointer(size=%d)", size); + return; + } + switch(type) { + case GL_BYTE: + case GL_SHORT: + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexCoordPointer(type=0x%x)", type); + return; + } + + _mesa_TexCoordPointer(size, type, stride, pointer); +} + +extern void GL_APIENTRY _mesa_TexEnvf(GLenum target, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_TexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_LOD_BIAS_EXT: + break; + case GL_TEXTURE_ENV_MODE: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_DECAL && param != GL_BLEND && param != GL_ADD && param != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_RGB: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT && param != GL_DOT3_RGB && param != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_ALPHA: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (param != 1.0 && param != 2.0 && param != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + if (param != GL_TEXTURE && param != GL_CONSTANT && param != GL_PRIMARY_COLOR && param != GL_PREVIOUS && param != GL_TEXTURE0 && param != GL_TEXTURE1 && param != GL_TEXTURE2 && param != GL_TEXTURE3 && param != GL_TEXTURE4 && param != GL_TEXTURE5 && param != GL_TEXTURE6 && param != GL_TEXTURE7 && param != GL_TEXTURE8 && param != GL_TEXTURE9 && param != GL_TEXTURE10 && param != GL_TEXTURE11 && param != GL_TEXTURE12 && param != GL_TEXTURE13 && param != GL_TEXTURE14 && param != GL_TEXTURE15 && param != GL_TEXTURE16 && param != GL_TEXTURE17 && param != GL_TEXTURE18 && param != GL_TEXTURE19 && param != GL_TEXTURE20 && param != GL_TEXTURE21 && param != GL_TEXTURE22 && param != GL_TEXTURE23 && param != GL_TEXTURE24 && param != GL_TEXTURE25 && param != GL_TEXTURE26 && param != GL_TEXTURE27 && param != GL_TEXTURE28 && param != GL_TEXTURE29 && param != GL_TEXTURE30 && param != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (param != GL_SRC_COLOR && param != GL_ONE_MINUS_SRC_COLOR && param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvf(pname=0x%x)", pname); + return; + } + + _mesa_TexEnvf(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexEnvfv(GLenum target, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: /* size 1 */ + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_LOD_BIAS_EXT: /* size 1 */ + break; + case GL_TEXTURE_ENV_MODE: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_DECAL && params[0] != GL_BLEND && params[0] != GL_ADD && params[0] != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_RGB: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT && params[0] != GL_DOT3_RGB && params[0] != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_ALPHA: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (params[0] != 1.0 && params[0] != 2.0 && params[0] != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: /* size 1 */ + case GL_SRC1_RGB: /* size 1 */ + case GL_SRC2_RGB: /* size 1 */ + case GL_SRC0_ALPHA: /* size 1 */ + case GL_SRC1_ALPHA: /* size 1 */ + case GL_SRC2_ALPHA: /* size 1 */ + if (params[0] != GL_TEXTURE && params[0] != GL_CONSTANT && params[0] != GL_PRIMARY_COLOR && params[0] != GL_PREVIOUS && params[0] != GL_TEXTURE0 && params[0] != GL_TEXTURE1 && params[0] != GL_TEXTURE2 && params[0] != GL_TEXTURE3 && params[0] != GL_TEXTURE4 && params[0] != GL_TEXTURE5 && params[0] != GL_TEXTURE6 && params[0] != GL_TEXTURE7 && params[0] != GL_TEXTURE8 && params[0] != GL_TEXTURE9 && params[0] != GL_TEXTURE10 && params[0] != GL_TEXTURE11 && params[0] != GL_TEXTURE12 && params[0] != GL_TEXTURE13 && params[0] != GL_TEXTURE14 && params[0] != GL_TEXTURE15 && params[0] != GL_TEXTURE16 && params[0] != GL_TEXTURE17 && params[0] != GL_TEXTURE18 && params[0] != GL_TEXTURE19 && params[0] != GL_TEXTURE20 && params[0] != GL_TEXTURE21 && params[0] != GL_TEXTURE22 && params[0] != GL_TEXTURE23 && params[0] != GL_TEXTURE24 && params[0] != GL_TEXTURE25 && params[0] != GL_TEXTURE26 && params[0] != GL_TEXTURE27 && params[0] != GL_TEXTURE28 && params[0] != GL_TEXTURE29 && params[0] != GL_TEXTURE30 && params[0] != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_RGB: /* size 1 */ + case GL_OPERAND1_RGB: /* size 1 */ + case GL_OPERAND2_RGB: /* size 1 */ + if (params[0] != GL_SRC_COLOR && params[0] != GL_ONE_MINUS_SRC_COLOR && params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_ALPHA: /* size 1 */ + case GL_OPERAND1_ALPHA: /* size 1 */ + case GL_OPERAND2_ALPHA: /* size 1 */ + if (params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_ENV_COLOR: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvfv(pname=0x%x)", pname); + return; + } + + _mesa_TexEnvfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexEnvi(GLenum target, GLenum pname, GLint param); +static void GL_APIENTRY _es_TexEnvi(GLenum target, GLenum pname, GLint param) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_LOD_BIAS_EXT: + break; + case GL_TEXTURE_ENV_MODE: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_DECAL && param != GL_BLEND && param != GL_ADD && param != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_RGB: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT && param != GL_DOT3_RGB && param != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_ALPHA: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (param != 1.0 && param != 2.0 && param != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + if (param != GL_TEXTURE && param != GL_CONSTANT && param != GL_PRIMARY_COLOR && param != GL_PREVIOUS && param != GL_TEXTURE0 && param != GL_TEXTURE1 && param != GL_TEXTURE2 && param != GL_TEXTURE3 && param != GL_TEXTURE4 && param != GL_TEXTURE5 && param != GL_TEXTURE6 && param != GL_TEXTURE7 && param != GL_TEXTURE8 && param != GL_TEXTURE9 && param != GL_TEXTURE10 && param != GL_TEXTURE11 && param != GL_TEXTURE12 && param != GL_TEXTURE13 && param != GL_TEXTURE14 && param != GL_TEXTURE15 && param != GL_TEXTURE16 && param != GL_TEXTURE17 && param != GL_TEXTURE18 && param != GL_TEXTURE19 && param != GL_TEXTURE20 && param != GL_TEXTURE21 && param != GL_TEXTURE22 && param != GL_TEXTURE23 && param != GL_TEXTURE24 && param != GL_TEXTURE25 && param != GL_TEXTURE26 && param != GL_TEXTURE27 && param != GL_TEXTURE28 && param != GL_TEXTURE29 && param != GL_TEXTURE30 && param != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (param != GL_SRC_COLOR && param != GL_ONE_MINUS_SRC_COLOR && param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvi(pname=0x%x)", pname); + return; + } + + _mesa_TexEnvi(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexEnviv(GLenum target, GLenum pname, const GLint * params); +static void GL_APIENTRY _es_TexEnviv(GLenum target, GLenum pname, const GLint *params) +{ + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: /* size 1 */ + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_LOD_BIAS_EXT: /* size 1 */ + break; + case GL_TEXTURE_ENV_MODE: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_DECAL && params[0] != GL_BLEND && params[0] != GL_ADD && params[0] != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_RGB: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT && params[0] != GL_DOT3_RGB && params[0] != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_COMBINE_ALPHA: /* size 1 */ + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (params[0] != 1.0 && params[0] != 2.0 && params[0] != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: /* size 1 */ + case GL_SRC1_RGB: /* size 1 */ + case GL_SRC2_RGB: /* size 1 */ + case GL_SRC0_ALPHA: /* size 1 */ + case GL_SRC1_ALPHA: /* size 1 */ + case GL_SRC2_ALPHA: /* size 1 */ + if (params[0] != GL_TEXTURE && params[0] != GL_CONSTANT && params[0] != GL_PRIMARY_COLOR && params[0] != GL_PREVIOUS && params[0] != GL_TEXTURE0 && params[0] != GL_TEXTURE1 && params[0] != GL_TEXTURE2 && params[0] != GL_TEXTURE3 && params[0] != GL_TEXTURE4 && params[0] != GL_TEXTURE5 && params[0] != GL_TEXTURE6 && params[0] != GL_TEXTURE7 && params[0] != GL_TEXTURE8 && params[0] != GL_TEXTURE9 && params[0] != GL_TEXTURE10 && params[0] != GL_TEXTURE11 && params[0] != GL_TEXTURE12 && params[0] != GL_TEXTURE13 && params[0] != GL_TEXTURE14 && params[0] != GL_TEXTURE15 && params[0] != GL_TEXTURE16 && params[0] != GL_TEXTURE17 && params[0] != GL_TEXTURE18 && params[0] != GL_TEXTURE19 && params[0] != GL_TEXTURE20 && params[0] != GL_TEXTURE21 && params[0] != GL_TEXTURE22 && params[0] != GL_TEXTURE23 && params[0] != GL_TEXTURE24 && params[0] != GL_TEXTURE25 && params[0] != GL_TEXTURE26 && params[0] != GL_TEXTURE27 && params[0] != GL_TEXTURE28 && params[0] != GL_TEXTURE29 && params[0] != GL_TEXTURE30 && params[0] != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_RGB: /* size 1 */ + case GL_OPERAND1_RGB: /* size 1 */ + case GL_OPERAND2_RGB: /* size 1 */ + if (params[0] != GL_SRC_COLOR && params[0] != GL_ONE_MINUS_SRC_COLOR && params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_OPERAND0_ALPHA: /* size 1 */ + case GL_OPERAND1_ALPHA: /* size 1 */ + case GL_OPERAND2_ALPHA: /* size 1 */ + if (params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_ENV_COLOR: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnviv(pname=0x%x)", pname); + return; + } + + _mesa_TexEnviv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexEnvf(GLenum target, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_TexEnvx(GLenum target, GLenum pname, GLfixed param) +{ + GLfloat converted_param; + int convert_param_value = 1; + + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_TEXTURE_LOD_BIAS_EXT: + break; + case GL_TEXTURE_ENV_MODE: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_DECAL && param != GL_BLEND && param != GL_ADD && param != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_COMBINE_RGB: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT && param != GL_DOT3_RGB && param != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_COMBINE_ALPHA: + if (param != GL_REPLACE && param != GL_MODULATE && param != GL_ADD && param != GL_ADD_SIGNED && param != GL_INTERPOLATE && param != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (param != 1.0 && param != 2.0 && param != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnvx(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + if (param != GL_TEXTURE && param != GL_CONSTANT && param != GL_PRIMARY_COLOR && param != GL_PREVIOUS && param != GL_TEXTURE0 && param != GL_TEXTURE1 && param != GL_TEXTURE2 && param != GL_TEXTURE3 && param != GL_TEXTURE4 && param != GL_TEXTURE5 && param != GL_TEXTURE6 && param != GL_TEXTURE7 && param != GL_TEXTURE8 && param != GL_TEXTURE9 && param != GL_TEXTURE10 && param != GL_TEXTURE11 && param != GL_TEXTURE12 && param != GL_TEXTURE13 && param != GL_TEXTURE14 && param != GL_TEXTURE15 && param != GL_TEXTURE16 && param != GL_TEXTURE17 && param != GL_TEXTURE18 && param != GL_TEXTURE19 && param != GL_TEXTURE20 && param != GL_TEXTURE21 && param != GL_TEXTURE22 && param != GL_TEXTURE23 && param != GL_TEXTURE24 && param != GL_TEXTURE25 && param != GL_TEXTURE26 && param != GL_TEXTURE27 && param != GL_TEXTURE28 && param != GL_TEXTURE29 && param != GL_TEXTURE30 && param != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (param != GL_SRC_COLOR && param != GL_ONE_MINUS_SRC_COLOR && param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (param != GL_SRC_ALPHA && param != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvx(pname=0x%x)", pname); + return; + } + + if (convert_param_value) { + converted_param = (GLfloat) (param / 65536.0f); + } else { + converted_param = (GLfloat) param; + } + + _mesa_TexEnvf(target, pname, converted_param); +} + +extern void GL_APIENTRY _mesa_TexEnvfv(GLenum target, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_TexEnvxv(GLenum target, GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(target) { + case GL_POINT_SPRITE_OES: + if (pname != GL_COORD_REPLACE_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_FILTER_CONTROL_EXT: + if (pname != GL_TEXTURE_LOD_BIAS_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(target=0x%x)", target); + return; + } + break; + case GL_TEXTURE_ENV: + if (pname != GL_TEXTURE_ENV_MODE && pname != GL_COMBINE_RGB && pname != GL_COMBINE_ALPHA && pname != GL_RGB_SCALE && pname != GL_ALPHA_SCALE && pname != GL_SRC0_RGB && pname != GL_SRC1_RGB && pname != GL_SRC2_RGB && pname != GL_SRC0_ALPHA && pname != GL_SRC1_ALPHA && pname != GL_SRC2_ALPHA && pname != GL_OPERAND0_RGB && pname != GL_OPERAND1_RGB && pname != GL_OPERAND2_RGB && pname != GL_OPERAND0_ALPHA && pname != GL_OPERAND1_ALPHA && pname != GL_OPERAND2_ALPHA && pname != GL_TEXTURE_ENV_COLOR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(target=0x%x)", target); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_COORD_REPLACE_OES: + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_LOD_BIAS_EXT: + n_params = 1; + break; + case GL_TEXTURE_ENV_MODE: + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_DECAL && params[0] != GL_BLEND && params[0] != GL_ADD && params[0] != GL_COMBINE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_COMBINE_RGB: + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT && params[0] != GL_DOT3_RGB && params[0] != GL_DOT3_RGBA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_COMBINE_ALPHA: + if (params[0] != GL_REPLACE && params[0] != GL_MODULATE && params[0] != GL_ADD && params[0] != GL_ADD_SIGNED && params[0] != GL_INTERPOLATE && params[0] != GL_SUBTRACT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_RGB_SCALE: + case GL_ALPHA_SCALE: + if (params[0] != 1.0 && params[0] != 2.0 && params[0] != 4.0) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexEnvxv(pname=0x%x)", pname); + return; + } + break; + case GL_SRC0_RGB: + case GL_SRC1_RGB: + case GL_SRC2_RGB: + case GL_SRC0_ALPHA: + case GL_SRC1_ALPHA: + case GL_SRC2_ALPHA: + if (params[0] != GL_TEXTURE && params[0] != GL_CONSTANT && params[0] != GL_PRIMARY_COLOR && params[0] != GL_PREVIOUS && params[0] != GL_TEXTURE0 && params[0] != GL_TEXTURE1 && params[0] != GL_TEXTURE2 && params[0] != GL_TEXTURE3 && params[0] != GL_TEXTURE4 && params[0] != GL_TEXTURE5 && params[0] != GL_TEXTURE6 && params[0] != GL_TEXTURE7 && params[0] != GL_TEXTURE8 && params[0] != GL_TEXTURE9 && params[0] != GL_TEXTURE10 && params[0] != GL_TEXTURE11 && params[0] != GL_TEXTURE12 && params[0] != GL_TEXTURE13 && params[0] != GL_TEXTURE14 && params[0] != GL_TEXTURE15 && params[0] != GL_TEXTURE16 && params[0] != GL_TEXTURE17 && params[0] != GL_TEXTURE18 && params[0] != GL_TEXTURE19 && params[0] != GL_TEXTURE20 && params[0] != GL_TEXTURE21 && params[0] != GL_TEXTURE22 && params[0] != GL_TEXTURE23 && params[0] != GL_TEXTURE24 && params[0] != GL_TEXTURE25 && params[0] != GL_TEXTURE26 && params[0] != GL_TEXTURE27 && params[0] != GL_TEXTURE28 && params[0] != GL_TEXTURE29 && params[0] != GL_TEXTURE30 && params[0] != GL_TEXTURE31) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_OPERAND0_RGB: + case GL_OPERAND1_RGB: + case GL_OPERAND2_RGB: + if (params[0] != GL_SRC_COLOR && params[0] != GL_ONE_MINUS_SRC_COLOR && params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_OPERAND0_ALPHA: + case GL_OPERAND1_ALPHA: + case GL_OPERAND2_ALPHA: + if (params[0] != GL_SRC_ALPHA && params[0] != GL_ONE_MINUS_SRC_ALPHA) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_ENV_COLOR: + n_params = 4; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexEnvxv(pname=0x%x)", pname); + return; + } + + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + } else { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + } + + _mesa_TexEnvfv(target, pname, converted_params); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenf(GLenum coord, GLenum pname, GLfloat param); +static void GL_APIENTRY _check_TexGenfOES(GLenum coord, GLenum pname, GLfloat param) +{ + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + if (param != GL_NORMAL_MAP_OES && param != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfOES(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfOES(pname=0x%x)", pname); + return; + } + + _es_TexGenf(coord, pname, param); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenfv(GLenum coord, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _check_TexGenfvOES(GLenum coord, GLenum pname, const GLfloat *params) +{ + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfvOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: /* size 1 */ + if (params[0] != GL_NORMAL_MAP_OES && params[0] != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfvOES(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenfvOES(pname=0x%x)", pname); + return; + } + + _es_TexGenfv(coord, pname, params); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenf(GLenum coord, GLenum pname, GLfloat param); +static void GL_APIENTRY _check_TexGeniOES(GLenum coord, GLenum pname, GLint param) +{ + GLfloat converted_param; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGeniOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + if (param != GL_NORMAL_MAP_OES && param != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGeniOES(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGeniOES(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) param; + + _es_TexGenf(coord, pname, converted_param); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenfv(GLenum coord, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _check_TexGenivOES(GLenum coord, GLenum pname, const GLint *params) +{ + register unsigned int i; + unsigned int n_params = 1; + GLfloat converted_params[1]; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenivOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + if (params[0] != GL_NORMAL_MAP_OES && params[0] != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenivOES(pname=0x%x)", pname); + return; + } + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenivOES(pname=0x%x)", pname); + return; + } + + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + + _es_TexGenfv(coord, pname, converted_params); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenf(GLenum coord, GLenum pname, GLfloat param); +static void GL_APIENTRY _check_TexGenxOES(GLenum coord, GLenum pname, GLfixed param) +{ + GLfloat converted_param; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + if (param != GL_NORMAL_MAP_OES && param != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxOES(pname=0x%x)", pname); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxOES(pname=0x%x)", pname); + return; + } + + converted_param = (GLfloat) param; + + _es_TexGenf(coord, pname, converted_param); +} + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_TexGenfv(GLenum coord, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _check_TexGenxvOES(GLenum coord, GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 1; + GLfloat converted_params[1]; + + switch(coord) { + case GL_TEXTURE_GEN_STR_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxvOES(coord=0x%x)", coord); + return; + } + switch(pname) { + case GL_TEXTURE_GEN_MODE_OES: + if (params[0] != GL_NORMAL_MAP_OES && params[0] != GL_REFLECTION_MAP_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxvOES(pname=0x%x)", pname); + return; + } + n_params = 1; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexGenxvOES(pname=0x%x)", pname); + return; + } + + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + + _es_TexGenfv(coord, pname, converted_params); +} + +extern void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexImage2D(internalFormat=%d)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexImage2D(border=%d)", border); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + + _mesa_TexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR && param != GL_NEAREST_MIPMAP_NEAREST && param != GL_NEAREST_MIPMAP_LINEAR && param != GL_LINEAR_MIPMAP_NEAREST && param != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_GENERATE_MIPMAP: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + + _mesa_TexParameterf(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR && params[0] != GL_NEAREST_MIPMAP_NEAREST && params[0] != GL_NEAREST_MIPMAP_LINEAR && params[0] != GL_LINEAR_MIPMAP_NEAREST && params[0] != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_GENERATE_MIPMAP: /* size 1 */ + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: /* size 1 */ + case GL_TEXTURE_CROP_RECT_OES: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + + _mesa_TexParameterfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexParameteri(GLenum target, GLenum pname, GLint param); +static void GL_APIENTRY _es_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR && param != GL_NEAREST_MIPMAP_NEAREST && param != GL_NEAREST_MIPMAP_LINEAR && param != GL_LINEAR_MIPMAP_NEAREST && param != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_GENERATE_MIPMAP: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + + _mesa_TexParameteri(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint * params); +static void GL_APIENTRY _es_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR && params[0] != GL_NEAREST_MIPMAP_NEAREST && params[0] != GL_NEAREST_MIPMAP_LINEAR && params[0] != GL_LINEAR_MIPMAP_NEAREST && params[0] != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_GENERATE_MIPMAP: /* size 1 */ + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: /* size 1 */ + case GL_TEXTURE_CROP_RECT_OES: /* size 4 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_TexParameteriv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_TexParameterx(GLenum target, GLenum pname, GLfixed param) +{ + GLfloat converted_param; + int convert_param_value = 1; + + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_TEXTURE_MIN_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR && param != GL_NEAREST_MIPMAP_NEAREST && param != GL_NEAREST_MIPMAP_LINEAR && param != GL_LINEAR_MIPMAP_NEAREST && param != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_TEXTURE_MAG_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_GENERATE_MIPMAP: + if (param != GL_TRUE && param != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(pname=0x%x)", pname); + return; + } + convert_param_value = 0; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterx(pname=0x%x)", pname); + return; + } + + if (convert_param_value) { + converted_param = (GLfloat) (param / 65536.0f); + } else { + converted_param = (GLfloat) param; + } + + _mesa_TexParameterf(target, pname, converted_param); +} + +extern void GL_APIENTRY _mesa_TexParameterfv(GLenum target, GLenum pname, GLfloat const * params); +static void GL_APIENTRY _es_TexParameterxv(GLenum target, GLenum pname, const GLfixed *params) +{ + register unsigned int i; + unsigned int n_params = 4; + GLfloat converted_params[4]; + int convert_params_value = 1; + + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_MIN_FILTER: + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR && params[0] != GL_NEAREST_MIPMAP_NEAREST && params[0] != GL_NEAREST_MIPMAP_LINEAR && params[0] != GL_LINEAR_MIPMAP_NEAREST && params[0] != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_MAG_FILTER: + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_GENERATE_MIPMAP: + if (params[0] != GL_TRUE && params[0] != GL_FALSE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(pname=0x%x)", pname); + return; + } + convert_params_value = 0; + n_params = 1; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + n_params = 1; + break; + case GL_TEXTURE_CROP_RECT_OES: + n_params = 4; + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterxv(pname=0x%x)", pname); + return; + } + + if (convert_params_value) { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) (params[i] / 65536.0f); + } + } else { + for (i = 0; i < n_params; i++) { + converted_params[i] = (GLfloat) params[i]; + } + } + + _mesa_TexParameterfv(target, pname, converted_params); +} + +extern void GL_APIENTRY _mesa_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexSubImage2D(target=0x%x)", target); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + + _mesa_TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_Translatef(GLfloat x, GLfloat y, GLfloat z); +#define _es_Translatef _mesa_Translatef + +extern void GL_APIENTRY _mesa_Translatef(GLfloat x, GLfloat y, GLfloat z); +static void GL_APIENTRY _es_Translatex(GLfixed x, GLfixed y, GLfixed z) +{ + GLfloat converted_x; + GLfloat converted_y; + GLfloat converted_z; + + converted_x = (GLfloat) (x / 65536.0f); + converted_y = (GLfloat) (y / 65536.0f); + converted_z = (GLfloat) (z / 65536.0f); + + _mesa_Translatef(converted_x, converted_y, converted_z); +} + +extern GLboolean GL_APIENTRY _mesa_UnmapBufferARB(GLenum target); +static GLboolean GL_APIENTRY _es_UnmapBufferOES(GLenum target) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glUnmapBufferOES(target=0x%x)", target); + return GL_FALSE; + } + + return _mesa_UnmapBufferARB(target); +} + +extern void GL_APIENTRY _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + switch(size) { + case 2: + case 3: + case 4: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glVertexPointer(size=%d)", size); + return; + } + switch(type) { + case GL_BYTE: + case GL_SHORT: + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glVertexPointer(type=0x%x)", type); + return; + } + + _mesa_VertexPointer(size, type, stride, pointer); +} + +extern void GL_APIENTRY _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); +#define _es_Viewport _mesa_Viewport + + +struct _glapi_table * +_mesa_create_exec_table_es1(void) +{ + struct _glapi_table *exec; + exec = _mesa_alloc_dispatch_table(sizeof *exec); + if (exec == NULL) + return NULL; + + + SET_ActiveTexture(exec, _es_ActiveTexture); + SET_AlphaFunc(exec, _es_AlphaFunc); + SET_AlphaFuncx(exec, _es_AlphaFuncx); + SET_BindBuffer(exec, _es_BindBuffer); + SET_BindFramebufferOES(exec, _es_BindFramebufferOES); + SET_BindRenderbufferOES(exec, _es_BindRenderbufferOES); + SET_BindTexture(exec, _es_BindTexture); + SET_BlendEquationOES(exec, _es_BlendEquationOES); + SET_BlendEquationSeparateOES(exec, _es_BlendEquationSeparateOES); + SET_BlendFunc(exec, _es_BlendFunc); + SET_BlendFuncSeparateOES(exec, _es_BlendFuncSeparateOES); + SET_BufferData(exec, _es_BufferData); + SET_BufferSubData(exec, _es_BufferSubData); + SET_CheckFramebufferStatusOES(exec, _es_CheckFramebufferStatusOES); + SET_Clear(exec, _es_Clear); + SET_ClearColor(exec, _es_ClearColor); + SET_ClearColorx(exec, _es_ClearColorx); + SET_ClearDepthf(exec, _es_ClearDepthf); + SET_ClearDepthx(exec, _es_ClearDepthx); + SET_ClearStencil(exec, _es_ClearStencil); + SET_ClientActiveTexture(exec, _es_ClientActiveTexture); + SET_ClipPlanef(exec, _es_ClipPlanef); + SET_ClipPlanex(exec, _es_ClipPlanex); + SET_Color4f(exec, _es_Color4f); + SET_Color4ub(exec, _es_Color4ub); + SET_Color4x(exec, _es_Color4x); + SET_ColorMask(exec, _es_ColorMask); + SET_ColorPointer(exec, _es_ColorPointer); + SET_CompressedTexImage2D(exec, _es_CompressedTexImage2D); + SET_CompressedTexSubImage2D(exec, _es_CompressedTexSubImage2D); + SET_CopyTexImage2D(exec, _es_CopyTexImage2D); + SET_CopyTexSubImage2D(exec, _es_CopyTexSubImage2D); + SET_CullFace(exec, _es_CullFace); + SET_DeleteBuffers(exec, _es_DeleteBuffers); + SET_DeleteFramebuffersOES(exec, _es_DeleteFramebuffersOES); + SET_DeleteRenderbuffersOES(exec, _es_DeleteRenderbuffersOES); + SET_DeleteTextures(exec, _es_DeleteTextures); + SET_DepthFunc(exec, _es_DepthFunc); + SET_DepthMask(exec, _es_DepthMask); + SET_DepthRangef(exec, _es_DepthRangef); + SET_DepthRangex(exec, _es_DepthRangex); + SET_Disable(exec, _es_Disable); + SET_DisableClientState(exec, _es_DisableClientState); + SET_DrawArrays(exec, _es_DrawArrays); + SET_DrawElements(exec, _es_DrawElements); + SET_DrawTexfOES(exec, _es_DrawTexfOES); + SET_DrawTexfvOES(exec, _es_DrawTexfvOES); + SET_DrawTexiOES(exec, _es_DrawTexiOES); + SET_DrawTexivOES(exec, _es_DrawTexivOES); + SET_DrawTexsOES(exec, _es_DrawTexsOES); + SET_DrawTexsvOES(exec, _es_DrawTexsvOES); + SET_DrawTexxOES(exec, _es_DrawTexxOES); + SET_DrawTexxvOES(exec, _es_DrawTexxvOES); + SET_EGLImageTargetRenderbufferStorageOES(exec, _es_EGLImageTargetRenderbufferStorageOES); + SET_EGLImageTargetTexture2DOES(exec, _es_EGLImageTargetTexture2DOES); + SET_Enable(exec, _es_Enable); + SET_EnableClientState(exec, _es_EnableClientState); + SET_Finish(exec, _es_Finish); + SET_Flush(exec, _es_Flush); + SET_Fogf(exec, _es_Fogf); + SET_Fogfv(exec, _es_Fogfv); + SET_Fogx(exec, _es_Fogx); + SET_Fogxv(exec, _es_Fogxv); + SET_FramebufferRenderbufferOES(exec, _es_FramebufferRenderbufferOES); + SET_FramebufferTexture2DOES(exec, _es_FramebufferTexture2DOES); + SET_FrontFace(exec, _es_FrontFace); + SET_Frustumf(exec, _es_Frustumf); + SET_Frustumx(exec, _es_Frustumx); + SET_GenBuffers(exec, _es_GenBuffers); + SET_GenFramebuffersOES(exec, _es_GenFramebuffersOES); + SET_GenRenderbuffersOES(exec, _es_GenRenderbuffersOES); + SET_GenTextures(exec, _es_GenTextures); + SET_GenerateMipmapOES(exec, _es_GenerateMipmapOES); + SET_GetBooleanv(exec, _es_GetBooleanv); + SET_GetBufferParameteriv(exec, _es_GetBufferParameteriv); + SET_GetBufferPointervOES(exec, _es_GetBufferPointervOES); + SET_GetClipPlanef(exec, _es_GetClipPlanef); + SET_GetClipPlanex(exec, _es_GetClipPlanex); + SET_GetError(exec, _es_GetError); + SET_GetFixedv(exec, _es_GetFixedv); + SET_GetFloatv(exec, _es_GetFloatv); + SET_GetFramebufferAttachmentParameterivOES(exec, _es_GetFramebufferAttachmentParameterivOES); + SET_GetIntegerv(exec, _es_GetIntegerv); + SET_GetLightfv(exec, _es_GetLightfv); + SET_GetLightxv(exec, _es_GetLightxv); + SET_GetMaterialfv(exec, _es_GetMaterialfv); + SET_GetMaterialxv(exec, _es_GetMaterialxv); + SET_GetPointerv(exec, _es_GetPointerv); + SET_GetRenderbufferParameterivOES(exec, _es_GetRenderbufferParameterivOES); + SET_GetString(exec, _es_GetString); + SET_GetTexEnvfv(exec, _es_GetTexEnvfv); + SET_GetTexEnviv(exec, _es_GetTexEnviv); + SET_GetTexEnvxv(exec, _es_GetTexEnvxv); + SET_GetTexGenfvOES(exec, _check_GetTexGenfvOES); + SET_GetTexGenivOES(exec, _check_GetTexGenivOES); + SET_GetTexGenxvOES(exec, _check_GetTexGenxvOES); + SET_GetTexParameterfv(exec, _es_GetTexParameterfv); + SET_GetTexParameteriv(exec, _es_GetTexParameteriv); + SET_GetTexParameterxv(exec, _es_GetTexParameterxv); + SET_Hint(exec, _es_Hint); + SET_IsBuffer(exec, _es_IsBuffer); + SET_IsEnabled(exec, _es_IsEnabled); + SET_IsFramebufferOES(exec, _es_IsFramebufferOES); + SET_IsRenderbufferOES(exec, _es_IsRenderbufferOES); + SET_IsTexture(exec, _es_IsTexture); + SET_LightModelf(exec, _es_LightModelf); + SET_LightModelfv(exec, _es_LightModelfv); + SET_LightModelx(exec, _es_LightModelx); + SET_LightModelxv(exec, _es_LightModelxv); + SET_Lightf(exec, _es_Lightf); + SET_Lightfv(exec, _es_Lightfv); + SET_Lightx(exec, _es_Lightx); + SET_Lightxv(exec, _es_Lightxv); + SET_LineWidth(exec, _es_LineWidth); + SET_LineWidthx(exec, _es_LineWidthx); + SET_LoadIdentity(exec, _es_LoadIdentity); + SET_LoadMatrixf(exec, _es_LoadMatrixf); + SET_LoadMatrixx(exec, _es_LoadMatrixx); + SET_LogicOp(exec, _es_LogicOp); + SET_MapBufferOES(exec, _es_MapBufferOES); + SET_Materialf(exec, _es_Materialf); + SET_Materialfv(exec, _es_Materialfv); + SET_Materialx(exec, _es_Materialx); + SET_Materialxv(exec, _es_Materialxv); + SET_MatrixMode(exec, _es_MatrixMode); + SET_MultMatrixf(exec, _es_MultMatrixf); + SET_MultMatrixx(exec, _es_MultMatrixx); + SET_MultiDrawArraysEXT(exec, _es_MultiDrawArraysEXT); + SET_MultiDrawElementsEXT(exec, _es_MultiDrawElementsEXT); + SET_MultiTexCoord4f(exec, _es_MultiTexCoord4f); + SET_MultiTexCoord4x(exec, _es_MultiTexCoord4x); + SET_Normal3f(exec, _es_Normal3f); + SET_Normal3x(exec, _es_Normal3x); + SET_NormalPointer(exec, _es_NormalPointer); + SET_Orthof(exec, _es_Orthof); + SET_Orthox(exec, _es_Orthox); + SET_PixelStorei(exec, _es_PixelStorei); + SET_PointParameterf(exec, _es_PointParameterf); + SET_PointParameterfv(exec, _es_PointParameterfv); + SET_PointParameterx(exec, _es_PointParameterx); + SET_PointParameterxv(exec, _es_PointParameterxv); + SET_PointSize(exec, _es_PointSize); + SET_PointSizePointerOES(exec, _es_PointSizePointerOES); + SET_PointSizex(exec, _es_PointSizex); + SET_PolygonOffset(exec, _es_PolygonOffset); + SET_PolygonOffsetx(exec, _es_PolygonOffsetx); + SET_PopMatrix(exec, _es_PopMatrix); + SET_PushMatrix(exec, _es_PushMatrix); + SET_QueryMatrixxOES(exec, _check_QueryMatrixxOES); + SET_ReadPixels(exec, _es_ReadPixels); + SET_RenderbufferStorageOES(exec, _check_RenderbufferStorageOES); + SET_Rotatef(exec, _es_Rotatef); + SET_Rotatex(exec, _es_Rotatex); + SET_SampleCoverage(exec, _es_SampleCoverage); + SET_SampleCoveragex(exec, _es_SampleCoveragex); + SET_Scalef(exec, _es_Scalef); + SET_Scalex(exec, _es_Scalex); + SET_Scissor(exec, _es_Scissor); + SET_ShadeModel(exec, _es_ShadeModel); + SET_StencilFunc(exec, _es_StencilFunc); + SET_StencilMask(exec, _es_StencilMask); + SET_StencilOp(exec, _es_StencilOp); + SET_TexCoordPointer(exec, _es_TexCoordPointer); + SET_TexEnvf(exec, _es_TexEnvf); + SET_TexEnvfv(exec, _es_TexEnvfv); + SET_TexEnvi(exec, _es_TexEnvi); + SET_TexEnviv(exec, _es_TexEnviv); + SET_TexEnvx(exec, _es_TexEnvx); + SET_TexEnvxv(exec, _es_TexEnvxv); + SET_TexGenfOES(exec, _check_TexGenfOES); + SET_TexGenfvOES(exec, _check_TexGenfvOES); + SET_TexGeniOES(exec, _check_TexGeniOES); + SET_TexGenivOES(exec, _check_TexGenivOES); + SET_TexGenxOES(exec, _check_TexGenxOES); + SET_TexGenxvOES(exec, _check_TexGenxvOES); + SET_TexImage2D(exec, _es_TexImage2D); + SET_TexParameterf(exec, _es_TexParameterf); + SET_TexParameterfv(exec, _es_TexParameterfv); + SET_TexParameteri(exec, _es_TexParameteri); + SET_TexParameteriv(exec, _es_TexParameteriv); + SET_TexParameterx(exec, _es_TexParameterx); + SET_TexParameterxv(exec, _es_TexParameterxv); + SET_TexSubImage2D(exec, _es_TexSubImage2D); + SET_Translatef(exec, _es_Translatef); + SET_Translatex(exec, _es_Translatex); + SET_UnmapBufferOES(exec, _es_UnmapBufferOES); + SET_VertexPointer(exec, _es_VertexPointer); + SET_Viewport(exec, _es_Viewport); + + return exec; +} + +#endif /* FEATURE_ES1 */ diff --git a/lib/libGL/gallium/libmesagallium/generated/api_exec_es2.c b/lib/libGL/gallium/libmesagallium/generated/api_exec_es2.c new file mode 100644 index 000000000..d28291b0e --- /dev/null +++ b/lib/libGL/gallium/libmesagallium/generated/api_exec_es2.c @@ -0,0 +1,2471 @@ +/* DO NOT EDIT ************************************************* + * THIS FILE AUTOMATICALLY GENERATED BY THE es_generator.py SCRIPT + * API specification file: /share/OpenBSD/xenocara/lib/libGL/libmesa/generated/../../../../dist/Mesa/src/mesa/main/APIspec.xml + * GLES version: GLES2.0 + * date: 2011-05-15 15:41:34 + */ + + +#include "GLES2/gl2.h" +#include "GLES2/gl2ext.h" +#include "main/mfeatures.h" + +#if FEATURE_ES2 + + +/* These types are needed for the Mesa veneer, but are not defined in + * the standard GLES headers. + */ +typedef double GLdouble; +typedef double GLclampd; + +/* Mesa error handling requires these */ +extern void *_mesa_get_current_context(void); +extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... ); + +#include "main/compiler.h" +#include "main/api_exec.h" +#include "main/remap.h" + +/* cannot include main/dispatch.h here */ +#ifdef IN_DRI_DRIVER +#define _GLAPI_USE_REMAP_TABLE +#endif +/* glapi uses GLAPIENTRY while GLES headers define GL_APIENTRY */ +#ifndef GLAPIENTRY +#define GLAPIENTRY GL_APIENTRY +#endif +#include "es2api/glapi/glapitable.h" +#include "es2api/glapi/glapioffsets.h" +#include "es2api/glapi/glapidispatch.h" + +#if FEATURE_remap_table + +#if !FEATURE_GL +int driDispatchRemapTable[driDispatchRemapTable_size]; +#endif + +#define need_MESA_remap_table + +#include "es2api/main/remap_helper.h" + +void +_mesa_init_remap_table_es2(void) +{ + _mesa_do_init_remap_table(_mesa_function_pool, + driDispatchRemapTable_size, + MESA_remap_table_functions); +} + +void +_mesa_map_static_functions_es2(void) +{ +} + +#endif + +typedef void (*_glapi_proc)(void); /* generic function pointer */ + +/************************************************************* + * Generated functions begin here + */ + +extern void GL_APIENTRY _mesa_ActiveTextureARB(GLenum texture); +static void GL_APIENTRY _es_ActiveTexture(GLenum texture) +{ + switch(texture) { + case GL_TEXTURE0: + case GL_TEXTURE1: + case GL_TEXTURE2: + case GL_TEXTURE3: + case GL_TEXTURE4: + case GL_TEXTURE5: + case GL_TEXTURE6: + case GL_TEXTURE7: + case GL_TEXTURE8: + case GL_TEXTURE9: + case GL_TEXTURE10: + case GL_TEXTURE11: + case GL_TEXTURE12: + case GL_TEXTURE13: + case GL_TEXTURE14: + case GL_TEXTURE15: + case GL_TEXTURE16: + case GL_TEXTURE17: + case GL_TEXTURE18: + case GL_TEXTURE19: + case GL_TEXTURE20: + case GL_TEXTURE21: + case GL_TEXTURE22: + case GL_TEXTURE23: + case GL_TEXTURE24: + case GL_TEXTURE25: + case GL_TEXTURE26: + case GL_TEXTURE27: + case GL_TEXTURE28: + case GL_TEXTURE29: + case GL_TEXTURE30: + case GL_TEXTURE31: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glActiveTexture(texture=0x%x)", texture); + return; + } + + _mesa_ActiveTextureARB(texture); +} + +extern void GL_APIENTRY _mesa_AttachShader(GLuint program, GLuint shader); +#define _es_AttachShader _mesa_AttachShader + +extern void GL_APIENTRY _mesa_BindAttribLocationARB(GLuint program, GLuint index, const char * name); +#define _es_BindAttribLocation _mesa_BindAttribLocationARB + +extern void GL_APIENTRY _mesa_BindBufferARB(GLenum target, GLuint buffer); +static void GL_APIENTRY _es_BindBuffer(GLenum target, GLuint buffer) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindBuffer(target=0x%x)", target); + return; + } + + _mesa_BindBufferARB(target, buffer); +} + +extern void GL_APIENTRY _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer); +static void GL_APIENTRY _es_BindFramebuffer(GLenum target, GLuint framebuffer) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindFramebuffer(target=0x%x)", target); + return; + } + + _mesa_BindFramebufferEXT(target, framebuffer); +} + +extern void GL_APIENTRY _mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer); +static void GL_APIENTRY _es_BindRenderbuffer(GLenum target, GLuint renderbuffer) +{ + switch(target) { + case GL_RENDERBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindRenderbuffer(target=0x%x)", target); + return; + } + + _mesa_BindRenderbufferEXT(target, renderbuffer); +} + +extern void GL_APIENTRY _mesa_BindTexture(GLenum target, GLuint texture); +static void GL_APIENTRY _es_BindTexture(GLenum target, GLuint texture) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBindTexture(target=0x%x)", target); + return; + } + + _mesa_BindTexture(target, texture); +} + +extern void GL_APIENTRY _mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#define _es_BlendColor _mesa_BlendColor + +extern void GL_APIENTRY _mesa_BlendEquation(GLenum mode); +static void GL_APIENTRY _es_BlendEquation(GLenum mode) +{ + switch(mode) { + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquation(mode=0x%x)", mode); + return; + } + + _mesa_BlendEquation(mode); +} + +extern void GL_APIENTRY _mesa_BlendEquationSeparateEXT(GLenum modeRGB, GLenum modeAlpha); +static void GL_APIENTRY _es_BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ + switch(modeRGB) { + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquationSeparate(modeRGB=0x%x)", modeRGB); + return; + } + switch(modeAlpha) { + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + case GL_MIN_EXT: + case GL_MAX_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendEquationSeparate(modeAlpha=0x%x)", modeAlpha); + return; + } + + _mesa_BlendEquationSeparateEXT(modeRGB, modeAlpha); +} + +extern void GL_APIENTRY _mesa_BlendFunc(GLenum sfactor, GLenum dfactor); +static void GL_APIENTRY _es_BlendFunc(GLenum sfactor, GLenum dfactor) +{ + switch(sfactor) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + case GL_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFunc(sfactor=0x%x)", sfactor); + return; + } + switch(dfactor) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFunc(dfactor=0x%x)", dfactor); + return; + } + + _mesa_BlendFunc(sfactor, dfactor); +} + +extern void GL_APIENTRY _mesa_BlendFuncSeparateEXT(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +static void GL_APIENTRY _es_BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + switch(srcRGB) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparate(srcRGB=0x%x)", srcRGB); + return; + } + switch(dstRGB) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparate(dstRGB=0x%x)", dstRGB); + return; + } + switch(srcAlpha) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA_SATURATE: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparate(srcAlpha=0x%x)", srcAlpha); + return; + } + switch(dstAlpha) { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBlendFuncSeparate(dstAlpha=0x%x)", dstAlpha); + return; + } + + _mesa_BlendFuncSeparateEXT(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +extern void GL_APIENTRY _mesa_BufferDataARB(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); +static void GL_APIENTRY _es_BufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferData(target=0x%x)", target); + return; + } + switch(usage) { + case GL_STATIC_DRAW: + case GL_DYNAMIC_DRAW: + case GL_STREAM_DRAW: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferData(usage=0x%x)", usage); + return; + } + + _mesa_BufferDataARB(target, size, data, usage); +} + +extern void GL_APIENTRY _mesa_BufferSubDataARB(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data); +static void GL_APIENTRY _es_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glBufferSubData(target=0x%x)", target); + return; + } + + _mesa_BufferSubDataARB(target, offset, size, data); +} + +extern GLenum GL_APIENTRY _mesa_CheckFramebufferStatusEXT(GLenum target); +static GLenum GL_APIENTRY _es_CheckFramebufferStatus(GLenum target) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCheckFramebufferStatus(target=0x%x)", target); + return (GLenum) 0; + } + + return _mesa_CheckFramebufferStatusEXT(target); +} + +extern void GL_APIENTRY _mesa_Clear(GLbitfield mask); +static void GL_APIENTRY _es_Clear(GLbitfield mask) +{ + switch(mask) { + case 0: + case (GL_COLOR_BUFFER_BIT): + case (GL_DEPTH_BUFFER_BIT): + case (GL_STENCIL_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + case (GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT): + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glClear(mask=0x%x)", mask); + return; + } + + _mesa_Clear(mask); +} + +extern void GL_APIENTRY _mesa_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#define _es_ClearColor _mesa_ClearColor + +extern void GL_APIENTRY _mesa_ClearDepthf(GLclampf depth); +#define _es_ClearDepthf _mesa_ClearDepthf + +extern void GL_APIENTRY _mesa_ClearStencil(GLint s); +#define _es_ClearStencil _mesa_ClearStencil + +extern void GL_APIENTRY _mesa_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#define _es_ColorMask _mesa_ColorMask + +extern void GL_APIENTRY _mesa_CompileShaderARB(GLuint shader); +#define _es_CompileShader _mesa_CompileShaderARB + +extern void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_PALETTE4_RGB8_OES: + case GL_PALETTE4_RGBA8_OES: + case GL_PALETTE4_R5_G6_B5_OES: + case GL_PALETTE4_RGBA4_OES: + case GL_PALETTE4_RGB5_A1_OES: + case GL_PALETTE8_RGB8_OES: + case GL_PALETTE8_RGBA8_OES: + case GL_PALETTE8_R5_G6_B5_OES: + case GL_PALETTE8_RGBA4_OES: + case GL_PALETTE8_RGB5_A1_OES: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexImage2D(internalFormat=0x%x)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCompressedTexImage2D(border=%d)", border); + return; + } + + _mesa_CompressedTexImage2DARB(target, level, internalFormat, width, height, border, imageSize, data); +} + +extern void GL_APIENTRY _mesa_CompressedTexImage3DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexImage3DOES(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexImage3DOES(target=0x%x)", target); + return; + } + + _mesa_CompressedTexImage3DARB(target, level, internalFormat, width, height, depth, border, imagesize, data); +} + +extern void GL_APIENTRY _mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexSubImage2D(target=0x%x)", target); + return; + } + switch(format) { + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexSubImage2D(format=0x%x)", format); + return; + } + + _mesa_CompressedTexSubImage2DARB(target, level, xoffset, yoffset, width, height, format, imageSize, data); +} + +extern void GL_APIENTRY _mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid * data); +static void GL_APIENTRY _es_CompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data) +{ + switch(target) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCompressedTexSubImage3DOES(target=0x%x)", target); + return; + } + + _mesa_CompressedTexSubImage3DARB(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imagesize, data); +} + +extern void GL_APIENTRY _mesa_CopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +static void GL_APIENTRY _es_CopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCopyTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCopyTexImage2D(internalFormat=0x%x)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glCopyTexImage2D(border=%d)", border); + return; + } + + _mesa_CopyTexImage2D(target, level, internalFormat, x, y, width, height, border); +} + +extern void GL_APIENTRY _mesa_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +static void GL_APIENTRY _es_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCopyTexSubImage2D(target=0x%x)", target); + return; + } + + _mesa_CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); +} + +extern void GL_APIENTRY _mesa_CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +static void GL_APIENTRY _es_CopyTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) +{ + switch(target) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCopyTexSubImage3DOES(target=0x%x)", target); + return; + } + + _mesa_CopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height); +} + +extern GLuint GL_APIENTRY _mesa_CreateProgram(void); +#define _es_CreateProgram _mesa_CreateProgram + +extern GLuint GL_APIENTRY _mesa_CreateShader(GLenum type); +static GLuint GL_APIENTRY _es_CreateShader(GLenum type) +{ + switch(type) { + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCreateShader(type=0x%x)", type); + return (GLuint) 0; + } + + return _mesa_CreateShader(type); +} + +extern void GL_APIENTRY _mesa_CullFace(GLenum mode); +static void GL_APIENTRY _es_CullFace(GLenum mode) +{ + switch(mode) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glCullFace(mode=0x%x)", mode); + return; + } + + _mesa_CullFace(mode); +} + +extern void GL_APIENTRY _mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer); +#define _es_DeleteBuffers _mesa_DeleteBuffersARB + +extern void GL_APIENTRY _mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers); +#define _es_DeleteFramebuffers _mesa_DeleteFramebuffersEXT + +extern void GL_APIENTRY _mesa_DeleteProgram(GLuint program); +#define _es_DeleteProgram _mesa_DeleteProgram + +extern void GL_APIENTRY _mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers); +#define _es_DeleteRenderbuffers _mesa_DeleteRenderbuffersEXT + +extern void GL_APIENTRY _mesa_DeleteShader(GLuint shader); +#define _es_DeleteShader _mesa_DeleteShader + +extern void GL_APIENTRY _mesa_DeleteTextures(GLsizei n, const GLuint * textures); +#define _es_DeleteTextures _mesa_DeleteTextures + +extern void GL_APIENTRY _mesa_DepthFunc(GLenum func); +static void GL_APIENTRY _es_DepthFunc(GLenum func) +{ + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDepthFunc(func=0x%x)", func); + return; + } + + _mesa_DepthFunc(func); +} + +extern void GL_APIENTRY _mesa_DepthMask(GLboolean flag); +#define _es_DepthMask _mesa_DepthMask + +extern void GL_APIENTRY _mesa_DepthRangef(GLclampf zNear, GLclampf zFar); +#define _es_DepthRangef _mesa_DepthRangef + +extern void GL_APIENTRY _mesa_DetachShader(GLuint program, GLuint shader); +#define _es_DetachShader _mesa_DetachShader + +extern void GL_APIENTRY _mesa_Disable(GLenum cap); +static void GL_APIENTRY _es_Disable(GLenum cap) +{ + switch(cap) { + case GL_CULL_FACE: + case GL_SCISSOR_TEST: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_BLEND: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDisable(cap=0x%x)", cap); + return; + } + + _mesa_Disable(cap); +} + +extern void GL_APIENTRY _mesa_DisableVertexAttribArrayARB(GLuint index); +#define _es_DisableVertexAttribArray _mesa_DisableVertexAttribArrayARB + +extern void GL_APIENTRY _mesa_DrawArrays(GLenum mode, GLint first, GLsizei count); +static void GL_APIENTRY _es_DrawArrays(GLenum mode, GLint first, GLsizei count) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawArrays(mode=0x%x)", mode); + return; + } + + _mesa_DrawArrays(mode, first, count); +} + +extern void GL_APIENTRY _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices); +static void GL_APIENTRY _es_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawElements(mode=0x%x)", mode); + return; + } + switch(type) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glDrawElements(type=0x%x)", type); + return; + } + + _mesa_DrawElements(mode, count, type, indices); +} + +extern void GL_APIENTRY _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image); +static void GL_APIENTRY _es_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image) +{ + switch(target) { + case GL_RENDERBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEGLImageTargetRenderbufferStorageOES(target=0x%x)", target); + return; + } + + _mesa_EGLImageTargetRenderbufferStorageOES(target, image); +} + +extern void GL_APIENTRY _mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image); +static void GL_APIENTRY _es_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + switch(target) { + case GL_TEXTURE_2D: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEGLImageTargetTexture2DOES(target=0x%x)", target); + return; + } + + _mesa_EGLImageTargetTexture2DOES(target, image); +} + +extern void GL_APIENTRY _mesa_Enable(GLenum cap); +static void GL_APIENTRY _es_Enable(GLenum cap) +{ + switch(cap) { + case GL_CULL_FACE: + case GL_SCISSOR_TEST: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_BLEND: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glEnable(cap=0x%x)", cap); + return; + } + + _mesa_Enable(cap); +} + +extern void GL_APIENTRY _mesa_EnableVertexAttribArrayARB(GLuint index); +#define _es_EnableVertexAttribArray _mesa_EnableVertexAttribArrayARB + +extern void GL_APIENTRY _mesa_Finish(void); +#define _es_Finish _mesa_Finish + +extern void GL_APIENTRY _mesa_Flush(void); +#define _es_Flush _mesa_Flush + +extern void GL_APIENTRY _mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +static void GL_APIENTRY _es_FramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbuffer(target=0x%x)", target); + return; + } + switch(attachment) { + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbuffer(attachment=0x%x)", attachment); + return; + } + switch(renderbuffertarget) { + case GL_RENDERBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferRenderbuffer(renderbuffertarget=0x%x)", renderbuffertarget); + return; + } + + _mesa_FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer); +} + +extern void GL_APIENTRY _mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +static void GL_APIENTRY _es_FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture2D(target=0x%x)", target); + return; + } + switch(attachment) { + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture2D(attachment=0x%x)", attachment); + return; + } + switch(textarget) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glFramebufferTexture2D(textarget=0x%x)", textarget); + return; + } + + _mesa_FramebufferTexture2DEXT(target, attachment, textarget, texture, level); +} + +extern void GL_APIENTRY _mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +static void GL_APIENTRY _es_FramebufferTexture3DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture3DOES(target=0x%x)", target); + return; + } + switch(attachment) { + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFramebufferTexture3DOES(attachment=0x%x)", attachment); + return; + } + switch(textarget) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glFramebufferTexture3DOES(textarget=0x%x)", textarget); + return; + } + + _mesa_FramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset); +} + +extern void GL_APIENTRY _mesa_FrontFace(GLenum mode); +static void GL_APIENTRY _es_FrontFace(GLenum mode) +{ + switch(mode) { + case GL_CW: + case GL_CCW: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glFrontFace(mode=0x%x)", mode); + return; + } + + _mesa_FrontFace(mode); +} + +extern void GL_APIENTRY _mesa_GenBuffersARB(GLsizei n, GLuint * buffer); +#define _es_GenBuffers _mesa_GenBuffersARB + +extern void GL_APIENTRY _mesa_GenFramebuffersEXT(GLsizei n, GLuint * ids); +#define _es_GenFramebuffers _mesa_GenFramebuffersEXT + +extern void GL_APIENTRY _mesa_GenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers); +#define _es_GenRenderbuffers _mesa_GenRenderbuffersEXT + +extern void GL_APIENTRY _mesa_GenTextures(GLsizei n, GLuint * textures); +#define _es_GenTextures _mesa_GenTextures + +extern void GL_APIENTRY _mesa_GenerateMipmapEXT(GLenum target); +static void GL_APIENTRY _es_GenerateMipmap(GLenum target) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGenerateMipmap(target=0x%x)", target); + return; + } + + _mesa_GenerateMipmapEXT(target); +} + +extern void GL_APIENTRY _mesa_GetActiveAttribARB(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +#define _es_GetActiveAttrib _mesa_GetActiveAttribARB + +extern void GL_APIENTRY _mesa_GetActiveUniformARB(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +#define _es_GetActiveUniform _mesa_GetActiveUniformARB + +extern void GL_APIENTRY _mesa_GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); +#define _es_GetAttachedShaders _mesa_GetAttachedShaders + +extern GLint GL_APIENTRY _mesa_GetAttribLocationARB(GLuint program, const char * name); +#define _es_GetAttribLocation _mesa_GetAttribLocationARB + +extern void GL_APIENTRY _mesa_GetBooleanv(GLenum pname, GLboolean * params); +#define _es_GetBooleanv _mesa_GetBooleanv + +extern void GL_APIENTRY _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_BUFFER_SIZE: + case GL_BUFFER_USAGE: + case GL_BUFFER_ACCESS_OES: + case GL_BUFFER_MAPPED_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetBufferParameterivARB(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid ** params); +static void GL_APIENTRY _es_GetBufferPointervOES(GLenum target, GLenum pname, GLvoid **params) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferPointervOES(target=0x%x)", target); + return; + } + switch(pname) { + case GL_BUFFER_MAP_POINTER_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetBufferPointervOES(pname=0x%x)", pname); + return; + } + + _mesa_GetBufferPointervARB(target, pname, params); +} + +extern GLenum GL_APIENTRY _mesa_GetError(void); +#define _es_GetError _mesa_GetError + +extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat * params); +#define _es_GetFloatv _mesa_GetFloatv + +extern void GL_APIENTRY _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params) +{ + switch(target) { + case GL_FRAMEBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetFramebufferAttachmentParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: /* size 1 */ + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetFramebufferAttachmentParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetFramebufferAttachmentParameterivEXT(target, attachment, pname, params); +} + +extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint * params); +#define _es_GetIntegerv _mesa_GetIntegerv + +extern void GL_APIENTRY _mesa_GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +#define _es_GetProgramInfoLog _mesa_GetProgramInfoLog + +extern void GL_APIENTRY _mesa_GetProgramiv(GLuint program, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetProgramiv(GLuint program, GLenum pname, GLint *params) +{ + switch(pname) { + case GL_DELETE_STATUS: + case GL_LINK_STATUS: + case GL_VALIDATE_STATUS: + case GL_INFO_LOG_LENGTH: + case GL_ATTACHED_SHADERS: + case GL_ACTIVE_ATTRIBUTES: + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + case GL_ACTIVE_UNIFORMS: + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetProgramiv(pname=0x%x)", pname); + return; + } + + _mesa_GetProgramiv(program, pname, params); +} + +extern void GL_APIENTRY _mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_RENDERBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetRenderbufferParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_RENDERBUFFER_WIDTH: /* size 1 */ + case GL_RENDERBUFFER_HEIGHT: /* size 1 */ + case GL_RENDERBUFFER_INTERNAL_FORMAT: /* size 1 */ + case GL_RENDERBUFFER_RED_SIZE: /* size 1 */ + case GL_RENDERBUFFER_GREEN_SIZE: /* size 1 */ + case GL_RENDERBUFFER_BLUE_SIZE: /* size 1 */ + case GL_RENDERBUFFER_ALPHA_SIZE: /* size 1 */ + case GL_RENDERBUFFER_DEPTH_SIZE: /* size 1 */ + case GL_RENDERBUFFER_STENCIL_SIZE: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetRenderbufferParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetRenderbufferParameterivEXT(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +#define _es_GetShaderInfoLog _mesa_GetShaderInfoLog + +extern void GL_APIENTRY _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint * range, GLint * precision); +static void GL_APIENTRY _es_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision) +{ + switch(shadertype) { + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetShaderPrecisionFormat(shadertype=0x%x)", shadertype); + return; + } + switch(precisiontype) { + case GL_LOW_FLOAT: + case GL_MEDIUM_FLOAT: + case GL_HIGH_FLOAT: + case GL_LOW_INT: + case GL_MEDIUM_INT: + case GL_HIGH_INT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetShaderPrecisionFormat(precisiontype=0x%x)", precisiontype); + return; + } + + _mesa_GetShaderPrecisionFormat(shadertype, precisiontype, range, precision); +} + +extern void GL_APIENTRY _mesa_GetShaderSourceARB(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); +#define _es_GetShaderSource _mesa_GetShaderSourceARB + +extern void GL_APIENTRY _mesa_GetShaderiv(GLuint shader, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetShaderiv(GLuint shader, GLenum pname, GLint *params) +{ + switch(pname) { + case GL_SHADER_TYPE: + case GL_COMPILE_STATUS: + case GL_DELETE_STATUS: + case GL_INFO_LOG_LENGTH: + case GL_SHADER_SOURCE_LENGTH: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetShaderiv(pname=0x%x)", pname); + return; + } + + _mesa_GetShaderiv(shader, pname, params); +} + +extern const GLubyte * GL_APIENTRY _mesa_GetString(GLenum name); +static const GLubyte * GL_APIENTRY _es_GetString(GLenum name) +{ + switch(name) { + case GL_VENDOR: + case GL_RENDERER: + case GL_VERSION: + case GL_EXTENSIONS: + case GL_SHADING_LANGUAGE_VERSION: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetString(name=0x%x)", name); + return (const GLubyte *) 0; + } + + return _mesa_GetString(name); +} + +extern void GL_APIENTRY _mesa_GetTexParameterfv(GLenum target, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_WRAP_R_OES: /* size 1 */ + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexParameterfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_GetTexParameteriv(GLenum target, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_WRAP_R_OES: /* size 1 */ + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_GetTexParameteriv(target, pname, params); +} + +extern GLint GL_APIENTRY _mesa_GetUniformLocationARB(GLuint program, const char * name); +#define _es_GetUniformLocation _mesa_GetUniformLocationARB + +extern void GL_APIENTRY _mesa_GetUniformfvARB(GLuint program, GLint location, GLfloat * params); +#define _es_GetUniformfv _mesa_GetUniformfvARB + +extern void GL_APIENTRY _mesa_GetUniformivARB(GLuint program, GLint location, GLint * params); +#define _es_GetUniformiv _mesa_GetUniformivARB + +extern void GL_APIENTRY _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid ** pointer); +static void GL_APIENTRY _es_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer) +{ + switch(pname) { + case GL_VERTEX_ATTRIB_ARRAY_POINTER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetVertexAttribPointerv(pname=0x%x)", pname); + return; + } + + _mesa_GetVertexAttribPointervARB(index, pname, pointer); +} + +extern void GL_APIENTRY _mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat * params); +static void GL_APIENTRY _es_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params) +{ + switch(pname) { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_SIZE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_TYPE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: /* size 1 */ + case GL_CURRENT_VERTEX_ATTRIB: /* size 16? */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetVertexAttribfv(pname=0x%x)", pname); + return; + } + + _mesa_GetVertexAttribfvARB(index, pname, params); +} + +extern void GL_APIENTRY _mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint * params); +static void GL_APIENTRY _es_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params) +{ + switch(pname) { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_SIZE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_TYPE: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: /* size 1 */ + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: /* size 1 */ + case GL_CURRENT_VERTEX_ATTRIB: /* size 16? */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glGetVertexAttribiv(pname=0x%x)", pname); + return; + } + + _mesa_GetVertexAttribivARB(index, pname, params); +} + +extern void GL_APIENTRY _mesa_Hint(GLenum target, GLenum mode); +static void GL_APIENTRY _es_Hint(GLenum target, GLenum mode) +{ + switch(target) { + case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: + case GL_GENERATE_MIPMAP_HINT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glHint(target=0x%x)", target); + return; + } + switch(mode) { + case GL_FASTEST: + case GL_NICEST: + case GL_DONT_CARE: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glHint(mode=0x%x)", mode); + return; + } + + _mesa_Hint(target, mode); +} + +extern GLboolean GL_APIENTRY _mesa_IsBufferARB(GLuint buffer); +#define _es_IsBuffer _mesa_IsBufferARB + +extern GLboolean GL_APIENTRY _mesa_IsEnabled(GLenum cap); +static GLboolean GL_APIENTRY _es_IsEnabled(GLenum cap) +{ + switch(cap) { + case GL_CULL_FACE: + case GL_SCISSOR_TEST: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_STENCIL_TEST: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_BLEND: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glIsEnabled(cap=0x%x)", cap); + return GL_FALSE; + } + + return _mesa_IsEnabled(cap); +} + +extern GLboolean GL_APIENTRY _mesa_IsFramebufferEXT(GLuint framebuffer); +#define _es_IsFramebuffer _mesa_IsFramebufferEXT + +extern GLboolean GL_APIENTRY _mesa_IsProgram(GLuint program); +#define _es_IsProgram _mesa_IsProgram + +extern GLboolean GL_APIENTRY _mesa_IsRenderbufferEXT(GLuint renderbuffer); +#define _es_IsRenderbuffer _mesa_IsRenderbufferEXT + +extern GLboolean GL_APIENTRY _mesa_IsShader(GLuint shader); +#define _es_IsShader _mesa_IsShader + +extern GLboolean GL_APIENTRY _mesa_IsTexture(GLuint texture); +#define _es_IsTexture _mesa_IsTexture + +extern void GL_APIENTRY _mesa_LineWidth(GLfloat width); +#define _es_LineWidth _mesa_LineWidth + +extern void GL_APIENTRY _mesa_LinkProgramARB(GLuint program); +#define _es_LinkProgram _mesa_LinkProgramARB + +extern void * GL_APIENTRY _mesa_MapBufferARB(GLenum target, GLenum access); +static void * GL_APIENTRY _es_MapBufferOES(GLenum target, GLenum access) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMapBufferOES(target=0x%x)", target); + return (void *) 0; + } + switch(access) { + case GL_WRITE_ONLY_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMapBufferOES(access=0x%x)", access); + return (void *) 0; + } + + return _mesa_MapBufferARB(target, access); +} + +extern void GL_APIENTRY _mesa_MultiDrawArraysEXT(GLenum mode, const GLint * first, const GLsizei * count, GLsizei primcount); +static void GL_APIENTRY _es_MultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawArraysEXT(mode=0x%x)", mode); + return; + } + + _mesa_MultiDrawArraysEXT(mode, first, count, primcount); +} + +extern void GL_APIENTRY _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); +static void GL_APIENTRY _es_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount) +{ + switch(mode) { + case GL_POINTS: + case GL_LINES: + case GL_LINE_LOOP: + case GL_LINE_STRIP: + case GL_TRIANGLES: + case GL_TRIANGLE_STRIP: + case GL_TRIANGLE_FAN: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawElementsEXT(mode=0x%x)", mode); + return; + } + switch(type) { + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: + case GL_UNSIGNED_INT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glMultiDrawElementsEXT(type=0x%x)", type); + return; + } + + _mesa_MultiDrawElementsEXT(mode, count, type, indices, primcount); +} + +extern void GL_APIENTRY _mesa_PixelStorei(GLenum pname, GLint param); +static void GL_APIENTRY _es_PixelStorei(GLenum pname, GLint param) +{ + switch(pname) { + case GL_PACK_ALIGNMENT: + case GL_UNPACK_ALIGNMENT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glPixelStorei(pname=0x%x)", pname); + return; + } + switch(param) { + case 1: + case 2: + case 4: + case 8: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glPixelStorei(param=%d)", param); + return; + } + + _mesa_PixelStorei(pname, param); +} + +extern void GL_APIENTRY _mesa_PolygonOffset(GLfloat factor, GLfloat units); +#define _es_PolygonOffset _mesa_PolygonOffset + +extern void GL_APIENTRY _mesa_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels); +static void GL_APIENTRY _es_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glReadPixels(format=0x%x)", format); + return; + } + + _mesa_ReadPixels(x, y, width, height, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_ReleaseShaderCompiler(void); +#define _es_ReleaseShaderCompiler _mesa_ReleaseShaderCompiler + +/* this function is special and is defined elsewhere */ +extern void GL_APIENTRY _es_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height); +static void GL_APIENTRY _check_RenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) +{ + switch(target) { + case GL_RENDERBUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glRenderbufferStorage(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_DEPTH_COMPONENT16: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGB565: + case GL_STENCIL_INDEX8: + case GL_DEPTH_COMPONENT24_OES: + case GL_DEPTH_COMPONENT32_OES: + case GL_RGB8_OES: + case GL_RGBA8_OES: + case GL_STENCIL_INDEX1_OES: + case GL_STENCIL_INDEX4_OES: + case GL_DEPTH24_STENCIL8_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glRenderbufferStorage(internalFormat=0x%x)", internalFormat); + return; + } + + _es_RenderbufferStorageEXT(target, internalFormat, width, height); +} + +extern void GL_APIENTRY _mesa_SampleCoverageARB(GLclampf value, GLboolean invert); +#define _es_SampleCoverage _mesa_SampleCoverageARB + +extern void GL_APIENTRY _mesa_Scissor(GLint x, GLint y, GLsizei width, GLsizei height); +#define _es_Scissor _mesa_Scissor + +extern void GL_APIENTRY _mesa_ShaderBinary(GLsizei n, const GLuint * shaders, GLenum binaryformat, const GLvoid * binary, GLsizei length); +#define _es_ShaderBinary _mesa_ShaderBinary + +extern void GL_APIENTRY _mesa_ShaderSourceARB(GLuint shader, GLsizei count, const GLchar ** string, const int * length); +#define _es_ShaderSource _mesa_ShaderSourceARB + +extern void GL_APIENTRY _mesa_StencilFunc(GLenum func, GLint ref, GLuint mask); +static void GL_APIENTRY _es_StencilFunc(GLenum func, GLint ref, GLuint mask) +{ + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilFunc(func=0x%x)", func); + return; + } + + _mesa_StencilFunc(func, ref, mask); +} + +extern void GL_APIENTRY _mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); +static void GL_APIENTRY _es_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + switch(face) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilFuncSeparate(face=0x%x)", face); + return; + } + switch(func) { + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilFuncSeparate(func=0x%x)", func); + return; + } + + _mesa_StencilFuncSeparate(face, func, ref, mask); +} + +extern void GL_APIENTRY _mesa_StencilMask(GLuint mask); +#define _es_StencilMask _mesa_StencilMask + +extern void GL_APIENTRY _mesa_StencilMaskSeparate(GLenum face, GLuint mask); +static void GL_APIENTRY _es_StencilMaskSeparate(GLenum face, GLuint mask) +{ + switch(face) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilMaskSeparate(face=0x%x)", face); + return; + } + + _mesa_StencilMaskSeparate(face, mask); +} + +extern void GL_APIENTRY _mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass); +static void GL_APIENTRY _es_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + switch(fail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(fail=0x%x)", fail); + return; + } + switch(zfail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(zfail=0x%x)", zfail); + return; + } + switch(zpass) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOp(zpass=0x%x)", zpass); + return; + } + + _mesa_StencilOp(fail, zfail, zpass); +} + +extern void GL_APIENTRY _mesa_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +static void GL_APIENTRY _es_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + switch(face) { + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOpSeparate(face=0x%x)", face); + return; + } + switch(fail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOpSeparate(fail=0x%x)", fail); + return; + } + switch(zfail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOpSeparate(zfail=0x%x)", zfail); + return; + } + switch(zpass) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: + case GL_INCR_WRAP: + case GL_DECR_WRAP: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glStencilOpSeparate(zpass=0x%x)", zpass); + return; + } + + _mesa_StencilOpSeparate(face, fail, zfail, zpass); +} + +extern void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexImage2D(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexImage2D(internalFormat=%d)", internalFormat); + return; + } + switch(border) { + case 0: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glTexImage2D(border=%d)", border); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1 && type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_DEPTH_COMPONENT: + if (type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + case GL_DEPTH_STENCIL_OES: + if (type != GL_UNSIGNED_INT_24_8_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage2D(format=0x%x)", format); + return; + } + + _mesa_TexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_TexImage3D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexImage3DOES(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexImage3DOES(target=0x%x)", target); + return; + } + switch(internalFormat) { + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexImage3DOES(internalFormat=0x%x)", internalFormat); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1 && type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage3DOES(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexImage3DOES(format=0x%x)", format); + return; + } + + _mesa_TexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param); +static void GL_APIENTRY _es_TexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R_OES: + if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR && param != GL_NEAREST_MIPMAP_NEAREST && param != GL_NEAREST_MIPMAP_LINEAR && param != GL_LINEAR_MIPMAP_NEAREST && param != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterf(pname=0x%x)", pname); + return; + } + + _mesa_TexParameterf(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat * params); +static void GL_APIENTRY _es_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_WRAP_R_OES: /* size 1 */ + if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR && params[0] != GL_NEAREST_MIPMAP_NEAREST && params[0] != GL_NEAREST_MIPMAP_LINEAR && params[0] != GL_LINEAR_MIPMAP_NEAREST && params[0] != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameterfv(pname=0x%x)", pname); + return; + } + + _mesa_TexParameterfv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexParameteri(GLenum target, GLenum pname, GLint param); +static void GL_APIENTRY _es_TexParameteri(GLenum target, GLenum pname, GLint param) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + case GL_TEXTURE_WRAP_R_OES: + if (param != GL_CLAMP_TO_EDGE && param != GL_REPEAT && param != GL_MIRRORED_REPEAT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR && param != GL_NEAREST_MIPMAP_NEAREST && param != GL_NEAREST_MIPMAP_LINEAR && param != GL_LINEAR_MIPMAP_NEAREST && param != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: + if (param != GL_NEAREST && param != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteri(pname=0x%x)", pname); + return; + } + + _mesa_TexParameteri(target, pname, param); +} + +extern void GL_APIENTRY _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint * params); +static void GL_APIENTRY _es_TexParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(target=0x%x)", target); + return; + } + switch(pname) { + case GL_TEXTURE_WRAP_S: /* size 1 */ + case GL_TEXTURE_WRAP_T: /* size 1 */ + case GL_TEXTURE_WRAP_R_OES: /* size 1 */ + if (params[0] != GL_CLAMP_TO_EDGE && params[0] != GL_REPEAT && params[0] != GL_MIRRORED_REPEAT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MIN_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR && params[0] != GL_NEAREST_MIPMAP_NEAREST && params[0] != GL_NEAREST_MIPMAP_LINEAR && params[0] != GL_LINEAR_MIPMAP_NEAREST && params[0] != GL_LINEAR_MIPMAP_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAG_FILTER: /* size 1 */ + if (params[0] != GL_NEAREST && params[0] != GL_LINEAR) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: /* size 1 */ + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexParameteriv(pname=0x%x)", pname); + return; + } + + _mesa_TexParameteriv(target, pname, params); +} + +extern void GL_APIENTRY _mesa_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexSubImage2D(target=0x%x)", target); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1 && type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_DEPTH_COMPONENT: + if (type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + case GL_DEPTH_STENCIL_OES: + if (type != GL_UNSIGNED_INT_24_8_OES) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage2D(format=0x%x)", format); + return; + } + + _mesa_TexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels); +static void GL_APIENTRY _es_TexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels) +{ + switch(target) { + case GL_TEXTURE_3D_OES: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glTexSubImage3DOES(target=0x%x)", target); + return; + } + switch(format) { + case GL_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_RGB: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_5_6_5) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_RGBA: + if (type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT_4_4_4_4 && type != GL_UNSIGNED_SHORT_5_5_5_1 && type != GL_UNSIGNED_INT_2_10_10_10_REV_EXT) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage3DOES(format=0x%x)", format); + return; + } + break; + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + if (type != GL_UNSIGNED_BYTE) { + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage3DOES(format=0x%x)", format); + return; + } + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_OPERATION, "glTexSubImage3DOES(format=0x%x)", format); + return; + } + + _mesa_TexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); +} + +extern void GL_APIENTRY _mesa_Uniform1fARB(GLint location, GLfloat v0); +#define _es_Uniform1f _mesa_Uniform1fARB + +extern void GL_APIENTRY _mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * values); +#define _es_Uniform1fv _mesa_Uniform1fvARB + +extern void GL_APIENTRY _mesa_Uniform1iARB(GLint location, GLint v0); +#define _es_Uniform1i _mesa_Uniform1iARB + +extern void GL_APIENTRY _mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * values); +#define _es_Uniform1iv _mesa_Uniform1ivARB + +extern void GL_APIENTRY _mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1); +#define _es_Uniform2f _mesa_Uniform2fARB + +extern void GL_APIENTRY _mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * values); +#define _es_Uniform2fv _mesa_Uniform2fvARB + +extern void GL_APIENTRY _mesa_Uniform2iARB(GLint location, GLint v0, GLint v1); +#define _es_Uniform2i _mesa_Uniform2iARB + +extern void GL_APIENTRY _mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * values); +#define _es_Uniform2iv _mesa_Uniform2ivARB + +extern void GL_APIENTRY _mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +#define _es_Uniform3f _mesa_Uniform3fARB + +extern void GL_APIENTRY _mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * values); +#define _es_Uniform3fv _mesa_Uniform3fvARB + +extern void GL_APIENTRY _mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2); +#define _es_Uniform3i _mesa_Uniform3iARB + +extern void GL_APIENTRY _mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * values); +#define _es_Uniform3iv _mesa_Uniform3ivARB + +extern void GL_APIENTRY _mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +#define _es_Uniform4f _mesa_Uniform4fARB + +extern void GL_APIENTRY _mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * values); +#define _es_Uniform4fv _mesa_Uniform4fvARB + +extern void GL_APIENTRY _mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +#define _es_Uniform4i _mesa_Uniform4iARB + +extern void GL_APIENTRY _mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * values); +#define _es_Uniform4iv _mesa_Uniform4ivARB + +extern void GL_APIENTRY _mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define _es_UniformMatrix2fv _mesa_UniformMatrix2fvARB + +extern void GL_APIENTRY _mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define _es_UniformMatrix3fv _mesa_UniformMatrix3fvARB + +extern void GL_APIENTRY _mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define _es_UniformMatrix4fv _mesa_UniformMatrix4fvARB + +extern GLboolean GL_APIENTRY _mesa_UnmapBufferARB(GLenum target); +static GLboolean GL_APIENTRY _es_UnmapBufferOES(GLenum target) +{ + switch(target) { + case GL_ARRAY_BUFFER: + case GL_ELEMENT_ARRAY_BUFFER: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_ENUM, "glUnmapBufferOES(target=0x%x)", target); + return GL_FALSE; + } + + return _mesa_UnmapBufferARB(target); +} + +extern void GL_APIENTRY _mesa_UseProgramObjectARB(GLuint program); +#define _es_UseProgram _mesa_UseProgramObjectARB + +extern void GL_APIENTRY _mesa_ValidateProgramARB(GLuint program); +#define _es_ValidateProgram _mesa_ValidateProgramARB + +extern void GL_APIENTRY _vbo_VertexAttrib1f(GLuint index, GLfloat x); +#define _es_VertexAttrib1f _vbo_VertexAttrib1f + +extern void GL_APIENTRY _vbo_VertexAttrib1fv(GLuint index, const GLfloat * v); +#define _es_VertexAttrib1fv _vbo_VertexAttrib1fv + +extern void GL_APIENTRY _vbo_VertexAttrib2f(GLuint index, GLfloat x, GLfloat y); +#define _es_VertexAttrib2f _vbo_VertexAttrib2f + +extern void GL_APIENTRY _vbo_VertexAttrib2fv(GLuint index, const GLfloat * v); +#define _es_VertexAttrib2fv _vbo_VertexAttrib2fv + +extern void GL_APIENTRY _vbo_VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z); +#define _es_VertexAttrib3f _vbo_VertexAttrib3f + +extern void GL_APIENTRY _vbo_VertexAttrib3fv(GLuint index, const GLfloat * v); +#define _es_VertexAttrib3fv _vbo_VertexAttrib3fv + +extern void GL_APIENTRY _vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +#define _es_VertexAttrib4f _vbo_VertexAttrib4f + +extern void GL_APIENTRY _vbo_VertexAttrib4fv(GLuint index, const GLfloat * v); +#define _es_VertexAttrib4fv _vbo_VertexAttrib4fv + +extern void GL_APIENTRY _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); +static void GL_APIENTRY _es_VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer) +{ + switch(size) { + case 1: + case 2: + case 3: + case 4: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glVertexAttribPointer(size=%d)", size); + return; + } + switch(type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_FLOAT: + case GL_FIXED: + break; + default: + _mesa_error(_mesa_get_current_context(), GL_INVALID_VALUE, "glVertexAttribPointer(type=0x%x)", type); + return; + } + + _mesa_VertexAttribPointerARB(index, size, type, normalized, stride, pointer); +} + +extern void GL_APIENTRY _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height); +#define _es_Viewport _mesa_Viewport + + +struct _glapi_table * +_mesa_create_exec_table_es2(void) +{ + struct _glapi_table *exec; + exec = _mesa_alloc_dispatch_table(sizeof *exec); + if (exec == NULL) + return NULL; + + + SET_ActiveTexture(exec, _es_ActiveTexture); + SET_AttachShader(exec, _es_AttachShader); + SET_BindAttribLocation(exec, _es_BindAttribLocation); + SET_BindBuffer(exec, _es_BindBuffer); + SET_BindFramebuffer(exec, _es_BindFramebuffer); + SET_BindRenderbuffer(exec, _es_BindRenderbuffer); + SET_BindTexture(exec, _es_BindTexture); + SET_BlendColor(exec, _es_BlendColor); + SET_BlendEquation(exec, _es_BlendEquation); + SET_BlendEquationSeparate(exec, _es_BlendEquationSeparate); + SET_BlendFunc(exec, _es_BlendFunc); + SET_BlendFuncSeparate(exec, _es_BlendFuncSeparate); + SET_BufferData(exec, _es_BufferData); + SET_BufferSubData(exec, _es_BufferSubData); + SET_CheckFramebufferStatus(exec, _es_CheckFramebufferStatus); + SET_Clear(exec, _es_Clear); + SET_ClearColor(exec, _es_ClearColor); + SET_ClearDepthf(exec, _es_ClearDepthf); + SET_ClearStencil(exec, _es_ClearStencil); + SET_ColorMask(exec, _es_ColorMask); + SET_CompileShader(exec, _es_CompileShader); + SET_CompressedTexImage2D(exec, _es_CompressedTexImage2D); + SET_CompressedTexImage3DOES(exec, _es_CompressedTexImage3DOES); + SET_CompressedTexSubImage2D(exec, _es_CompressedTexSubImage2D); + SET_CompressedTexSubImage3DOES(exec, _es_CompressedTexSubImage3DOES); + SET_CopyTexImage2D(exec, _es_CopyTexImage2D); + SET_CopyTexSubImage2D(exec, _es_CopyTexSubImage2D); + SET_CopyTexSubImage3DOES(exec, _es_CopyTexSubImage3DOES); + SET_CreateProgram(exec, _es_CreateProgram); + SET_CreateShader(exec, _es_CreateShader); + SET_CullFace(exec, _es_CullFace); + SET_DeleteBuffers(exec, _es_DeleteBuffers); + SET_DeleteFramebuffers(exec, _es_DeleteFramebuffers); + SET_DeleteProgram(exec, _es_DeleteProgram); + SET_DeleteRenderbuffers(exec, _es_DeleteRenderbuffers); + SET_DeleteShader(exec, _es_DeleteShader); + SET_DeleteTextures(exec, _es_DeleteTextures); + SET_DepthFunc(exec, _es_DepthFunc); + SET_DepthMask(exec, _es_DepthMask); + SET_DepthRangef(exec, _es_DepthRangef); + SET_DetachShader(exec, _es_DetachShader); + SET_Disable(exec, _es_Disable); + SET_DisableVertexAttribArray(exec, _es_DisableVertexAttribArray); + SET_DrawArrays(exec, _es_DrawArrays); + SET_DrawElements(exec, _es_DrawElements); + SET_EGLImageTargetRenderbufferStorageOES(exec, _es_EGLImageTargetRenderbufferStorageOES); + SET_EGLImageTargetTexture2DOES(exec, _es_EGLImageTargetTexture2DOES); + SET_Enable(exec, _es_Enable); + SET_EnableVertexAttribArray(exec, _es_EnableVertexAttribArray); + SET_Finish(exec, _es_Finish); + SET_Flush(exec, _es_Flush); + SET_FramebufferRenderbuffer(exec, _es_FramebufferRenderbuffer); + SET_FramebufferTexture2D(exec, _es_FramebufferTexture2D); + SET_FramebufferTexture3DOES(exec, _es_FramebufferTexture3DOES); + SET_FrontFace(exec, _es_FrontFace); + SET_GenBuffers(exec, _es_GenBuffers); + SET_GenFramebuffers(exec, _es_GenFramebuffers); + SET_GenRenderbuffers(exec, _es_GenRenderbuffers); + SET_GenTextures(exec, _es_GenTextures); + SET_GenerateMipmap(exec, _es_GenerateMipmap); + SET_GetActiveAttrib(exec, _es_GetActiveAttrib); + SET_GetActiveUniform(exec, _es_GetActiveUniform); + SET_GetAttachedShaders(exec, _es_GetAttachedShaders); + SET_GetAttribLocation(exec, _es_GetAttribLocation); + SET_GetBooleanv(exec, _es_GetBooleanv); + SET_GetBufferParameteriv(exec, _es_GetBufferParameteriv); + SET_GetBufferPointervOES(exec, _es_GetBufferPointervOES); + SET_GetError(exec, _es_GetError); + SET_GetFloatv(exec, _es_GetFloatv); + SET_GetFramebufferAttachmentParameteriv(exec, _es_GetFramebufferAttachmentParameteriv); + SET_GetIntegerv(exec, _es_GetIntegerv); + SET_GetProgramInfoLog(exec, _es_GetProgramInfoLog); + SET_GetProgramiv(exec, _es_GetProgramiv); + SET_GetRenderbufferParameteriv(exec, _es_GetRenderbufferParameteriv); + SET_GetShaderInfoLog(exec, _es_GetShaderInfoLog); + SET_GetShaderPrecisionFormat(exec, _es_GetShaderPrecisionFormat); + SET_GetShaderSource(exec, _es_GetShaderSource); + SET_GetShaderiv(exec, _es_GetShaderiv); + SET_GetString(exec, _es_GetString); + SET_GetTexParameterfv(exec, _es_GetTexParameterfv); + SET_GetTexParameteriv(exec, _es_GetTexParameteriv); + SET_GetUniformLocation(exec, _es_GetUniformLocation); + SET_GetUniformfv(exec, _es_GetUniformfv); + SET_GetUniformiv(exec, _es_GetUniformiv); + SET_GetVertexAttribPointerv(exec, _es_GetVertexAttribPointerv); + SET_GetVertexAttribfv(exec, _es_GetVertexAttribfv); + SET_GetVertexAttribiv(exec, _es_GetVertexAttribiv); + SET_Hint(exec, _es_Hint); + SET_IsBuffer(exec, _es_IsBuffer); + SET_IsEnabled(exec, _es_IsEnabled); + SET_IsFramebuffer(exec, _es_IsFramebuffer); + SET_IsProgram(exec, _es_IsProgram); + SET_IsRenderbuffer(exec, _es_IsRenderbuffer); + SET_IsShader(exec, _es_IsShader); + SET_IsTexture(exec, _es_IsTexture); + SET_LineWidth(exec, _es_LineWidth); + SET_LinkProgram(exec, _es_LinkProgram); + SET_MapBufferOES(exec, _es_MapBufferOES); + SET_MultiDrawArraysEXT(exec, _es_MultiDrawArraysEXT); + SET_MultiDrawElementsEXT(exec, _es_MultiDrawElementsEXT); + SET_PixelStorei(exec, _es_PixelStorei); + SET_PolygonOffset(exec, _es_PolygonOffset); + SET_ReadPixels(exec, _es_ReadPixels); + SET_ReleaseShaderCompiler(exec, _es_ReleaseShaderCompiler); + SET_RenderbufferStorage(exec, _check_RenderbufferStorage); + SET_SampleCoverage(exec, _es_SampleCoverage); + SET_Scissor(exec, _es_Scissor); + SET_ShaderBinary(exec, _es_ShaderBinary); + SET_ShaderSource(exec, _es_ShaderSource); + SET_StencilFunc(exec, _es_StencilFunc); + SET_StencilFuncSeparate(exec, _es_StencilFuncSeparate); + SET_StencilMask(exec, _es_StencilMask); + SET_StencilMaskSeparate(exec, _es_StencilMaskSeparate); + SET_StencilOp(exec, _es_StencilOp); + SET_StencilOpSeparate(exec, _es_StencilOpSeparate); + SET_TexImage2D(exec, _es_TexImage2D); + SET_TexImage3DOES(exec, _es_TexImage3DOES); + SET_TexParameterf(exec, _es_TexParameterf); + SET_TexParameterfv(exec, _es_TexParameterfv); + SET_TexParameteri(exec, _es_TexParameteri); + SET_TexParameteriv(exec, _es_TexParameteriv); + SET_TexSubImage2D(exec, _es_TexSubImage2D); + SET_TexSubImage3DOES(exec, _es_TexSubImage3DOES); + SET_Uniform1f(exec, _es_Uniform1f); + SET_Uniform1fv(exec, _es_Uniform1fv); + SET_Uniform1i(exec, _es_Uniform1i); + SET_Uniform1iv(exec, _es_Uniform1iv); + SET_Uniform2f(exec, _es_Uniform2f); + SET_Uniform2fv(exec, _es_Uniform2fv); + SET_Uniform2i(exec, _es_Uniform2i); + SET_Uniform2iv(exec, _es_Uniform2iv); + SET_Uniform3f(exec, _es_Uniform3f); + SET_Uniform3fv(exec, _es_Uniform3fv); + SET_Uniform3i(exec, _es_Uniform3i); + SET_Uniform3iv(exec, _es_Uniform3iv); + SET_Uniform4f(exec, _es_Uniform4f); + SET_Uniform4fv(exec, _es_Uniform4fv); + SET_Uniform4i(exec, _es_Uniform4i); + SET_Uniform4iv(exec, _es_Uniform4iv); + SET_UniformMatrix2fv(exec, _es_UniformMatrix2fv); + SET_UniformMatrix3fv(exec, _es_UniformMatrix3fv); + SET_UniformMatrix4fv(exec, _es_UniformMatrix4fv); + SET_UnmapBufferOES(exec, _es_UnmapBufferOES); + SET_UseProgram(exec, _es_UseProgram); + SET_ValidateProgram(exec, _es_ValidateProgram); + SET_VertexAttrib1f(exec, _es_VertexAttrib1f); + SET_VertexAttrib1fv(exec, _es_VertexAttrib1fv); + SET_VertexAttrib2f(exec, _es_VertexAttrib2f); + SET_VertexAttrib2fv(exec, _es_VertexAttrib2fv); + SET_VertexAttrib3f(exec, _es_VertexAttrib3f); + SET_VertexAttrib3fv(exec, _es_VertexAttrib3fv); + SET_VertexAttrib4f(exec, _es_VertexAttrib4f); + SET_VertexAttrib4fv(exec, _es_VertexAttrib4fv); + SET_VertexAttribPointer(exec, _es_VertexAttribPointer); + SET_Viewport(exec, _es_Viewport); + + return exec; +} + +#endif /* FEATURE_ES2 */ |